[cfe-dev] SourceLocations for faux subexpressions of CXXForRangeStmt

Ted Kremenek kremenek at apple.com
Tue Oct 4 22:15:43 PDT 2011

I recently did an AST dump of CXXForRangeStmt, which led to the discover that the "faux" expressions representing the semantics of this statement have actual SourceLocations:

  (CXXForRangeStmt 0x7fb8db83dad8 <line:4:3, col:34>
    (DeclStmt 0x7fb8db83d5a8 <col:17>
      0x7fb8db83d3a0 "auto int (&&__range)[2] =
        (DeclRefExpr 0x7fb8db83d260 <col:17> 'int [2]' lvalue Var 0x7fb8db83d030 'array' 'int [2]')")
    (DeclStmt 0x7fb8db83d8e8 <col:15>
      0x7fb8db83d600 "auto int *__begin =
        (ImplicitCastExpr 0x7fb8db83d7c0 <col:15> 'int *' <ArrayToPointerDecay>

I'm trying to understand why we would do this, as this could possibly pose problems with clients that want to reason about how the source was actually written.  These expressions don't actually appear in the source.  Should they even have valid SourceLocations?


More information about the cfe-dev mailing list