13#ifndef LLVM_CLANG_AST_ATTR_H
14#define LLVM_CLANG_AST_ATTR_H
28#include "llvm/Frontend/HLSL/HLSLResource.h"
29#include "llvm/Support/CodeGen.h"
30#include "llvm/Support/ErrorHandling.h"
31#include "llvm/Support/VersionTuple.h"
32#include "llvm/Support/raw_ostream.h"
38class AttributeCommonInfo;
46 unsigned AttrKind : 16;
51 LLVM_PREFERRED_TYPE(
bool)
53 LLVM_PREFERRED_TYPE(
bool)
55 LLVM_PREFERRED_TYPE(
bool)
59 LLVM_PREFERRED_TYPE(
bool)
61 LLVM_PREFERRED_TYPE(
bool)
64 void *operator new(
size_t bytes) noexcept {
65 llvm_unreachable(
"Attrs cannot be allocated with regular 'new'.");
67 void operator delete(
void *data)
noexcept {
68 llvm_unreachable(
"Attrs cannot be released with regular 'delete'.");
74 size_t Alignment = 8)
noexcept {
75 return ::operator
new(Bytes,
C, Alignment);
77 void operator delete(
void *Ptr,
ASTContext &
C,
size_t Alignment)
noexcept {
78 return ::operator
delete(Ptr,
C, Alignment);
127 return A->
getKind() >= attr::FirstTypeAttr &&
128 A->
getKind() <= attr::LastTypeAttr;
140 return A->
getKind() >= attr::FirstStmtAttr &&
141 A->
getKind() <= attr::LastStmtAttr;
165 return A->
getKind() >= attr::FirstInheritableAttr &&
166 A->
getKind() <= attr::LastInheritableAttr;
180 return A->
getKind() >= attr::FirstDeclOrStmtAttr &&
181 A->
getKind() <= attr::LastDeclOrStmtAttr;
196 return A->
getKind() >= attr::FirstInheritableParamAttr &&
197 A->
getKind() <= attr::LastInheritableParamAttr;
213 return A->
getKind() >= attr::FirstInheritableParamOrStmtAttr &&
214 A->
getKind() <= attr::LastInheritableParamOrStmtAttr;
229 return A->
getKind() >= attr::FirstHLSLAnnotationAttr &&
230 A->
getKind() <= attr::LastHLSLAnnotationAttr;
248 return A->
getKind() >= attr::FirstParameterABIAttr &&
249 A->
getKind() <= attr::LastParameterABIAttr;
258 LLVM_PREFERRED_TYPE(
bool)
259 unsigned HasThis : 1;
260 LLVM_PREFERRED_TYPE(
bool)
261 unsigned IsValid : 1;
263 void assertComparable(
const ParamIdx &I)
const {
265 "ParamIdx must be valid to be compared");
270 assert(HasThis == I.HasThis &&
271 "ParamIdx must be for the same function to be compared");
286 : Idx(Idx), HasThis(
false), IsValid(
true) {
287 assert(Idx >= 1 &&
"Idx must be one-origin");
288 if (
const auto *FD = dyn_cast<FunctionDecl>(
D))
289 HasThis = FD->isCXXInstanceMember();
301 return *
reinterpret_cast<const SerialType *
>(
this);
308 void *ParamIdxPtr =
static_cast<void *
>(&S);
310 assert((!
P.IsValid ||
P.Idx >= 1) &&
"valid Idx must be one-origin");
324 assert(
isValid() &&
"ParamIdx must be valid");
335 assert(
isValid() &&
"ParamIdx must be valid");
336 assert(Idx >= 1 + HasThis &&
337 "stored index must be base-1 and not specify C++ implicit this");
338 return Idx - 1 - HasThis;
346 assert(
isValid() &&
"ParamIdx must be valid");
347 assert(Idx >= 1 &&
"stored index must be base-1");
378 "ParamIdx does not fit its serialization type");
380#include "clang/AST/Attrs.inc"
390 case attr::SwiftContext:
392 case attr::SwiftAsyncContext:
394 case attr::SwiftErrorResult:
396 case attr::SwiftIndirectResult:
398 case attr::HLSLParamModifier: {
399 const auto *A = cast<HLSLParamModifierAttr>(
this);
407 llvm_unreachable(
"bad parameter ABI attribute kind");
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)
InheritableParamOrStmtAttr(ASTContext &Context, const AttributeCommonInfo &CommonInfo, attr::Kind AK, bool IsLateParsed, bool InheritEvenIfAlreadyPresent)
static bool classof(const Attr *A)
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...
@ Ordinary
This parameter uses ordinary ABI rules for its type.
@ 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.