Page MenuHomePhabricator

Support _Clang as a scoped attribute identifier

Authored by aaron.ballman on Oct 25 2018, 7:22 AM.



Currently, we only accept clang as the scoped attribute identifier for double square bracket attributes provided by Clang, but this has the potential to conflict with user-defined macros. To help alleviate these concerns, this patch introduces the _Clang scoped attribute identifier as an alias for clang.

GCC elected to go with __gnu__ for their protected name, but we cannot follow suit due to __clang__ being a predefined macro that identifies the implementation. I added a warning with a fixit on the off chance someone attempts to use __clang__ as the scoped attribute identifier, but do not support the spelling fully (for instance, __has_cpp_attribute does not support __clang__).

Diff Detail

Event Timeline

aaron.ballman created this revision.Oct 25 2018, 7:22 AM

Another option that @rsmith and I discussed today is perhaps using __clang or clang__ as the identifier, but perhaps this will cause more confusion about where to put underscores than _Clang would. If there are other ideas that are more palatable for the identifier, that'd be great -- I am not strongly tied to a spelling.

Adding some libc++ maintainers to see if they have opinions on the identifier picked.

ldionne accepted this revision.Nov 8 2018, 3:49 PM

I'm fine with _Clang or anything else too. Thanks for doing this!


That was a complicated way of doing something simple.

This revision is now accepted and ready to land.Nov 8 2018, 3:49 PM
rsmith accepted this revision.Nov 8 2018, 4:07 PM

Let's do it. The diagnostic and fix-it is awesome ;)

aaron.ballman closed this revision.Nov 9 2018, 9:22 AM

Thanks for the reviews -- I've commit in r346521.