[PATCH] D137979: parse: process GNU and standard attributes on top-level decls

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 21 10:42:46 PST 2022


aaron.ballman added inline comments.


================
Comment at: clang/lib/Parse/Parser.cpp:1096-1097
+    ParsingDeclSpec &DS, AccessSpecifier AS) {
+  DS.SetRangeStart(DeclSpecAttrs.Range.getBegin());
+  DS.SetRangeEnd(DeclSpecAttrs.Range.getEnd());
+  DS.takeAttributesFrom(DeclSpecAttrs);
----------------
compnerd wrote:
> aaron.ballman wrote:
> > How sure are you that this isn't overwriting existing range data that's potentially relevant? e.g., where declaration specifiers and attributes are mixed together such that the attribute range doesn't cover all of the declaration specifiers?
> I don't believe it can - the range hasn't been setup yet when coming into this function, only the storage has been allocated.  This is the first place where we are initializing the source range.  If there are other unstated invariants, it would be nice to have some sort of assertion for them.
Ah, so we could perhaps assert that the range is invalid on entry and leave a comment explaining why we're asserting/what's going on?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137979/new/

https://reviews.llvm.org/D137979



More information about the cfe-commits mailing list