21#include "llvm/ADT/StringSwitch.h"
27 if (Name ==
"__gnu__")
38 if (Name.size() >= 4 && Name.starts_with(
"__") && Name.ends_with(
"__"))
39 return Name.substr(2, Name.size() - 4);
47#include "clang/Basic/AttrHasAttributeImpl.inc"
64 if (LangOpts.OpenMP && ScopeName ==
"omp" &&
65 (Name ==
"directive" || Name ==
"sequence"))
75 if (Ptr->hasSpelling(Syntax, Name))
87 Target, LangOpts, CheckPlugins);
99#define ATTR_MATCH_RULE(NAME, SPELLING, IsAbstract) \
102#include "clang/Basic/AttrSubMatchRulesList.inc"
104 llvm_unreachable(
"Invalid subject match rule");
126 StringRef NormalizedScopeName,
130 bool ShouldNormalize =
134 (NormalizedScopeName.empty() || NormalizedScopeName ==
"gnu" ||
135 NormalizedScopeName ==
"clang"));
153 return AttrScope.isValid() && (AttrScope.getName()->isStr(
"gnu") ||
154 AttrScope.getName()->isStr(
"__gnu__"));
158 return AttrScope.isValid() && (AttrScope.getName()->isStr(
"clang") ||
159 AttrScope.getName()->isStr(
"_Clang"));
162#include "clang/Sema/AttrParsedAttrKinds.inc"
170 if (!ScopeName.empty()) {
175 FullName += StrAttrName;
193 ::getAttrKind(
normalizeName(Name, ScopeName, SyntaxUsed), SyntaxUsed);
196 return AttributeCommonInfo::Kind::AT_HLSLUnparsedSemantic;
204#define CXX11_ATTR_ARGS_INFO
205 return llvm::StringSwitch<AttributeCommonInfo::AttrArgsInfo>(AttrName)
206#include "clang/Basic/CXX11AttributeInfo.inc"
208#undef CXX11_ATTR_ARGS_INFO
212 return static_cast<std::string
>(
218 StringRef AttrName)
const {
219 return static_cast<std::string
>(
230 return llvm::StringSwitch<AttributeCommonInfo::Scope>(ScopeName)
242unsigned AttributeCommonInfo::calculateAttributeSpellingListIndex()
const {
252#include "clang/Sema/AttrSpellingListIndex.inc"
255#define ATTR_NAME(NAME) NAME,
257#include "clang/Basic/AttributeSpellingList.inc"
260#define ATTR_SCOPE_NAME(SCOPE_NAME) SCOPE_NAME,
262#include "clang/Basic/AttributeSpellingList.inc"
265std::optional<StringRef>
267 if (ScopeName.size() > 0 &&
274 return CorrectedScopeName;
291 return CorrectedAttrName;
static StringRef canonicalizeAttrName(StringRef Name)
static StringRef normalizeAttrName(StringRef AttrName, StringRef NormalizedScopeName, AttributeCommonInfo::Syntax SyntaxUsed)
static constexpr const char * AttrScopeSpellingList[]
static StringRef canonicalizeScopeName(StringRef Name)
static AttributeCommonInfo::Scope getScopeFromNormalizedScopeName(StringRef ScopeName)
static SmallString< 64 > normalizeName(StringRef AttrName, StringRef ScopeName, AttributeCommonInfo::Syntax SyntaxUsed)
static constexpr const char * AttrSpellingList[]
static int hasAttributeImpl(AttributeCommonInfo::Syntax Syntax, StringRef Name, StringRef ScopeName, const TargetInfo &Target, const LangOptions &LangOpts)
static StringRef normalizeAttrScopeName(StringRef ScopeName, 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.
@ AS_HLSLAnnotation
<vardecl> : <annotation>
const IdentifierInfo * getScopeName() const
StringRef getNormalizedAttrName(StringRef ScopeName) const
std::optional< StringRef > tryGetCorrectedAttrName(StringRef ScopeName, StringRef AttrName, const TargetInfo &Target, const LangOptions &LangOpts) const
static AttrArgsInfo getCXX11AttrArgsInfo(const IdentifierInfo *Name)
SourceRange getNormalizedRange() const
std::optional< StringRef > tryGetCorrectedScopeName(StringRef ScopeName) const
const IdentifierInfo * getAttrName() const
StringRef getNormalizedScopeName() const
Kind getParsedKind() const
One of these records is kept for each identifier that is lexed.
StringRef getName() const
Return the actual identifier 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.
std::optional< StringRef > getCorrection() const
void add(const StringRef Candidate)
A trivial tuple used to represent a source range.
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)
StringRef getName(const HeaderType T)
The JSON file list parser is used to communicate input to InstallAPI.
int hasAttribute(AttributeCommonInfo::Syntax Syntax, llvm::StringRef ScopeName, llvm::StringRef AttrName, const TargetInfo &Target, const LangOptions &LangOpts, bool CheckPlugins)
Return the version number associated with the attribute if we recognize and implement the attribute s...
const std::list< std::unique_ptr< ParsedAttrInfo > > & getAttributePluginInstances()