From 908f130d584964adc74d7ac8acd142bc9494cbb7 Mon Sep 17 00:00:00 2001 From: Jean-Daniel Dupas Date: Thu, 1 Mar 2012 14:53:16 +0000 Subject: Implement double underscore names support in __has_attribute llvm-svn: 151809 --- clang/lib/Lex/PPMacroExpansion.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'clang/lib/Lex') diff --git a/clang/lib/Lex/PPMacroExpansion.cpp b/clang/lib/Lex/PPMacroExpansion.cpp index 007be3bed2d..56ce407c186 100644 --- a/clang/lib/Lex/PPMacroExpansion.cpp +++ b/clang/lib/Lex/PPMacroExpansion.cpp @@ -760,7 +760,12 @@ static bool HasExtension(const Preprocessor &PP, const IdentifierInfo *II) { /// HasAttribute - Return true if we recognize and implement the attribute /// specified by the given identifier. static bool HasAttribute(const IdentifierInfo *II) { - return llvm::StringSwitch(II->getName()) + StringRef Name = II->getName(); + // Normalize the attribute name, __foo__ becomes foo. + if (Name.startswith("__") && Name.endswith("__") && Name.size() >= 4) + Name = Name.substr(2, Name.size() - 4); + + return llvm::StringSwitch(Name) #include "clang/Lex/AttrSpellings.inc" .Default(false); } -- cgit v1.2.3