[cfe-dev] SourceLocation of CXXConstructExpr nodes

Nicola Gigante nicola.gigante at gmail.com
Sat Feb 4 14:36:21 PST 2012


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
  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?

Thank you,

[1]  http://lists.cs.uiuc.edu/pipermail/cfe-dev/2011-December/019297.html

More information about the cfe-dev mailing list