Skip to content

Wrong source range for CXXTemporaryObjectExpr #143711

@tJener

Description

@tJener

See https://godbolt.org/z/6cdcj1qqY

struct S {
    S(int, int);
};

void f() {
    S(S(0, 1));
}

When the CXXTemporaryObjectExpr is wrapped with a CXXFunctionalCastExpr, the source range of the CXXTemporaryObjectExpr contains the closing parenthesis of the CXXFunctionalCastExpr.

This occurs starting in -std=c++17, where guaranteed copy elision is in effect. In C++14, there is an intervening CXXConstructExpr and the CXXTemporaryObjectExpr has the correct source range (although Compiler Explorer's highlighting of AST nodes includes the closing parenthesis, as if )) was a single token).

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"confirmedVerified by a second party

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions