Skip to content

Commit 9a82f74

Browse files
authored
[HLSL][NFC] Refactor HLSLExternalSemaSource (#131032)
Moving builder classes into separate files `HLSLBuiltinTypeDeclBuilder.cpp`/`.h`, changing a some `HLSLExternalSemaSource` methods to private and removing unused methods. This is a prep work before we start adding more builtin types and methods, like textures, resource constructors or matrices. 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 3df9219 commit 9a82f74

File tree

5 files changed

+894
-756
lines changed

5 files changed

+894
-756
lines changed

clang/include/clang/Sema/HLSLExternalSemaSource.h

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@
1212
#ifndef CLANG_SEMA_HLSLEXTERNALSEMASOURCE_H
1313
#define CLANG_SEMA_HLSLEXTERNALSEMASOURCE_H
1414

15-
#include "llvm/ADT/DenseMap.h"
16-
1715
#include "clang/Sema/ExternalSemaSource.h"
16+
#include "llvm/ADT/DenseMap.h"
1817

1918
namespace clang {
2019
class NamespaceDecl;
@@ -27,14 +26,8 @@ class HLSLExternalSemaSource : public ExternalSemaSource {
2726
using CompletionFunction = std::function<void(CXXRecordDecl *)>;
2827
llvm::DenseMap<CXXRecordDecl *, CompletionFunction> Completions;
2928

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

3932
/// Initialize the semantic source with the Sema instance
4033
/// being used to perform semantic analysis on the abstract syntax
@@ -47,6 +40,12 @@ class HLSLExternalSemaSource : public ExternalSemaSource {
4740
using ExternalASTSource::CompleteType;
4841
/// Complete an incomplete HLSL builtin type
4942
void CompleteType(TagDecl *Tag) override;
43+
44+
private:
45+
void defineTrivialHLSLTypes();
46+
void defineHLSLVectorAlias();
47+
void defineHLSLTypesWithForwardDeclarations();
48+
void onCompletion(CXXRecordDecl *Record, CompletionFunction Fn);
5049
};
5150

5251
} // 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)