14 #ifndef LLVM_CLANG_AST_ATTR_H 15 #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::FirstStmtAttr &&
125 A->
getKind() <= attr::LastStmtAttr;
133 :
Attr(AK, R, SpellingListIndex, IsLateParsed) {
148 return A->
getKind() >= attr::FirstInheritableAttr &&
149 A->
getKind() <= attr::LastInheritableAttr;
158 InheritEvenIfAlreadyPresent) {}
163 return A->
getKind() >= attr::FirstInheritableParamAttr &&
164 A->
getKind() <= attr::LastInheritableParamAttr;
176 InheritEvenIfAlreadyPresent) {}
181 case attr::SwiftContext:
183 case attr::SwiftErrorResult:
185 case attr::SwiftIndirectResult:
188 llvm_unreachable(
"bad parameter ABI attribute kind");
193 return A->
getKind() >= attr::FirstParameterABIAttr &&
194 A->
getKind() <= attr::LastParameterABIAttr;
203 unsigned HasThis : 1;
204 unsigned IsValid : 1;
206 void assertComparable(
const ParamIdx &I)
const {
207 assert(isValid() && I.
isValid() &&
208 "ParamIdx must be valid to be compared");
213 assert(HasThis == I.HasThis &&
214 "ParamIdx must be for the same function to be compared");
229 : Idx(Idx), HasThis(
false), IsValid(
true) {
230 assert(Idx >= 1 &&
"Idx must be one-origin");
231 if (
const auto *FD = dyn_cast<FunctionDecl>(D))
232 HasThis = FD->isCXXInstanceMember();
244 return *
reinterpret_cast<const SerialType *
>(
this);
249 ParamIdx P(*reinterpret_cast<ParamIdx *>(&S));
250 assert((!P.IsValid || P.Idx >= 1) &&
"valid Idx must be one-origin");
264 assert(isValid() &&
"ParamIdx must be valid");
275 assert(isValid() &&
"ParamIdx must be valid");
276 assert(Idx >= 1 + HasThis &&
277 "stored index must be base-1 and not specify C++ implicit this");
278 return Idx - 1 - HasThis;
286 assert(isValid() &&
"ParamIdx must be valid");
287 assert(Idx >= 1 &&
"stored index must be base-1");
318 "ParamIdx does not fit its serialization type");
320 #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...
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
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.