[PATCH] D68581: Include leading attributes in DeclStmt's SourceRange
Stephan Bergmann via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 7 08:22:29 PDT 2019
sberg created this revision.
sberg added reviewers: aaron.ballman, rsmith, Nathan-Huckleberry.
Herald added a project: clang.
For a `DeclStmt` like
[[maybe_unused]] int i;
`getBeginLoc()` returned the start of `int` instead of the start of `[[` (see http://lists.llvm.org/pipermail/cfe-dev/2019-September/063434.html "[cfe-dev] Poor DeclStmt source range with leading [[attributes]]?").
Is there a good way to write a test for this?
Repository:
rC Clang
https://reviews.llvm.org/D68581
Files:
clang/lib/Parse/ParseStmt.cpp
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.223610.patch
Type: text/x-patch
Size: 462 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20191007/b97bbc99/attachment.bin>
More information about the cfe-commits
mailing list