[cfe-dev] wrong getLocEnd() returns

nicolas normand doomyster at gmail.com
Mon Nov 4 02:33:00 PST 2013


Hi clang devs,

Using clang 3.3, I noticed that some classes (clang::FloatingLiteral
for exemple) lacks the End Location information, returning the Start
Location instead.

As an example, these sources
void function() {
float f = 0.0;
}

gives an AST like (I just keep the interesting part):
CompoundStmt 0x5457228 <test1.c:1:17, line:3:1>
`-DeclStmt 0x5457210 <line:2:1, col:14>             // Ok this that
  `-VarDecl 0x5457180 <col:1, col:11> f 'float'       // It should end at 13
    `-ImplicitCastExpr 0x54571f8 <col:11> 'float' <FloatingCast>
// Same here
      `-FloatingLiteral 0x54571d8 <col:11> 'double' 0.000000e+00    // Same here

It is problematic for me, because I can't trust the return of
getLocEnd() methods (I want to rewrite sources and need precise
locations).
Patching this seemed not hard to me, so I gave it a try and succeeded
for FloatingLiteral.

I was wondering if there were good reasons NOT doing this patch for
all objects ?
Would you be interested in such patches ?
Are there other ways to retrieve precise end locations ?

Thanks,
  Nicolas



More information about the cfe-dev mailing list