diff options
author | Aaron Ballman <aaron@aaronballman.com> | 2018-10-24 12:26:23 +0000 |
---|---|---|
committer | Aaron Ballman <aaron@aaronballman.com> | 2018-10-24 12:26:23 +0000 |
commit | ad672ffb643c646ca7680c765342bd58252ecdbe (patch) | |
tree | 983949541e2d1345350ca5f6f01833b6db7a09da /clang/lib/Basic/Attributes.cpp | |
parent | c4a995c8e05bd63932677ee30e4f4cfd6623eaff (diff) | |
download | llvm-ad672ffb643c646ca7680c765342bd58252ecdbe.zip llvm-ad672ffb643c646ca7680c765342bd58252ecdbe.tar.gz llvm-ad672ffb643c646ca7680c765342bd58252ecdbe.tar.bz2 |
Support accepting __gnu__ as a scoped attribute namespace that aliases to gnu.
This is useful in libstdc++ to avoid clashes with identifiers in the user's namespace.
llvm-svn: 345132
Diffstat (limited to 'clang/lib/Basic/Attributes.cpp')
-rw-r--r-- | clang/lib/Basic/Attributes.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/clang/lib/Basic/Attributes.cpp b/clang/lib/Basic/Attributes.cpp index b7570d0..1c84d07 100644 --- a/clang/lib/Basic/Attributes.cpp +++ b/clang/lib/Basic/Attributes.cpp @@ -9,12 +9,17 @@ 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); - -#include "clang/Basic/AttrHasAttributeImpl.inc" - - return 0; + 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"
+
+ return 0;
} const char *attr::getSubjectMatchRuleSpelling(attr::SubjectMatchRule Rule) { |