[PATCH] D53591: Support the __gnu__ scoped attribute token

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 23 11:12:16 PDT 2018


aaron.ballman created this revision.
aaron.ballman added reviewers: rsmith, dblaikie, echristo.
Herald added a subscriber: krytarowski.

GCC is currently considering a patch to accept `__gnu__` as a scoped attribute namespace that aliases to `gnu`. This is useful for libstdc++ so that they don't have to worry about stepping on the user's namespace. The GCC bug can be found at: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86288

This patch supports parsing `__gnu__`, but it does support `__clang__` similarly because `__clang__` is a predefined macro that expands to an empty expansion. In order to support `[[__clang__::foobar]]` as an attribute spelling, I think we'd need to introduce some frontend hacks. Rather than get bogged down in that support, I am proposing to support only `__gnu__` for the moment, to ensure we remain compatible with libstdc++ when it makes the switch to the new attribute namespace.

Btw, an alternative implementation strategy here would be to make the `GCC` spelling introduce both the `gnu` and `__gnu__` variants of the attribute in addition to the GNU-style spelling. We have no CXX11 spellings that manually specify `gnu` as the vendor namespace, so this would suffice, but it feels a bit more fragile than baking this into the attribute system directly.


https://reviews.llvm.org/D53591

Files:
  include/clang/Sema/ParsedAttr.h
  lib/Basic/Attributes.cpp
  lib/Parse/ParseDeclCXX.cpp
  lib/Sema/ParsedAttr.cpp
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaType.cpp
  test/Preprocessor/has_attribute.cpp
  test/SemaCXX/attr-gnu.cpp
  utils/TableGen/ClangAttrEmitter.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53591.170701.patch
Type: text/x-patch
Size: 7796 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20181023/4ed71c52/attachment.bin>


More information about the cfe-commits mailing list