summaryrefslogtreecommitdiffstats
path: root/clang/lib/Lex
diff options
context:
space:
mode:
authorJean-Daniel Dupas <devlists@shadowlab.org>2012-03-01 14:53:16 +0000
committerJean-Daniel Dupas <devlists@shadowlab.org>2012-03-01 14:53:16 +0000
commit908f130d584964adc74d7ac8acd142bc9494cbb7 (patch)
treefeaf2fb1b139e3be5112cf97f85a2342d9d9c8c0 /clang/lib/Lex
parent8e9d772c5af4e567af150297b2c99da4dee7bdf2 (diff)
downloadbcm5719-llvm-908f130d584964adc74d7ac8acd142bc9494cbb7.tar.gz
bcm5719-llvm-908f130d584964adc74d7ac8acd142bc9494cbb7.zip
Implement double underscore names support in __has_attribute
llvm-svn: 151809
Diffstat (limited to 'clang/lib/Lex')
-rw-r--r--clang/lib/Lex/PPMacroExpansion.cpp7
1 files changed, 6 insertions, 1 deletions
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<bool>(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<bool>(Name)
#include "clang/Lex/AttrSpellings.inc"
.Default(false);
}
OpenPOWER on IntegriCloud