Index: test/Lexer/has_attribute.cpp
===================================================================
--- test/Lexer/has_attribute.cpp	(revision 151477)
+++ test/Lexer/has_attribute.cpp	(working copy)
@@ -5,6 +5,11 @@
 int always_inline();
 #endif
 
+// CHECK: __always_inline__
+#if __has_attribute(__always_inline__)
+int __always_inline__();
+#endif
+
 // CHECK: no_dummy_attribute
 #if !__has_attribute(dummy_attribute)
 int no_dummy_attribute();
Index: lib/Lex/PPMacroExpansion.cpp
===================================================================
--- lib/Lex/PPMacroExpansion.cpp	(revision 151477)
+++ lib/Lex/PPMacroExpansion.cpp	(working copy)
@@ -760,7 +760,14 @@
 /// HasAttribute -  Return true if we recognize and implement the attribute
 /// specified by the given identifier.
 static bool HasAttribute(const IdentifierInfo *II) {
-    return llvm::StringSwitch<bool>(II->getName())
+  StringRef Attribute = II->getName();
+
+  // Normalize the attribute name, __foo__ becomes foo.
+  if (Attribute.startswith("__") && Attribute.endswith("__") &&
+      Attribute.size() >= 4)
+    Attribute = Attribute.substr(2, Attribute.size() - 4);
+    
+    return llvm::StringSwitch<bool>(Attribute)
 #include "clang/Lex/AttrSpellings.inc"
         .Default(false);
 }
