[PATCH] D68581: Include leading attributes in DeclStmt's SourceRange
Stephan Bergmann via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 10 03:56:30 PDT 2019
sberg updated this revision to Diff 224303.
sberg edited the summary of this revision.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D68581/new/
https://reviews.llvm.org/D68581
Files:
clang/lib/Parse/ParseStmt.cpp
clang/test/AST/sourceranges.cpp
Index: clang/test/AST/sourceranges.cpp
===================================================================
--- clang/test/AST/sourceranges.cpp
+++ clang/test/AST/sourceranges.cpp
@@ -143,4 +143,14 @@
new int{0};
}
}
+
+// CHECK-1Z: NamespaceDecl {{.*}} attributed_decl
+namespace attributed_decl {
+ void f() {
+ // CHECK-1Z: DeclStmt {{.*}} <line:[[@LINE+1]]:5, col:27>
+ [[maybe_unused]] int i;
+ // CHECK-1Z: DeclStmt {{.*}} <line:[[@LINE+1]]:5, col:34>
+ int __attribute__((unused)) j;
+ }
+}
#endif
Index: clang/lib/Parse/ParseStmt.cpp
===================================================================
--- clang/lib/Parse/ParseStmt.cpp
+++ clang/lib/Parse/ParseStmt.cpp
@@ -220,6 +220,8 @@
Decl =
ParseDeclaration(DeclaratorContext::BlockContext, DeclEnd, Attrs);
}
+ if (Attrs.Range.getBegin().isValid())
+ DeclStart = Attrs.Range.getBegin();
return Actions.ActOnDeclStmt(Decl, DeclStart, DeclEnd);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D68581.224303.patch
Type: text/x-patch
Size: 1002 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20191010/ba253f0f/attachment.bin>
More information about the cfe-commits
mailing list