diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2019-10-17 11:20:21 +0000 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2019-10-17 11:20:21 +0000 |
commit | 0572918ae27ed9703ecbbfc3d3bdd99d63d27dde (patch) | |
tree | 448118994b0470e37fb30727bb3e8aede9d1e315 | |
parent | 5632b3f285e75da13100c7198a058582ea29cb90 (diff) |
Include leading attributes in DeclStmt's SourceRange
Differential Revision: https://reviews.llvm.org/D68581
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@375104 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Parse/ParseStmt.cpp | 2 | ||||
-rw-r--r-- | test/AST/sourceranges.cpp | 16 |
2 files changed, 18 insertions, 0 deletions
diff --git a/lib/Parse/ParseStmt.cpp b/lib/Parse/ParseStmt.cpp index 3bfe4a70ba..727ab75ada 100644 --- a/lib/Parse/ParseStmt.cpp +++ b/lib/Parse/ParseStmt.cpp @@ -220,6 +220,8 @@ Retry: Decl = ParseDeclaration(DeclaratorContext::BlockContext, DeclEnd, Attrs); } + if (Attrs.Range.getBegin().isValid()) + DeclStart = Attrs.Range.getBegin(); return Actions.ActOnDeclStmt(Decl, DeclStart, DeclEnd); } diff --git a/test/AST/sourceranges.cpp b/test/AST/sourceranges.cpp index 53f2f57e67..3c023c8689 100644 --- a/test/AST/sourceranges.cpp +++ b/test/AST/sourceranges.cpp @@ -92,6 +92,22 @@ struct map { }; // namespace std
+// CHECK: NamespaceDecl {{.*}} attributed_decl
+namespace attributed_decl {
+ void f() {
+ // CHECK: DeclStmt {{.*}} <line:[[@LINE+1]]:5, col:28>
+ [[maybe_unused]] int i1;
+ // CHECK: DeclStmt {{.*}} <line:[[@LINE+1]]:5, col:35>
+ __attribute__((unused)) int i2;
+ // CHECK: DeclStmt {{.*}} <line:[[@LINE+1]]:5, col:35>
+ int __attribute__((unused)) i3;
+ // CHECK: DeclStmt {{.*}} <<built-in>:{{.*}}, {{.*}}:[[@LINE+1]]:40>
+ __declspec(dllexport) extern int i4;
+ // CHECK: DeclStmt {{.*}} <line:[[@LINE+1]]:5, col:40>
+ extern int __declspec(dllexport) i5;
+ }
+}
+
#if __cplusplus >= 201703L
// CHECK-1Z: FunctionDecl {{.*}} construct_with_init_list
std::map<int, int> construct_with_init_list() {
|