diff options
author | Aaron Ballman <aaron@aaronballman.com> | 2018-11-09 17:19:45 +0000 |
---|---|---|
committer | Aaron Ballman <aaron@aaronballman.com> | 2018-11-09 17:19:45 +0000 |
commit | c44c174246280dc7614b6591f48010858f482eb9 (patch) | |
tree | ee0b46581c0d7149fdf74e5c5943b534b7fec331 /clang/lib/Basic/Attributes.cpp | |
parent | 21e7f5e24eb1fef1676d70eb013b1346482a7bac (diff) | |
download | bcm5719-llvm-c44c174246280dc7614b6591f48010858f482eb9.tar.gz bcm5719-llvm-c44c174246280dc7614b6591f48010858f482eb9.zip |
Introduce the _Clang scoped attribute token.
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 introduces the _Clang scoped attribute identifier as an alias for clang. It also introduces a warning with a fixit on the off chance someone attempts to use __clang__ as the scoped attribute (which is a predefined compiler identification macro).
llvm-svn: 346521
Diffstat (limited to 'clang/lib/Basic/Attributes.cpp')
-rw-r--r-- | clang/lib/Basic/Attributes.cpp | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/clang/lib/Basic/Attributes.cpp b/clang/lib/Basic/Attributes.cpp index 1c84d0779e1..9a8eb3d932c 100644 --- a/clang/lib/Basic/Attributes.cpp +++ b/clang/lib/Basic/Attributes.cpp @@ -9,16 +9,18 @@ int clang::hasAttribute(AttrSyntax Syntax, const IdentifierInfo *Scope, const LangOptions &LangOpts) { StringRef Name = Attr->getName(); // Normalize the attribute name, __foo__ becomes foo. - if (Name.size() >= 4 && Name.startswith("__") && Name.endswith("__"))
- Name = Name.substr(2, Name.size() - 4);
-
- // Normalize the scope name, but only for gnu attributes.
- StringRef ScopeName = Scope ? Scope->getName() : "";
- if (ScopeName == "__gnu__")
- ScopeName = ScopeName.slice(2, ScopeName.size() - 2);
-
-#include "clang/Basic/AttrHasAttributeImpl.inc"
-
+ if (Name.size() >= 4 && Name.startswith("__") && Name.endswith("__")) + Name = Name.substr(2, Name.size() - 4); + + // Normalize the scope name, but only for gnu and clang attributes. + StringRef ScopeName = Scope ? Scope->getName() : ""; + if (ScopeName == "__gnu__") + ScopeName = "gnu"; + else if (ScopeName == "_Clang") + ScopeName = "clang"; + +#include "clang/Basic/AttrHasAttributeImpl.inc" + return 0;
} |