[PATCH] D51329: [Attribute/Diagnostics] Print macro instead of whole attribute for address_space

Leonard Chan via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 30 10:08:11 PDT 2018


leonardchan added inline comments.


================
Comment at: lib/Parse/ParseDecl.cpp:244-252
+    // If this was declared in a macro, attatch the macro IdentifierInfo to the
+    // parsed attribute.
+    for (const auto &MacroPair : PP.getAttributeMacros()) {
+      if (SourceLocInSourceRange(AttrTok.getLocation(), MacroPair.first,
+                                 PP.getSourceManager())) {
+        ApplyMacroIIToParsedAttrs(attrs, NumParsedAttrs, MacroPair.second);
+        break;
----------------
rsmith wrote:
> You shouldn't do this if `NumParsedAttrs != 1`. We're only looking for a macro that exactly covers one attribute.
> 
> (Also, your computation of the number of attributes in the attribute list is not correct in the presence of late-parsed attributes.)
One of the things we would like is for this to cover more than one attribute in the attribute list since in sparse, `address_space` is sometimes used with `noderef`.

So given `# define __user __attribute__((noderef, address_space(1)))`, `__user` would be saved into the `ParsedAttr` made for `noderef` and `address_space`.

What would be the appropriate way to track newly added attributes into the `ParsedAttributes`, including late-parsed attributes?


Repository:
  rC Clang

https://reviews.llvm.org/D51329





More information about the cfe-commits mailing list