[cfe-dev] SourceLocation of CXXConstructExpr nodes
John McCall
rjmccall at apple.com
Mon Feb 6 10:59:16 PST 2012
On Feb 4, 2012, at 2:36 PM, Nicola Gigante wrote:
> Hello.
>
> I'm trying to fix my patch [1] to make it pass all the tests.
> Currently, Index/recursive-cxx-member-calls.cpp fails with my patch
> because of the following issue.
>
> Consider this code:
>
> class Foo
> {
> public:
> Foo(const char *);
> };
>
> Foo func()
> {
> const char *c;
> return Foo(c);
> }
>
> The AST currently produced for the return statement is:
> (ReturnStmt <line:10:4, col:16>
> (CXXConstructExpr <col:11, col:16> 'class Foo''void (const class Foo &) throw()' elidable
> (MaterializeTemporaryExpr <col:11, col:16> 'const class Foo' lvalue
> (ImplicitCastExpr <col:11, col:16> 'const class Foo' <NoOp>
> (CXXFunctionalCastExpr <col:11, col:16> 'class Foo' functional cast to class Foo
> (CXXConstructExpr <col:11, col:15> 'class Foo''void (const char *)'
> (ImplicitCastExpr <col:15> 'const char *' <LValueToRValue>
> (DeclRefExpr <col:15> 'const char *' lvalue Var 0x7f92eb03afb0 'c' 'const char *')))))))))
>
> After my patch, the CXXFunctionalCastExpr node becomes:
> (CXXFunctionalCastExpr <col:11, col:16> 'class Foo' functional cast to class Foo <ConstructorConversion>
> (CXXConstructExpr <col:11, col:16> 'class Foo''void (const char *)'
> (ImplicitCastExpr <col:15> 'const char *' <LValueToRValue>
> (DeclRefExpr <col:15> 'const char *' lvalue Var 0x7fe0eb858640 'c' 'const char *')))))))))
>
>
> You see that now the inner CXXConstructExpr source range ends at column 16, while before it used
> to end at column 15.
> Is there any reason why the CXXConstructExpr range should end one character before the CXXFunctionalCastExpr,
> when they in fact refer to the same piece of code?
> The c-index test fails because of this change, but I think the new behaviour is correct. If so, I'll update the test case.
> Do you agree with me?
I agree.
John.
More information about the cfe-dev
mailing list