13#ifndef LLVM_CLANG_AST_ATTR_H
14#define LLVM_CLANG_AST_ATTR_H
27#include "llvm/Support/ErrorHandling.h"
28#include "llvm/Support/VersionTuple.h"
29#include "llvm/Support/raw_ostream.h"
35class AttributeCommonInfo;
42 unsigned AttrKind : 16;
55 void *
operator new(
size_t bytes)
noexcept {
56 llvm_unreachable(
"Attrs cannot be allocated with regular 'new'.");
58 void operator delete(
void *data)
noexcept {
59 llvm_unreachable(
"Attrs cannot be released with regular 'delete'.");
65 size_t Alignment = 8)
noexcept {
66 return ::operator
new(Bytes,
C, Alignment);
68 void operator delete(
void *Ptr,
ASTContext &
C,
size_t Alignment)
noexcept {
69 return ::operator
delete(Ptr,
C, Alignment);
118 return A->
getKind() >= attr::FirstTypeAttr &&
119 A->
getKind() <= attr::LastTypeAttr;
131 return A->
getKind() >= attr::FirstStmtAttr &&
132 A->
getKind() <= attr::LastStmtAttr;
156 return A->
getKind() >= attr::FirstInheritableAttr &&
157 A->
getKind() <= attr::LastInheritableAttr;
171 return A->
getKind() >= attr::FirstDeclOrStmtAttr &&
172 A->
getKind() <= attr::LastDeclOrStmtAttr;
187 return A->
getKind() >= attr::FirstInheritableParamAttr &&
188 A->
getKind() <= attr::LastInheritableParamAttr;
203 return A->
getKind() >= attr::FirstHLSLAnnotationAttr &&
204 A->
getKind() <= attr::LastHLSLAnnotationAttr;
221 case attr::SwiftContext:
223 case attr::SwiftAsyncContext:
225 case attr::SwiftErrorResult:
227 case attr::SwiftIndirectResult:
230 llvm_unreachable(
"bad parameter ABI attribute kind");
235 return A->
getKind() >= attr::FirstParameterABIAttr &&
236 A->
getKind() <= attr::LastParameterABIAttr;
245 unsigned HasThis : 1;
246 unsigned IsValid : 1;
248 void assertComparable(
const ParamIdx &I)
const {
250 "ParamIdx must be valid to be compared");
255 assert(HasThis == I.HasThis &&
256 "ParamIdx must be for the same function to be compared");
271 : Idx(Idx), HasThis(
false), IsValid(
true) {
272 assert(Idx >= 1 &&
"Idx must be one-origin");
273 if (
const auto *FD = dyn_cast<FunctionDecl>(D))
274 HasThis = FD->isCXXInstanceMember();
286 return *
reinterpret_cast<const SerialType *
>(
this);
293 void *ParamIdxPtr =
static_cast<void *
>(&S);
295 assert((!
P.IsValid ||
P.Idx >= 1) &&
"valid Idx must be one-origin");
309 assert(
isValid() &&
"ParamIdx must be valid");
320 assert(
isValid() &&
"ParamIdx must be valid");
321 assert(Idx >= 1 + HasThis &&
322 "stored index must be base-1 and not specify C++ implicit this");
323 return Idx - 1 - HasThis;
331 assert(
isValid() &&
"ParamIdx must be valid");
332 assert(Idx >= 1 &&
"stored index must be base-1");
363 "ParamIdx does not fit its serialization type");
365#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.
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(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.
const char * getSpelling() const
void setPackExpansion(bool PE)
bool isImplicit() const
Returns true if the attribute has been implicitly created instead of explicitly written by the user.
Attr * clone(ASTContext &C) 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)
const StreamingDiagnostic & operator<<(const StreamingDiagnostic &DB, const ASTContext::SectionInfo &Section)
Insertion operator for diagnostics.
@ C
Languages that the frontend can parse and compile.
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.