20#include "llvm/ADT/StringMap.h"
21#include "llvm/ADT/StringSwitch.h"
29#include "clang/Basic/AttrHasAttributeImpl.inc"
38 StringRef Name =
Attr->getName();
40 if (Name.size() >= 4 && Name.starts_with(
"__") && Name.ends_with(
"__"))
41 Name = Name.substr(2, Name.size() - 4);
44 StringRef ScopeName =
Scope ?
Scope->getName() :
"";
45 if (ScopeName ==
"__gnu__")
47 else if (ScopeName ==
"_Clang")
57 if (LangOpts.OpenMP && ScopeName ==
"omp" &&
58 (Name ==
"directive" || Name ==
"sequence"))
68 if (Ptr->hasSpelling(Syntax, Name))
84#define ATTR_MATCH_RULE(NAME, SPELLING, IsAbstract) \
87#include "clang/Basic/AttrSubMatchRulesList.inc"
89 llvm_unreachable(
"Invalid subject match rule");
100 StringRef ScopeName =
Scope->getName();
103 if (ScopeName ==
"__gnu__")
105 else if (ScopeName ==
"_Clang")
112 StringRef NormalizedScopeName,
116 bool ShouldNormalize =
120 (NormalizedScopeName.empty() || NormalizedScopeName ==
"gnu" ||
121 NormalizedScopeName ==
"clang"));
122 StringRef AttrName = Name->getName();
123 if (ShouldNormalize && AttrName.size() >= 4 && AttrName.starts_with(
"__") &&
124 AttrName.ends_with(
"__"))
125 AttrName = AttrName.slice(2, AttrName.size() - 2);
131 return ScopeName && (ScopeName->
isStr(
"gnu") || ScopeName->
isStr(
"__gnu__"));
135 return ScopeName && (ScopeName->
isStr(
"clang") || ScopeName->
isStr(
"_Clang"));
138#include "clang/Sema/AttrParsedAttrKinds.inc"
147 if (!ScopeName.empty()) {
161 return ::getAttrKind(
normalizeName(Name, ScopeName, SyntaxUsed), SyntaxUsed);
168#define CXX11_ATTR_ARGS_INFO
169 return llvm::StringSwitch<AttributeCommonInfo::AttrArgsInfo>(AttrName)
170#include "clang/Basic/CXX11AttributeInfo.inc"
172#undef CXX11_ATTR_ARGS_INFO
176 return static_cast<std::string
>(
182 return llvm::StringSwitch<AttributeCommonInfo::Scope>(ScopeName)
193unsigned AttributeCommonInfo::calculateAttributeSpellingListIndex()
const {
203#include "clang/Sema/AttrSpellingListIndex.inc"
static SmallString< 64 > normalizeName(const IdentifierInfo *Name, const IdentifierInfo *Scope, AttributeCommonInfo::Syntax SyntaxUsed)
static AttributeCommonInfo::Scope getScopeFromNormalizedScopeName(StringRef ScopeName)
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.
llvm::MachO::Target Target
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
static AttrArgsInfo getCXX11AttrArgsInfo(const IdentifierInfo *Name)
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)
The JSON file list parser is used to communicate input to InstallAPI.
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()