13 #ifndef LLVM_CLANG_AST_ATTR_H 14 #define LLVM_CLANG_AST_ATTR_H 27 #include "llvm/ADT/StringSwitch.h" 28 #include "llvm/Support/ErrorHandling.h" 29 #include "llvm/Support/VersionTuple.h" 30 #include "llvm/Support/raw_ostream.h" 36 class AttributeCommonInfo;
38 class ObjCInterfaceDecl;
47 unsigned AttrKind : 16;
60 void *
operator new(
size_t bytes) noexcept {
61 llvm_unreachable(
"Attrs cannot be allocated with regular 'new'.");
63 void operator delete(
void *data) noexcept {
64 llvm_unreachable(
"Attrs cannot be released with regular 'delete'.");
70 size_t Alignment = 8) noexcept {
71 return ::operator
new(Bytes,
C, Alignment);
73 void operator delete(
void *Ptr,
ASTContext &
C,
size_t Alignment) noexcept {
74 return ::operator
delete(Ptr,
C, Alignment);
117 :
Attr(Context, CommonInfo, AK, IsLateParsed) {}
121 return A->
getKind() >= attr::FirstTypeAttr &&
122 A->
getKind() <= attr::LastTypeAttr;
130 :
Attr(Context, CommonInfo, AK, IsLateParsed) {}
134 return A->
getKind() >= attr::FirstStmtAttr &&
135 A->
getKind() <= attr::LastStmtAttr;
144 :
Attr(Context, CommonInfo, AK, IsLateParsed) {
159 return A->
getKind() >= attr::FirstInheritableAttr &&
160 A->
getKind() <= attr::LastInheritableAttr;
170 InheritEvenIfAlreadyPresent) {}
175 return A->
getKind() >= attr::FirstInheritableParamAttr &&
176 A->
getKind() <= attr::LastInheritableParamAttr;
188 InheritEvenIfAlreadyPresent) {}
193 case attr::SwiftContext:
195 case attr::SwiftErrorResult:
197 case attr::SwiftIndirectResult:
200 llvm_unreachable(
"bad parameter ABI attribute kind");
205 return A->
getKind() >= attr::FirstParameterABIAttr &&
206 A->
getKind() <= attr::LastParameterABIAttr;
215 unsigned HasThis : 1;
216 unsigned IsValid : 1;
218 void assertComparable(
const ParamIdx &I)
const {
219 assert(isValid() && I.
isValid() &&
220 "ParamIdx must be valid to be compared");
225 assert(HasThis == I.HasThis &&
226 "ParamIdx must be for the same function to be compared");
241 : Idx(Idx), HasThis(
false), IsValid(
true) {
242 assert(Idx >= 1 &&
"Idx must be one-origin");
243 if (
const auto *FD = dyn_cast<FunctionDecl>(D))
244 HasThis = FD->isCXXInstanceMember();
256 return *
reinterpret_cast<const SerialType *
>(
this);
261 ParamIdx P(*reinterpret_cast<ParamIdx *>(&S));
262 assert((!P.IsValid || P.Idx >= 1) &&
"valid Idx must be one-origin");
276 assert(isValid() &&
"ParamIdx must be valid");
287 assert(isValid() &&
"ParamIdx must be valid");
288 assert(Idx >= 1 + HasThis &&
289 "stored index must be base-1 and not specify C++ implicit this");
290 return Idx - 1 - HasThis;
298 assert(isValid() &&
"ParamIdx must be valid");
299 assert(Idx >= 1 &&
"stored index must be base-1");
330 "ParamIdx does not fit its serialization type");
337 bool DuplicateArchitecture =
false;
344 #include "clang/AST/Attrs.inc" std::vector< std::string > Features
const char * getSpelling() const
bool operator==(CanQual< T > x, CanQual< U > y)
ParamIdx()
Construct an invalid parameter index (isValid returns false and accessors fail an assert)...
C Language Family Type Representation.
Decl - This represents one declaration (or definition), e.g.
void AddTaggedVal(intptr_t V, DiagnosticsEngine::ArgumentKind Kind) const
const DiagnosticBuilder & operator<<(const DiagnosticBuilder &DB, const Attr *At)
unsigned Inherited
An index into the spelling list of an attribute defined in Attr.td file.
Attr(ASTContext &Context, const AttributeCommonInfo &CommonInfo, attr::Kind AK, bool IsLateParsed)
static bool classof(const Attr *A)
bool operator<=(const ParamIdx &I) const
Describes how types, statements, expressions, and declarations should be printed. ...
static StringRef bytes(const std::vector< T, Allocator > &v)
bool isValid() const
Is this parameter index valid?
Defines the clang::SanitizerKind enum.
void AddTaggedVal(intptr_t V, DiagnosticsEngine::ArgumentKind Kind) const
unsigned InheritEvenIfAlreadyPresent
bool isImplicit() const
Returns true if the attribute has been implicitly created instead of explicitly written by the user...
ParameterABI getABI() const
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
unsigned getSourceIndex() const
Get the parameter index as it would normally be encoded for attributes at the source level of represe...
Defines the clang::attr::Kind enum.
Defines some OpenMP-specific enums and functions.
This parameter (which must have pointer type) uses the special Swift context-pointer ABI treatment...
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
static bool classof(const Attr *A)
This parameter (which must have pointer-to-pointer type) uses the special Swift error-result ABI trea...
Contains information gathered from parsing the contents of TargetAttr.
A little helper class used to produce diagnostics.
static bool classof(const Attr *A)
unsigned getLLVMIndex() const
Get the parameter index as it would normally be encoded at the LLVM level of representation: zero-ori...
bool operator<(const ParamIdx &I) const
bool operator!=(const ParamIdx &I) const
A single parameter index whose accessors require each use to make explicit the parameter index encodi...
bool isPackExpansion() const
bool shouldInheritEvenIfAlreadyPresent() const
Should this attribute be inherited from a prior declaration even if it's explicitly provided in the c...
bool operator==(const ParamIdx &I) const
InheritableParamAttr(ASTContext &Context, const AttributeCommonInfo &CommonInfo, attr::Kind AK, bool IsLateParsed, bool InheritEvenIfAlreadyPresent)
static bool classof(const Attr *A)
bool operator>(const ParamIdx &I) const
unsigned getASTIndex() const
Get the parameter index as it would normally be encoded at the AST level of representation: zero-orig...
A parameter attribute which changes the argument-passing ABI rule for the parameter.
Encodes a location in the source.
Attr * clone(ASTContext &C) const
unsigned getSpellingListIndex() const
void setPackExpansion(bool PE)
ParamIdx(unsigned Idx, const Decl *D)
SourceLocation getLocation() const
SourceRange getRange() const
void printPretty(raw_ostream &OS, const PrintingPolicy &Policy) const
ParameterABI
Kinds of parameter ABI.
StringRef BranchProtection
Dataflow Directional Tag Classes.
static ParamIdx deserialize(SerialType S)
Construct from a result from serialize.
bool isLateParsed() const
SerialType serialize() const
Produce a representation that can later be passed to deserialize to construct an equivalent ParamIdx...
uint32_t SerialType
A type into which ParamIdx can be serialized.
void setInherited(bool I)
static bool classof(const Attr *A)
Defines the clang::SourceLocation class and associated facilities.
ParameterABIAttr(ASTContext &Context, const AttributeCommonInfo &CommonInfo, attr::Kind AK, bool IsLateParsed, bool InheritEvenIfAlreadyPresent)
StmtAttr(ASTContext &Context, const AttributeCommonInfo &CommonInfo, attr::Kind AK, bool IsLateParsed)
bool DuplicateArchitecture
unsigned getAttributeSpellingListIndex() const
bool operator>=(const ParamIdx &I) const
TypeAttr(ASTContext &Context, const AttributeCommonInfo &CommonInfo, attr::Kind AK, bool IsLateParsed)
attr::Kind getKind() const
SourceLocation getBegin() const
Attr - This represents one attribute.
This parameter (which must have pointer type) is a Swift indirect result parameter.
InheritableAttr(ASTContext &Context, const AttributeCommonInfo &CommonInfo, attr::Kind AK, bool IsLateParsed, bool InheritEvenIfAlreadyPresent)