13 #ifndef LLVM_CLANG_AST_ATTR_H 14 #define LLVM_CLANG_AST_ATTR_H 26 #include "llvm/ADT/StringSwitch.h" 27 #include "llvm/Support/ErrorHandling.h" 28 #include "llvm/Support/VersionTuple.h" 29 #include "llvm/Support/raw_ostream.h" 36 class ObjCInterfaceDecl;
46 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);
80 : Range(R), AttrKind(AK), SpellingListIndex(SpellingListIndex),
120 :
Attr(AK, R, SpellingListIndex, IsLateParsed) {}
124 return A->
getKind() >= attr::FirstTypeAttr &&
125 A->
getKind() <= attr::LastTypeAttr;
133 :
Attr(AK, R, SpellingListIndex, IsLateParsed) {}
137 return A->
getKind() >= attr::FirstStmtAttr &&
138 A->
getKind() <= attr::LastStmtAttr;
146 :
Attr(AK, R, SpellingListIndex, IsLateParsed) {
161 return A->
getKind() >= attr::FirstInheritableAttr &&
162 A->
getKind() <= attr::LastInheritableAttr;
171 InheritEvenIfAlreadyPresent) {}
176 return A->
getKind() >= attr::FirstInheritableParamAttr &&
177 A->
getKind() <= attr::LastInheritableParamAttr;
189 InheritEvenIfAlreadyPresent) {}
194 case attr::SwiftContext:
196 case attr::SwiftErrorResult:
198 case attr::SwiftIndirectResult:
201 llvm_unreachable(
"bad parameter ABI attribute kind");
206 return A->
getKind() >= attr::FirstParameterABIAttr &&
207 A->
getKind() <= attr::LastParameterABIAttr;
216 unsigned HasThis : 1;
217 unsigned IsValid : 1;
219 void assertComparable(
const ParamIdx &I)
const {
220 assert(isValid() && I.
isValid() &&
221 "ParamIdx must be valid to be compared");
226 assert(HasThis == I.HasThis &&
227 "ParamIdx must be for the same function to be compared");
242 : Idx(Idx), HasThis(
false), IsValid(
true) {
243 assert(Idx >= 1 &&
"Idx must be one-origin");
244 if (
const auto *FD = dyn_cast<FunctionDecl>(D))
245 HasThis = FD->isCXXInstanceMember();
257 return *
reinterpret_cast<const SerialType *
>(
this);
262 ParamIdx P(*reinterpret_cast<ParamIdx *>(&S));
263 assert((!P.IsValid || P.Idx >= 1) &&
"valid Idx must be one-origin");
277 assert(isValid() &&
"ParamIdx must be valid");
288 assert(isValid() &&
"ParamIdx must be valid");
289 assert(Idx >= 1 + HasThis &&
290 "stored index must be base-1 and not specify C++ implicit this");
291 return Idx - 1 - HasThis;
299 assert(isValid() &&
"ParamIdx must be valid");
300 assert(Idx >= 1 &&
"stored index must be base-1");
331 "ParamIdx does not fit its serialization type");
333 #include "clang/AST/Attrs.inc" const char * getSpelling() const
Attr(attr::Kind AK, SourceRange R, unsigned SpellingListIndex, bool IsLateParsed)
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)
InheritableAttr(attr::Kind AK, SourceRange R, unsigned SpellingListIndex, bool IsLateParsed, bool InheritEvenIfAlreadyPresent)
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...
void setRange(SourceRange R)
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...
InheritableParamAttr(attr::Kind AK, SourceRange R, unsigned SpellingListIndex, bool IsLateParsed, bool InheritEvenIfAlreadyPresent)
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...
TypeAttr(attr::Kind AK, SourceRange R, unsigned SpellingListIndex, bool IsLateParsed)
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
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)
StmtAttr(attr::Kind AK, SourceRange R, unsigned SpellingListIndex, bool IsLateParsed)
ParamIdx(unsigned Idx, const Decl *D)
SourceLocation getLocation() const
void printPretty(raw_ostream &OS, const PrintingPolicy &Policy) const
ParameterABI
Kinds of parameter ABI.
SourceRange getRange() const
Dataflow Directional Tag Classes.
static ParamIdx deserialize(SerialType S)
Construct from a result from serialize.
unsigned SpellingListIndex
An index into the spelling list of an attribute defined in Attr.td file.
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.
bool operator>=(const ParamIdx &I) const
ParameterABIAttr(attr::Kind AK, SourceRange R, unsigned SpellingListIndex, bool IsLateParsed, bool InheritEvenIfAlreadyPresent)
A trivial tuple used to represent a source range.
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.