[PATCH] D139028: [RFC][clang] Add attribute-like keywords

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 24 08:21:21 PST 2023


aaron.ballman added a reviewer: erichkeane.
aaron.ballman added a comment.

Roping in Erich as the attributes code owner. In general, I think this is going in roughly the right direction. One concern I have is that the distinction between a keyword spelling for an attribute is now a bit harder. We have keyword attributes and we have attribute-like keywords, and it's hard to know when it's appropriate to use one over another. From what I can tell, it seems that the biggest distinction between the two is automatic parsing or not and diagnostic wording (please correct me if I'm missing something!). If I'm correct, then I don't think we want an additional attribute syntax enumeration for this (it's still `AS_Keyword`), but we should surface this via Attr.td/tablegen so that the `Keyword` spelling can opt into the extra generality (or perhaps we want the default to be all keyword attributes get the general behavior and we make a few existing attributes opt out).



================
Comment at: clang/include/clang/Basic/AttributeCommonInfo.h:55
+
+    /// A keyword that can appear wherever a standard attribute can appear.
+    AS_AttributeLikeKeyword,
----------------
I think it would help to describe how this differs from `AS_Keyword` and `AS_ContextSensitiveKeyword` as I would expect these to have considerable overlap.


================
Comment at: clang/include/clang/Basic/TokenKinds.h:105-107
+inline bool isAttributeLikeKeyword(TokenKind K) {
+  return K >= tok::kw___arm_streaming && K <= tok::kw___arm_preserves_za;
+}
----------------
This strikes me as something that should be handled via tablegen -- the spelling used in Attr.td should show what kind of attribute spelling it is (regular keyword or not).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139028



More information about the cfe-commits mailing list