5 #include "llvm/ADT/StringSwitch.h" 11 StringRef Name =
Attr->getName();
13 if (Name.size() >= 4 && Name.startswith(
"__") && Name.endswith(
"__"))
14 Name = Name.substr(2, Name.size() - 4);
17 StringRef ScopeName =
Scope ?
Scope->getName() :
"";
18 if (ScopeName ==
"__gnu__")
20 else if (ScopeName ==
"_Clang")
23 #include "clang/Basic/AttrHasAttributeImpl.inc" 30 #define ATTR_MATCH_RULE(NAME, SPELLING, IsAbstract) \ 33 #include "clang/Basic/AttrSubMatchRulesList.inc" 35 llvm_unreachable(
"Invalid subject match rule");
46 StringRef ScopeName =
Scope->getName();
49 if (ScopeName ==
"__gnu__")
51 else if (ScopeName ==
"_Clang")
58 StringRef NormalizedScopeName,
62 bool ShouldNormalize =
66 (NormalizedScopeName.empty() || NormalizedScopeName ==
"gnu" ||
67 NormalizedScopeName ==
"clang"));
68 StringRef AttrName = Name->getName();
69 if (ShouldNormalize && AttrName.size() >= 4 && AttrName.startswith(
"__") &&
70 AttrName.endswith(
"__"))
71 AttrName = AttrName.slice(2, AttrName.size() - 2);
77 return ScopeName && (ScopeName->
isStr(
"gnu") || ScopeName->
isStr(
"__gnu__"));
80 #include "clang/Sema/AttrParsedAttrKinds.inc" 89 if (!ScopeName.empty()) {
103 return ::getAttrKind(
normalizeName(Name, ScopeName, SyntaxUsed), SyntaxUsed);
107 return static_cast<std::string>(
111 unsigned AttributeCommonInfo::calculateAttributeSpellingListIndex()
const {
118 #include "clang/Sema/AttrSpellingListIndex.inc"
Syntax
The style used to specify an attribute.
One of these records is kept for each identifier that is lexed.
SubjectMatchRule
A list of all the recognized kinds of attributes.
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Scope - A scope is a transient data structure that is used while parsing the program.
int hasAttribute(AttrSyntax Syntax, const IdentifierInfo *Scope, const IdentifierInfo *Attr, const TargetInfo &Target, const LangOptions &LangOpts)
Return the version number associated with the attribute if we recognize and implement the attribute s...
static StringRef normalizeAttrName(const IdentifierInfo *Name, StringRef NormalizedScopeName, AttributeCommonInfo::Syntax SyntaxUsed)
const IdentifierInfo * getAttrName() const
Exposes information about the current target.
static StringRef normalizeAttrScopeName(const IdentifierInfo *Scope, AttributeCommonInfo::Syntax SyntaxUsed)
static SmallString< 64 > normalizeName(const IdentifierInfo *Name, const IdentifierInfo *Scope, AttributeCommonInfo::Syntax SyntaxUsed)
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
const char * getSubjectMatchRuleSpelling(SubjectMatchRule Rule)
Dataflow Directional Tag Classes.
std::string getNormalizedFullName() const
Gets the normalized full name, which consists of both scope and name and with surrounding underscores...
const IdentifierInfo * getScopeName() const
Kind getParsedKind() const
Attr - This represents one attribute.