[PATCH] D100136: Allow applying attributes to subset of allowed subjects.

Artem Belevich via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 8 14:47:00 PDT 2021


tra added inline comments.


================
Comment at: clang/lib/Sema/SemaAttr.cpp:896
+      attr::SubjectMatchRule MatchRule = attr::SubjectMatchRule(Rule.first);
+      if (auto ParentRule = getParentAttrMatcherRule(MatchRule)) {
+        if (llvm::any_of(StrictSubjectMatchRuleSet,
----------------
rsmith wrote:
> Does this need to be a loop? (Can we have a grandparent matcher rule?)
No. We currently have two levels of tablegen classes: `AttrSubjectMatcherRule<list<...AttrSubjectMatcherSubRule> subrules>` and `AttrSubjectMatcherSubRule` does not allow further nesting.


================
Comment at: clang/test/Sema/pragma-attribute-strict-subjects.c:59
 #pragma clang attribute push (__attribute__((abi_tag("a"))), apply_to = any(enum_constant, function, record(unless(is_union)), variable, variable(is_parameter)))
 // FIXME: comma in this diagnostic is wrong.
+// expected-error at -2 {{attribute 'abi_tag' can't be applied to 'enum_constant'}}
----------------
rsmith wrote:
> The FIXME here is "fixed" now. Please can you add another example that shows the incorrect comma and move the FIXME there?
Added another matcher to preserve the comma in the diagnostic.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100136



More information about the cfe-commits mailing list