13 #ifndef LLVM_CLANG_AST_ATTR_H
14 #define LLVM_CLANG_AST_ATTR_H
29 #include "llvm/ADT/SmallSet.h"
30 #include "llvm/ADT/StringSwitch.h"
31 #include "llvm/Frontend/HLSL/HLSLResource.h"
32 #include "llvm/Support/CodeGen.h"
33 #include "llvm/Support/ErrorHandling.h"
34 #include "llvm/Support/VersionTuple.h"
35 #include "llvm/Support/raw_ostream.h"
41 class AttributeCommonInfo;
49 unsigned AttrKind : 16;
54 LLVM_PREFERRED_TYPE(
bool)
56 LLVM_PREFERRED_TYPE(
bool)
58 LLVM_PREFERRED_TYPE(
bool)
62 LLVM_PREFERRED_TYPE(
bool)
64 LLVM_PREFERRED_TYPE(
bool)
67 void *operator new(
size_t bytes) noexcept {
68 llvm_unreachable(
"Attrs cannot be allocated with regular 'new'.");
70 void operator delete(
void *data) noexcept {
71 llvm_unreachable(
"Attrs cannot be released with regular 'delete'.");
77 size_t Alignment = 8) noexcept {
78 return ::operator
new(Bytes, C, Alignment);
80 void operator delete(
void *Ptr,
ASTContext &C,
size_t Alignment) noexcept {
81 return ::operator
delete(Ptr, C, Alignment);
130 return A->
getKind() >= attr::FirstTypeAttr &&
131 A->
getKind() <= attr::LastTypeAttr;
143 return A->
getKind() >= attr::FirstStmtAttr &&
144 A->
getKind() <= attr::LastStmtAttr;
168 return A->
getKind() >= attr::FirstInheritableAttr &&
169 A->
getKind() <= attr::LastInheritableAttr;
183 return A->
getKind() >= attr::FirstDeclOrStmtAttr &&
184 A->
getKind() <= attr::LastDeclOrStmtAttr;
199 return A->
getKind() >= attr::FirstInheritableParamAttr &&
200 A->
getKind() <= attr::LastInheritableParamAttr;
215 return A->
getKind() >= attr::FirstHLSLAnnotationAttr &&
216 A->
getKind() <= attr::LastHLSLAnnotationAttr;
233 case attr::SwiftContext:
235 case attr::SwiftAsyncContext:
237 case attr::SwiftErrorResult:
239 case attr::SwiftIndirectResult:
242 llvm_unreachable(
"bad parameter ABI attribute kind");
247 return A->
getKind() >= attr::FirstParameterABIAttr &&
248 A->
getKind() <= attr::LastParameterABIAttr;
257 LLVM_PREFERRED_TYPE(
bool)
258 unsigned HasThis : 1;
259 LLVM_PREFERRED_TYPE(
bool)
260 unsigned IsValid : 1;
262 void assertComparable(
const ParamIdx &I)
const {
264 "ParamIdx must be valid to be compared");
269 assert(HasThis == I.HasThis &&
270 "ParamIdx must be for the same function to be compared");
285 : Idx(Idx), HasThis(
false), IsValid(
true) {
286 assert(Idx >= 1 &&
"Idx must be one-origin");
287 if (
const auto *FD = dyn_cast<FunctionDecl>(
D))
288 HasThis = FD->isCXXInstanceMember();
300 return *
reinterpret_cast<const SerialType *
>(
this);
307 void *ParamIdxPtr =
static_cast<void *
>(&S);
309 assert((!
P.IsValid ||
P.Idx >= 1) &&
"valid Idx must be one-origin");
323 assert(
isValid() &&
"ParamIdx must be valid");
334 assert(
isValid() &&
"ParamIdx must be valid");
335 assert(Idx >= 1 + HasThis &&
336 "stored index must be base-1 and not specify C++ implicit this");
337 return Idx - 1 - HasThis;
345 assert(
isValid() &&
"ParamIdx must be valid");
346 assert(Idx >= 1 &&
"stored index must be base-1");
377 "ParamIdx does not fit its serialization type");
379 #include "clang/AST/Attrs.inc"
Forward declaration of all AST node types.
static StringRef bytes(const std::vector< T, Allocator > &v)
Defines the clang::attr::Kind enum.
Defines the clang::Expr interface and subclasses for C++ expressions.
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Defines the clang::LangOptions interface.
Defines some OpenMP-specific enums and functions.
Defines the clang::SanitizerKind enum.
Defines the clang::SourceLocation class and associated facilities.
C Language Family Type Representation.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Attr - This represents one attribute.
unsigned getSpellingListIndex() const
Attr * clone(ASTContext &C) const
Attr(ASTContext &Context, const AttributeCommonInfo &CommonInfo, attr::Kind AK, bool IsLateParsed)
attr::Kind getKind() const
void printPretty(raw_ostream &OS, const PrintingPolicy &Policy) const
static StringRef getDocumentation(attr::Kind)
unsigned InheritEvenIfAlreadyPresent
unsigned Inherited
An index into the spelling list of an attribute defined in Attr.td file.
void setPackExpansion(bool PE)
bool isImplicit() const
Returns true if the attribute has been implicitly created instead of explicitly written by the user.
const char * getSpelling() const
SourceLocation getLocation() const
bool isLateParsed() const
bool isPackExpansion() const
SourceRange getRange() const
unsigned getAttributeSpellingListIndex() const
static bool classof(const Attr *A)
DeclOrStmtAttr(ASTContext &Context, const AttributeCommonInfo &CommonInfo, attr::Kind AK, bool IsLateParsed, bool InheritEvenIfAlreadyPresent)
Decl - This represents one declaration (or definition), e.g.
HLSLAnnotationAttr(ASTContext &Context, const AttributeCommonInfo &CommonInfo, attr::Kind AK, bool IsLateParsed, bool InheritEvenIfAlreadyPresent)
static bool classof(const Attr *A)
void setInherited(bool I)
static bool classof(const Attr *A)
InheritableAttr(ASTContext &Context, const AttributeCommonInfo &CommonInfo, attr::Kind AK, bool IsLateParsed, bool InheritEvenIfAlreadyPresent)
bool shouldInheritEvenIfAlreadyPresent() const
Should this attribute be inherited from a prior declaration even if it's explicitly provided in the c...
static bool classof(const Attr *A)
InheritableParamAttr(ASTContext &Context, const AttributeCommonInfo &CommonInfo, attr::Kind AK, bool IsLateParsed, bool InheritEvenIfAlreadyPresent)
A single parameter index whose accessors require each use to make explicit the parameter index encodi...
bool operator==(const ParamIdx &I) const
bool operator<=(const ParamIdx &I) const
ParamIdx()
Construct an invalid parameter index (isValid returns false and accessors fail an assert).
bool operator<(const ParamIdx &I) const
bool isValid() const
Is this parameter index valid?
static ParamIdx deserialize(SerialType S)
Construct from a result from serialize.
unsigned getSourceIndex() const
Get the parameter index as it would normally be encoded for attributes at the source level of represe...
bool operator>=(const ParamIdx &I) const
unsigned getLLVMIndex() const
Get the parameter index as it would normally be encoded at the LLVM level of representation: zero-ori...
ParamIdx(unsigned Idx, const Decl *D)
unsigned getASTIndex() const
Get the parameter index as it would normally be encoded at the AST level of representation: zero-orig...
bool operator>(const ParamIdx &I) const
uint32_t SerialType
A type into which ParamIdx can be serialized.
SerialType serialize() const
Produce a representation that can later be passed to deserialize to construct an equivalent ParamIdx.
bool operator!=(const ParamIdx &I) const
A parameter attribute which changes the argument-passing ABI rule for the parameter.
ParameterABI getABI() const
ParameterABIAttr(ASTContext &Context, const AttributeCommonInfo &CommonInfo, attr::Kind AK, bool IsLateParsed, bool InheritEvenIfAlreadyPresent)
static bool classof(const Attr *A)
Encodes a location in the source.
SourceLocation getBegin() const
static bool classof(const Attr *A)
StmtAttr(ASTContext &Context, const AttributeCommonInfo &CommonInfo, attr::Kind AK, bool IsLateParsed)
The streaming interface shared between DiagnosticBuilder and PartialDiagnostic.
void AddTaggedVal(uint64_t V, DiagnosticsEngine::ArgumentKind Kind) const
TypeAttr(ASTContext &Context, const AttributeCommonInfo &CommonInfo, attr::Kind AK, bool IsLateParsed)
static bool classof(const Attr *A)
The JSON file list parser is used to communicate input to InstallAPI.
const StreamingDiagnostic & operator<<(const StreamingDiagnostic &DB, const ASTContext::SectionInfo &Section)
Insertion operator for diagnostics.
ParameterABI
Kinds of parameter ABI.
@ SwiftAsyncContext
This parameter (which must have pointer type) uses the special Swift asynchronous context-pointer ABI...
@ SwiftErrorResult
This parameter (which must have pointer-to-pointer type) uses the special Swift error-result ABI trea...
@ SwiftIndirectResult
This parameter (which must have pointer type) is a Swift indirect result parameter.
@ SwiftContext
This parameter (which must have pointer type) uses the special Swift context-pointer ABI treatment.
Describes how types, statements, expressions, and declarations should be printed.