Author: sberg Date: Thu Oct 17 04:20:21 2019 New Revision: 375104 URL: http://llvm.org/viewvc/llvm-project?rev=375104&view=rev Log: Include leading attributes in DeclStmt's SourceRange
Differential Revision: https://reviews.llvm.org/D68581 Modified: cfe/trunk/lib/Parse/ParseStmt.cpp cfe/trunk/test/AST/sourceranges.cpp Modified: cfe/trunk/lib/Parse/ParseStmt.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseStmt.cpp?rev=375104&r1=375103&r2=375104&view=diff ============================================================================== --- cfe/trunk/lib/Parse/ParseStmt.cpp (original) +++ cfe/trunk/lib/Parse/ParseStmt.cpp Thu Oct 17 04:20:21 2019 @@ -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); } Modified: cfe/trunk/test/AST/sourceranges.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/AST/sourceranges.cpp?rev=375104&r1=375103&r2=375104&view=diff ============================================================================== --- cfe/trunk/test/AST/sourceranges.cpp (original) +++ cfe/trunk/test/AST/sourceranges.cpp Thu Oct 17 04:20:21 2019 @@ -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() { _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits