13#ifndef LLVM_CLANG_AST_ATTR_H
14#define LLVM_CLANG_AST_ATTR_H
27#include "llvm/Frontend/HLSL/HLSLResource.h"
28#include "llvm/Support/CodeGen.h"
29#include "llvm/Support/ErrorHandling.h"
30#include "llvm/Support/VersionTuple.h"
31#include "llvm/Support/raw_ostream.h"
37class AttributeCommonInfo;
45 unsigned AttrKind : 16;
50 LLVM_PREFERRED_TYPE(
bool)
52 LLVM_PREFERRED_TYPE(
bool)
54 LLVM_PREFERRED_TYPE(
bool)
58 LLVM_PREFERRED_TYPE(
bool)
60 LLVM_PREFERRED_TYPE(
bool)
63 void *operator new(
size_t bytes) noexcept {
64 llvm_unreachable(
"Attrs cannot be allocated with regular 'new'.");
66 void operator delete(
void *data)
noexcept {
67 llvm_unreachable(
"Attrs cannot be released with regular 'delete'.");
73 size_t Alignment = 8)
noexcept {
74 return ::operator
new(Bytes,
C, Alignment);
76 void operator delete(
void *Ptr,
ASTContext &
C,
size_t Alignment)
noexcept {
77 return ::operator
delete(Ptr,
C, Alignment);
126 return A->
getKind() >= attr::FirstTypeAttr &&
127 A->
getKind() <= attr::LastTypeAttr;
139 return A->
getKind() >= attr::FirstStmtAttr &&
140 A->
getKind() <= attr::LastStmtAttr;
164 return A->
getKind() >= attr::FirstInheritableAttr &&
165 A->
getKind() <= attr::LastInheritableAttr;
179 return A->
getKind() >= attr::FirstDeclOrStmtAttr &&
180 A->
getKind() <= attr::LastDeclOrStmtAttr;
195 return A->
getKind() >= attr::FirstInheritableParamAttr &&
196 A->
getKind() <= attr::LastInheritableParamAttr;
211 return A->
getKind() >= attr::FirstHLSLAnnotationAttr &&
212 A->
getKind() <= attr::LastHLSLAnnotationAttr;
229 case attr::SwiftContext:
231 case attr::SwiftAsyncContext:
233 case attr::SwiftErrorResult:
235 case attr::SwiftIndirectResult:
238 llvm_unreachable(
"bad parameter ABI attribute kind");
243 return A->
getKind() >= attr::FirstParameterABIAttr &&
244 A->
getKind() <= attr::LastParameterABIAttr;
253 LLVM_PREFERRED_TYPE(
bool)
254 unsigned HasThis : 1;
255 LLVM_PREFERRED_TYPE(
bool)
256 unsigned IsValid : 1;
258 void assertComparable(
const ParamIdx &I)
const {
260 "ParamIdx must be valid to be compared");
265 assert(HasThis == I.HasThis &&
266 "ParamIdx must be for the same function to be compared");
281 : Idx(Idx), HasThis(
false), IsValid(
true) {
282 assert(Idx >= 1 &&
"Idx must be one-origin");
283 if (
const auto *FD = dyn_cast<FunctionDecl>(
D))
284 HasThis = FD->isCXXInstanceMember();
296 return *
reinterpret_cast<const SerialType *
>(
this);
303 void *ParamIdxPtr =
static_cast<void *
>(&S);
305 assert((!
P.IsValid ||
P.Idx >= 1) &&
"valid Idx must be one-origin");
319 assert(
isValid() &&
"ParamIdx must be valid");
330 assert(
isValid() &&
"ParamIdx must be valid");
331 assert(Idx >= 1 + HasThis &&
332 "stored index must be base-1 and not specify C++ implicit this");
333 return Idx - 1 - HasThis;
341 assert(
isValid() &&
"ParamIdx must be valid");
342 assert(Idx >= 1 &&
"stored index must be base-1");
373 "ParamIdx does not fit its serialization type");
375#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)
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.