Index: test/Preprocessor/feature_tests.c
===================================================================
--- test/Preprocessor/feature_tests.c	(revision 151367)
+++ test/Preprocessor/feature_tests.c	(working copy)
@@ -21,8 +21,10 @@
 #error Clang should not have this
 #endif
 
+#if __has_feature(attribute_deprecated_with_message) && !__has_feature(__attribute_deprecated_with_message__)
+#error Feature name in double underscores does not work
+#endif
 
-
 // Make sure we have x86 builtins only (forced with target triple).
 
 #if !__has_builtin(__builtin_ia32_emms) || \
Index: docs/LanguageExtensions.html
===================================================================
--- docs/LanguageExtensions.html	(revision 151367)
+++ docs/LanguageExtensions.html	(working copy)
@@ -228,6 +228,11 @@
 
 <p>The feature tag is described along with the language feature below.</p>
 
+<p>The feature name can also be specified with a preceding and following
+<code>__</code> (double underscore) to use them without being concerned about
+a macro with the same name. I.e. <code>__always_inline__</code> can be used
+instead of <code>always_inline</code>.</p>
+
 <!-- ======================================================================= -->
 <h3><a name="__has_attribute">__has_attribute</a></h3>
 <!-- ======================================================================= -->
Index: lib/Lex/PPMacroExpansion.cpp
===================================================================
--- lib/Lex/PPMacroExpansion.cpp	(revision 151367)
+++ lib/Lex/PPMacroExpansion.cpp	(working copy)
@@ -589,8 +589,11 @@
 /// specified by the identifier as a standard language feature.
 static bool HasFeature(const Preprocessor &PP, const IdentifierInfo *II) {
   const LangOptions &LangOpts = PP.getLangOptions();
-
-  return llvm::StringSwitch<bool>(II->getName())
+  StringRef          Feature = II->getName();
+  // Normalize the feature name, __foo__ becomes foo.
+  if (Feature.startswith("__") && Feature.endswith("__"))
+    Feature = Feature.substr(2, Feature.size() - 4);
+  return llvm::StringSwitch<bool>(Feature)
            .Case("address_sanitizer", LangOpts.AddressSanitizer)
            .Case("attribute_analyzer_noreturn", true)
            .Case("attribute_availability", true)
