Skip to content

Commit 7ebfc82

Browse files
committed
[HLSL][NFC] Refactoring HLSLExternalSemaSource
Moving builder classes into separate files `HLSLBuiltinTypeDeclBuilder.cpp`/`.h` and changing a some `HLSLExternalSemaSource` methods to private. This is a prep work before we start adding more builtin types and methods, like textures or resource constructors. For example constructors could make use of the `BuiltinTypeMethodBuilder`, but this helper class was defined in `HLSLExternalSemaSource.cpp` after the method that creates a constructor. Rather than reshuffling the code one big source file I am moving the builders into a separate cpp & header file and placing the helper classes declarations up top. Currently the new header only exposes `BuiltinTypeDeclBuilder` to `HLSLExternalSemaSource`. In the future but we might decide to expose more helper classes as needed.
1 parent 1a626e6 commit 7ebfc82

File tree

5 files changed

+890
-755
lines changed

5 files changed

+890
-755
lines changed

clang/include/clang/Sema/HLSLExternalSemaSource.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,15 @@ class NamespaceDecl;
2121
class Sema;
2222

2323
class HLSLExternalSemaSource : public ExternalSemaSource {
24+
private:
2425
Sema *SemaPtr = nullptr;
2526
NamespaceDecl *HLSLNamespace = nullptr;
2627

2728
using CompletionFunction = std::function<void(CXXRecordDecl *)>;
2829
llvm::DenseMap<CXXRecordDecl *, CompletionFunction> Completions;
2930

30-
void defineHLSLVectorAlias();
31-
void defineTrivialHLSLTypes();
32-
void defineHLSLTypesWithForwardDeclarations();
33-
34-
void onCompletion(CXXRecordDecl *Record, CompletionFunction Fn);
35-
3631
public:
37-
~HLSLExternalSemaSource() override;
32+
~HLSLExternalSemaSource() override {}
3833

3934
/// Initialize the semantic source with the Sema instance
4035
/// being used to perform semantic analysis on the abstract syntax
@@ -47,6 +42,12 @@ class HLSLExternalSemaSource : public ExternalSemaSource {
4742
using ExternalASTSource::CompleteType;
4843
/// Complete an incomplete HLSL builtin type
4944
void CompleteType(TagDecl *Tag) override;
45+
46+
private:
47+
void defineTrivialHLSLTypes();
48+
void defineHLSLVectorAlias();
49+
void defineHLSLTypesWithForwardDeclarations();
50+
void onCompletion(CXXRecordDecl *Record, CompletionFunction Fn);
5051
};
5152

5253
} // namespace clang

clang/lib/Sema/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ add_clang_library(clangSema
2020
DeclSpec.cpp
2121
DelayedDiagnostic.cpp
2222
HeuristicResolver.cpp
23+
HLSLBuiltinTypeDeclBuilder.cpp
2324
HLSLExternalSemaSource.cpp
2425
IdentifierResolver.cpp
2526
JumpDiagnostics.cpp

0 commit comments

Comments
 (0)