13#ifndef LLVM_CLANG_AST_ATTR_H
14#define LLVM_CLANG_AST_ATTR_H
29#include "llvm/Frontend/HLSL/HLSLResource.h"
30#include "llvm/Support/CodeGen.h"
31#include "llvm/Support/ErrorHandling.h"
32#include "llvm/Support/VersionTuple.h"
33#include "llvm/Support/raw_ostream.h"
48 unsigned AttrKind : 16;
53 LLVM_PREFERRED_TYPE(
bool)
55 LLVM_PREFERRED_TYPE(
bool)
57 LLVM_PREFERRED_TYPE(
bool)
61 LLVM_PREFERRED_TYPE(
bool)
63 LLVM_PREFERRED_TYPE(
bool)
66 void *operator new(
size_t bytes) noexcept {
67 llvm_unreachable(
"Attrs cannot be allocated with regular 'new'.");
69 void operator delete(
void *data)
noexcept {
70 llvm_unreachable(
"Attrs cannot be released with regular 'delete'.");
76 size_t Alignment = 8)
noexcept {
77 return ::operator
new(Bytes,
C, Alignment);
79 void operator delete(
void *Ptr,
ASTContext &
C,
size_t Alignment)
noexcept {
80 return ::operator
delete(Ptr,
C, Alignment);
129 return A->
getKind() >= attr::FirstTypeAttr &&
130 A->
getKind() <= attr::LastTypeAttr;
142 return A->
getKind() >= attr::FirstStmtAttr &&
143 A->
getKind() <= attr::LastStmtAttr;
167 return A->
getKind() >= attr::FirstInheritableAttr &&
168 A->
getKind() <= attr::LastInheritableAttr;
182 return A->
getKind() >= attr::FirstDeclOrStmtAttr &&
183 A->
getKind() <= attr::LastDeclOrStmtAttr;
198 return A->
getKind() >= attr::FirstInheritableParamAttr &&
199 A->
getKind() <= attr::LastInheritableParamAttr;
215 return A->
getKind() >= attr::FirstInheritableParamOrStmtAttr &&
216 A->
getKind() <= attr::LastInheritableParamOrStmtAttr;
231 return A->
getKind() >= attr::FirstHLSLAnnotationAttr &&
232 A->
getKind() <= attr::LastHLSLAnnotationAttr;
237 unsigned SemanticIndex = 0;
238 LLVM_PREFERRED_TYPE(
bool)
239 unsigned SemanticIndexable : 1;
240 LLVM_PREFERRED_TYPE(
bool)
241 unsigned SemanticExplicitIndex : 1;
243 Decl *TargetDecl =
nullptr;
251 this->SemanticIndexable = SemanticIndexable;
252 this->SemanticExplicitIndex =
false;
259 this->SemanticIndex = SemanticIndex;
260 this->SemanticExplicitIndex =
true;
272 return A->
getKind() >= attr::FirstHLSLSemanticAttr &&
273 A->
getKind() <= attr::LastHLSLSemanticAttr;
291 return A->
getKind() >= attr::FirstParameterABIAttr &&
292 A->
getKind() <= attr::LastParameterABIAttr;
301 LLVM_PREFERRED_TYPE(
bool)
302 unsigned HasThis : 1;
303 LLVM_PREFERRED_TYPE(
bool)
304 unsigned IsValid : 1;
306 void assertComparable(
const ParamIdx &I)
const {
308 "ParamIdx must be valid to be compared");
313 assert(HasThis == I.HasThis &&
314 "ParamIdx must be for the same function to be compared");
329 : Idx(Idx), HasThis(
false), IsValid(
true) {
330 assert(Idx >= 1 &&
"Idx must be one-origin");
331 if (
const auto *MethodDecl = dyn_cast<CXXMethodDecl>(D))
332 HasThis = MethodDecl->isImplicitObjectMemberFunction();
344 return *
reinterpret_cast<const SerialType *
>(
this);
351 void *ParamIdxPtr =
static_cast<void *
>(&S);
353 assert((!P.IsValid || P.Idx >= 1) &&
"valid Idx must be one-origin");
367 assert(
isValid() &&
"ParamIdx must be valid");
378 assert(
isValid() &&
"ParamIdx must be valid");
379 assert(Idx >= 1 + HasThis &&
380 "stored index must be base-1 and not specify C++ implicit this");
381 return Idx - 1 - HasThis;
389 assert(
isValid() &&
"ParamIdx must be valid");
390 assert(Idx >= 1 &&
"stored index must be base-1");
421 "ParamIdx does not fit its serialization type");
423#include "clang/AST/Attrs.inc"
433 case attr::SwiftContext:
435 case attr::SwiftAsyncContext:
437 case attr::SwiftErrorResult:
439 case attr::SwiftIndirectResult:
441 case attr::HLSLParamModifier: {
450 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.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
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
AttributeCommonInfo(const IdentifierInfo *AttrName, AttributeScopeInfo AttrScope, SourceRange AttrRange, Kind AttrKind, Form FormUsed)
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.
Represents a function declaration or definition.
HLSLAnnotationAttr(ASTContext &Context, const AttributeCommonInfo &CommonInfo, attr::Kind AK, bool IsLateParsed, bool InheritEvenIfAlreadyPresent)
static bool classof(const Attr *A)
bool isSemanticIndexable() const
Decl * getTargetDecl() const
void setSemanticIndex(unsigned SemanticIndex)
HLSLSemanticAttr(ASTContext &Context, const AttributeCommonInfo &CommonInfo, attr::Kind AK, bool IsLateParsed, bool InheritEvenIfAlreadyPresent, bool SemanticIndexable)
bool isSemanticIndexExplicit() const
unsigned getSemanticIndex() const
static bool classof(const Attr *A)
void setTargetDecl(Decl *D)
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)
Helper data structure representing the traits in a match clause of an declare variant or metadirectiv...
This is the base type for all OpenACC Clauses.
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
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.
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.
const StreamingDiagnostic & operator<<(const StreamingDiagnostic &DB, const ConceptReference *C)
Insertion operator for diagnostics.
U cast(CodeGen::Address addr)
Describes how types, statements, expressions, and declarations should be printed.