26#include "clang/Basic/AttrHasAttributeImpl.inc"
34 StringRef Name =
Attr->getName();
36 if (Name.size() >= 4 && Name.startswith(
"__") && Name.endswith(
"__"))
37 Name = Name.substr(2, Name.size() - 4);
40 StringRef ScopeName =
Scope ?
Scope->getName() :
"";
41 if (ScopeName ==
"__gnu__")
43 else if (ScopeName ==
"_Clang")
50 if (LangOpts.OpenMP && ScopeName ==
"omp")
51 return (Name ==
"directive" || Name ==
"sequence") ? 1 : 0;
59 if (Ptr->hasSpelling(Syntax, Name))
67#define ATTR_MATCH_RULE(NAME, SPELLING, IsAbstract) \
70#include "clang/Basic/AttrSubMatchRulesList.inc"
72 llvm_unreachable(
"Invalid subject match rule");
83 StringRef ScopeName =
Scope->getName();
86 if (ScopeName ==
"__gnu__")
88 else if (ScopeName ==
"_Clang")
95 StringRef NormalizedScopeName,
99 bool ShouldNormalize =
103 (NormalizedScopeName.empty() || NormalizedScopeName ==
"gnu" ||
104 NormalizedScopeName ==
"clang"));
105 StringRef AttrName = Name->getName();
106 if (ShouldNormalize && AttrName.size() >= 4 && AttrName.startswith(
"__") &&
107 AttrName.endswith(
"__"))
108 AttrName = AttrName.slice(2, AttrName.size() - 2);
114 return ScopeName && (ScopeName->
isStr(
"gnu") || ScopeName->
isStr(
"__gnu__"));
118 return ScopeName && (ScopeName->
isStr(
"clang") || ScopeName->
isStr(
"_Clang"));
121#include "clang/Sema/AttrParsedAttrKinds.inc"
130 if (!ScopeName.empty()) {
135 FullName += AttrName;
144 return ::getAttrKind(
normalizeName(Name, ScopeName, SyntaxUsed), SyntaxUsed);
148 return static_cast<std::string
>(
152unsigned AttributeCommonInfo::calculateAttributeSpellingListIndex()
const {
159#include "clang/Sema/AttrSpellingListIndex.inc"
static SmallString< 64 > normalizeName(const IdentifierInfo *Name, const IdentifierInfo *Scope, AttributeCommonInfo::Syntax SyntaxUsed)
static int hasAttributeImpl(AttributeCommonInfo::Syntax Syntax, StringRef Name, StringRef ScopeName, const TargetInfo &Target, const LangOptions &LangOpts)
static StringRef normalizeAttrScopeName(const IdentifierInfo *Scope, AttributeCommonInfo::Syntax SyntaxUsed)
static StringRef normalizeAttrName(const IdentifierInfo *Name, StringRef NormalizedScopeName, AttributeCommonInfo::Syntax SyntaxUsed)
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
Defines the clang::LangOptions interface.
Attr - This represents one attribute.
bool isClangScope() const
std::string getNormalizedFullName() const
Gets the normalized full name, which consists of both scope and name and with surrounding underscores...
Syntax
The style used to specify an attribute.
const IdentifierInfo * getScopeName() const
const IdentifierInfo * getAttrName() const
Kind getParsedKind() const
One of these records is kept for each identifier that is lexed.
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.
Exposes information about the current target.
Defines the clang::TargetInfo interface.
SubjectMatchRule
A list of all the recognized kinds of attributes.
const char * getSubjectMatchRuleSpelling(SubjectMatchRule Rule)
int hasAttribute(AttributeCommonInfo::Syntax 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...
const std::list< std::unique_ptr< ParsedAttrInfo > > & getAttributePluginInstances()