aboutsummaryrefslogtreecommitdiff
path: root/clang/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
commit2fbf99429a156523fa9bdee917a3a19d57ef7b8e (patch)
tree5722f190e46201a403181342ea9e6bb4aac227fc /clang/lib/Basic/Attributes.cpp
parent8aa19c1392d681712a3e556ea4206279d29f49e9 (diff)
downloadllvm-2fbf99429a156523fa9bdee917a3a19d57ef7b8e.zip
llvm-2fbf99429a156523fa9bdee917a3a19d57ef7b8e.tar.gz
llvm-2fbf99429a156523fa9bdee917a3a19d57ef7b8e.tar.bz2
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. llvm-svn: 205181
Diffstat (limited to 'clang/lib/Basic/Attributes.cpp')
-rw-r--r--clang/lib/Basic/Attributes.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/clang/lib/Basic/Attributes.cpp b/clang/lib/Basic/Attributes.cpp
new file mode 100644
index 0000000..c882bc2
--- /dev/null
+++ b/clang/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;
+}