[cfe-dev] SourceLocations for faux subexpressions of CXXForRangeStmt
erikjv at me.com
Wed Oct 5 10:30:44 PDT 2011
On 5 okt. 2011, at 19:18, Argyrios Kyrtzidis <kyrtzidis at apple.com> wrote:
> 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) =
>>> (DeclRefExpr 0x7fb8db83d260 <col:17> 'int ' lvalue Var 0x7fb8db83d030 'array' 'int ')")
>>> (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)
FWIW: +1, because it would make implementing source-to-source transformations easier.
More information about the cfe-dev