[cfe-dev] Poor DeclStmt source range with leading [[attributes]]?
Stephan Bergmann via cfe-dev
cfe-dev at lists.llvm.org
Mon Sep 30 07:01:50 PDT 2019
Seen with various versions of Clang, 8.0.0 and recent trunk,
> $ cat test.cc
> void f() {
> [[maybe_unused]] int i;
> }
> clang++ -c -Xclang -ast-dump test.cc
[...]
> `-FunctionDecl 0x8ab1148 <test.cc:1:1, line:3:1> line:1:6 f 'void ()'
> `-CompoundStmt 0x8ab1320 <col:10, line:3:1>
> `-DeclStmt 0x8ab1308 <line:2:19, col:24>
> `-VarDecl 0x8ab1248 <col:19, col:23> col:23 i 'int'
> `-UnusedAttr 0x8ab12b0 <col:4> maybe_unused
Note how the DeclStmt (and the enclosed VarDecl) only start with the
"int" at column 19, not with the "[[" at column 1. (And that matches
what you programmatically obtain from that DeclStmt via
getSourceRange/getBeginLoc.)
Is there some good reason for that, or is it a bug that should get fixed?
More information about the cfe-dev
mailing list