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
25class ClassTemplateDecl;
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 addHandleMember(ResourceClass RC, bool IsROV, bool RawBuffer,
78
79 // Builtin types constructors
83
84 // Builtin types methods
89 bool IsConst, bool IsRef);
92
93private:
94 FieldDecl *getResourceHandleField() const;
95 QualType getFirstTemplateTypeParam();
96 QualType getHandleElementType();
97 Expr *getConstantIntExpr(int value);
98 HLSLAttributedResourceType::Attributes getResourceAttrs() const;
99};
100
101} // namespace hlsl
102
103} // namespace clang
104
105#endif // LLVM_CLANG_SEMA_HLSLBUILTINTYPEDECLBUILDER_H
llvm::dxil::ResourceClass ResourceClass
Definition: CGHLSLRuntime.h:50
llvm::MachO::Record Record
Definition: MachO.h:31
C Language Family Type Representation.
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:3157
Represent a C++ namespace.
Definition: Decl.h:591
A (possibly-)qualified type.
Definition: TypeBase.h:937
Sema - This implements semantic analysis and AST building for C.
Definition: Sema.h:850
The base class of the type hierarchy.
Definition: TypeBase.h:1833
BuiltinTypeDeclBuilder & addHandleConstructorFromImplicitBinding()
BuiltinTypeDeclBuilder & addSimpleTemplateParams(ArrayRef< StringRef > Names, ConceptDecl *CD)
BuiltinTypeDeclBuilder & addMemberVariable(StringRef Name, QualType Type, llvm::ArrayRef< Attr * > Attrs, AccessSpecifier Access=AccessSpecifier::AS_private)
BuiltinTypeDeclBuilder & addHandleConstructorFromBinding()
BuiltinTypeDeclBuilder & addHandleAccessFunction(DeclarationName &Name, bool IsConst, bool IsRef)
BuiltinTypeDeclBuilder & addArraySubscriptOperators()
BuiltinTypeDeclBuilder & addIncrementCounterMethod()
BuiltinTypeDeclBuilder & addHandleMember(ResourceClass RC, bool IsROV, bool RawBuffer, AccessSpecifier Access=AccessSpecifier::AS_private)
BuiltinTypeDeclBuilder & addDefaultHandleConstructor()
BuiltinTypeDeclBuilder & addDecrementCounterMethod()
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