2014-03-31 21:14:44 +08:00
|
|
|
#include "clang/Basic/Attributes.h"
|
2017-04-18 22:33:39 +08:00
|
|
|
#include "clang/Basic/AttrSubjectMatchRules.h"
|
2014-03-31 21:14:44 +08:00
|
|
|
#include "clang/Basic/IdentifierTable.h"
|
|
|
|
#include "llvm/ADT/StringSwitch.h"
|
|
|
|
using namespace clang;
|
|
|
|
|
2014-11-14 21:44:02 +08:00
|
|
|
int clang::hasAttribute(AttrSyntax Syntax, const IdentifierInfo *Scope,
|
2015-07-21 06:57:31 +08:00
|
|
|
const IdentifierInfo *Attr, const TargetInfo &Target,
|
|
|
|
const LangOptions &LangOpts) {
|
2014-03-31 21:14:44 +08:00
|
|
|
StringRef Name = Attr->getName();
|
|
|
|
// Normalize the attribute name, __foo__ becomes foo.
|
2018-11-10 01:19:45 +08:00
|
|
|
if (Name.size() >= 4 && Name.startswith("__") && Name.endswith("__"))
|
|
|
|
Name = Name.substr(2, Name.size() - 4);
|
|
|
|
|
|
|
|
// Normalize the scope name, but only for gnu and clang attributes.
|
|
|
|
StringRef ScopeName = Scope ? Scope->getName() : "";
|
|
|
|
if (ScopeName == "__gnu__")
|
|
|
|
ScopeName = "gnu";
|
|
|
|
else if (ScopeName == "_Clang")
|
|
|
|
ScopeName = "clang";
|
|
|
|
|
|
|
|
#include "clang/Basic/AttrHasAttributeImpl.inc"
|
|
|
|
|
2018-10-24 20:26:23 +08:00
|
|
|
return 0;
|
2014-03-31 21:14:44 +08:00
|
|
|
}
|
2017-04-18 22:33:39 +08:00
|
|
|
|
|
|
|
const char *attr::getSubjectMatchRuleSpelling(attr::SubjectMatchRule Rule) {
|
|
|
|
switch (Rule) {
|
|
|
|
#define ATTR_MATCH_RULE(NAME, SPELLING, IsAbstract) \
|
|
|
|
case attr::NAME: \
|
|
|
|
return SPELLING;
|
|
|
|
#include "clang/Basic/AttrSubMatchRulesList.inc"
|
|
|
|
}
|
|
|
|
llvm_unreachable("Invalid subject match rule");
|
|
|
|
}
|