[cfe-dev] SourceLocations for faux subexpressions of CXXForRangeStmt

Argyrios Kyrtzidis kyrtzidis at apple.com
Wed Oct 5 10:18:01 PDT 2011


On Oct 5, 2011, at 12:05 AM, Abramo Bagnara wrote:

> Il 05/10/2011 07:15, Ted Kremenek ha scritto:
>> 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?
> 
> IMHO locations for generated nodes should point to generating nodes
> (just like template instantiations).

+1, I think given any Stmt* we should be able to know where in source code it was written/generated, otherwise we add unnecessary complexity to clients (imagine just traversing the ast inside a specific source range)

> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev




More information about the cfe-dev mailing list