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
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 @@
                         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) {