clang 22.0.0git
HLSLBuiltinTypeDeclBuilder.h
Go to the documentation of this file.
1//===--- HLSLBuiltinTypeDeclBuilder.h - HLSL Builtin Type Decl Builder ---===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// Helper classes for creating HLSL builtin class types. Used by external HLSL
10// sema source.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_CLANG_SEMA_HLSLBUILTINTYPEDECLBUILDER_H
15#define LLVM_CLANG_SEMA_HLSLBUILTINTYPEDECLBUILDER_H
16
17#include "clang/AST/Type.h"
18#include "clang/Sema/Sema.h"
19#include "llvm/ADT/StringMap.h"
20
21using llvm::hlsl::ResourceClass;
22
23namespace clang {
24
26class NamespaceDecl;
27class CXXRecordDecl;
28class FieldDecl;
29
30namespace hlsl {
31
32// Builder for builtin HLSL class types such as HLSL resource classes.
33// Allows creating declaration of builtin types using the builder pattern
34// like this:
35//
36// Decl = BuiltinTypeDeclBuilder(Sema, Namespace, "BuiltinClassName")
37// .addSimpleTemplateParams({"T"}, Concept)
38// .finalizeForwardDeclaration();
39//
40// And then completing the type like this:
41//
42// BuiltinTypeDeclBuilder(Sema, Decl)
43// .addDefaultHandleConstructor();
44// .addLoadMethods()
45// .completeDefinition();
46//
48private:
49 Sema &SemaRef;
50 CXXRecordDecl *Record = nullptr;
51 ClassTemplateDecl *Template = nullptr;
52 ClassTemplateDecl *PrevTemplate = nullptr;
53 NamespaceDecl *HLSLNamespace = nullptr;
54 llvm::StringMap<FieldDecl *> Fields;
55
56public:
59
61 BuiltinTypeDeclBuilder(Sema &SemaRef, NamespaceDecl *Namespace,
62 StringRef Name);
64
66 ConceptDecl *CD);
69
73
75 addBufferHandles(ResourceClass RC, bool IsROV, bool RawBuffer,
76 bool HasCounter,
79
80 // Builtin types constructors
84
85 // Static create methods
87
88 // Builtin types methods
93 bool IsConst, bool IsRef);
96
98
99private:
100 BuiltinTypeDeclBuilder &addCreateFromBinding();
101 BuiltinTypeDeclBuilder &addCreateFromImplicitBinding();
102 BuiltinTypeDeclBuilder &addCreateFromBindingWithImplicitCounter();
103 BuiltinTypeDeclBuilder &addCreateFromImplicitBindingWithImplicitCounter();
104 BuiltinTypeDeclBuilder &addResourceMember(StringRef MemberName,
105 ResourceClass RC, bool IsROV,
106 bool RawBuffer, bool IsCounter,
107 AccessSpecifier Access);
109 addHandleMember(ResourceClass RC, bool IsROV, bool RawBuffer,
112 addCounterHandleMember(ResourceClass RC, bool IsROV, bool RawBuffer,
114 FieldDecl *getResourceHandleField() const;
115 FieldDecl *getResourceCounterHandleField() const;
116 QualType getFirstTemplateTypeParam();
117 QualType getHandleElementType();
118 Expr *getConstantIntExpr(int value);
119 HLSLAttributedResourceType::Attributes getResourceAttrs() const;
120};
121
122} // namespace hlsl
123
124} // namespace clang
125
126#endif // LLVM_CLANG_SEMA_HLSLBUILTINTYPEDECLBUILDER_H
llvm::dxil::ResourceClass ResourceClass
C Language Family Type Representation.
BuiltinTypeDeclBuilder(Sema &SemaRef, CXXRecordDecl *R)
Represents a C++ struct/union/class.
Definition DeclCXX.h:258
Declaration of a class template.
Declaration of a C++20 concept.
The name of a declaration.
This represents one expression.
Definition Expr.h:112
Represents a member of a struct/union/class.
Definition Decl.h:3160
Represent a C++ namespace.
Definition Decl.h:592
A (possibly-)qualified type.
Definition TypeBase.h:937
Sema - This implements semantic analysis and AST building for C.
Definition Sema.h:854
The base class of the type hierarchy.
Definition TypeBase.h:1833
BuiltinTypeDeclBuilder(Sema &SemaRef, CXXRecordDecl *R)
BuiltinTypeDeclBuilder & addSimpleTemplateParams(ArrayRef< StringRef > Names, ConceptDecl *CD)
BuiltinTypeDeclBuilder & addMemberVariable(StringRef Name, QualType Type, llvm::ArrayRef< Attr * > Attrs, AccessSpecifier Access=AccessSpecifier::AS_private)
BuiltinTypeDeclBuilder & addHandleAccessFunction(DeclarationName &Name, bool IsConst, bool IsRef)
BuiltinTypeDeclBuilder & addGetDimensionsMethodForBuffer()
BuiltinTypeDeclBuilder & addBufferHandles(ResourceClass RC, bool IsROV, bool RawBuffer, bool HasCounter, AccessSpecifier Access=AccessSpecifier::AS_private)
BuiltinTypeDeclBuilder & addStaticInitializationFunctions(bool HasCounter)
The JSON file list parser is used to communicate input to InstallAPI.
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
Definition Specifiers.h:123
@ AS_private
Definition Specifiers.h:126