summaryrefslogtreecommitdiffstats
path: root/lib/Basic/Attributes.cpp
diff options
context:
space:
mode:
authorAaron Ballman <aaron@aaronballman.com>2014-03-31 13:14:44 +0000
committerAaron Ballman <aaron@aaronballman.com>2014-03-31 13:14:44 +0000
commit3056e7cbc99ea69d655b110e4c6ceb92079522f6 (patch)
tree1e677eb5eed25021e43959c8986a29f54bafb567 /lib/Basic/Attributes.cpp
parent1fe9ec45cdd62dda07c38cf1f6e11a0ed9867847 (diff)
Reapplying r204952 a second time.
Clean up the __has_attribute implementation without modifying its behavior. Replaces the tablegen-driven AttrSpellings.inc, which lived in the lexing layer with AttrHasAttributeImpl.inc, which lives in the basic layer. Updates the preprocessor to call through to this new functionality which can take additional information into account (such as scopes and syntaxes). Expose the ability for parts of the compiler to ask whether an attribute is supported for a given spelling (including scope), syntax, triple and language options. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@205181 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Basic/Attributes.cpp')
-rw-r--r--lib/Basic/Attributes.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/Basic/Attributes.cpp b/lib/Basic/Attributes.cpp
new file mode 100644
index 0000000000..c882bc226d
--- /dev/null
+++ b/lib/Basic/Attributes.cpp
@@ -0,0 +1,17 @@
+#include "clang/Basic/Attributes.h"
+#include "clang/Basic/IdentifierTable.h"
+#include "llvm/ADT/StringSwitch.h"
+using namespace clang;
+
+bool clang::HasAttribute(AttrSyntax Syntax, const IdentifierInfo *Scope,
+ const IdentifierInfo *Attr, const llvm::Triple &T,
+ 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 false;
+}