Skip to content

Commit c68f33a

Browse files
committed
detect subobjects in globals
1 parent 1969f85 commit c68f33a

3 files changed

Lines changed: 14 additions & 13 deletions

File tree

tools/clang/lib/Sema/SemaHLSLDiagnoseTU.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,6 @@ void hlsl::DiagnoseTranslationUnit(clang::Sema *self) {
590590

591591
const auto *shaderModel =
592592
hlsl::ShaderModel::GetByName(self->getLangOpts().HLSLProfile.c_str());
593-
DXIL::ShaderKind EntrySK = shaderModel->GetKind();
594593

595594
llvm::SmallVector<VarDecl *, 16> GlobalsWithInit;
596595
GatherGlobalsWithInitializers(self->getASTContext().getTranslationUnitDecl(),
@@ -706,7 +705,7 @@ void hlsl::DiagnoseTranslationUnit(clang::Sema *self) {
706705
<< PatchConstantFunctionReturnIdx;
707706
}
708707
}
709-
708+
DXIL::ShaderKind EntrySK = shaderModel->GetKind();
710709
DXIL::NodeLaunchType NodeLaunchTy = DXIL::NodeLaunchType::Invalid;
711710
if (EntrySK == DXIL::ShaderKind::Library) {
712711
// For library, check if the exported function is entry with shader
@@ -734,12 +733,12 @@ void hlsl::DiagnoseTranslationUnit(clang::Sema *self) {
734733
Visitor.TraverseDecl(FD);
735734
}
736735

737-
if (EntrySK == DXIL::ShaderKind::Library) {
736+
if (shaderModel->GetKind() == DXIL::ShaderKind::Library) {
738737
for (VarDecl *VD : GlobalsWithInit) {
739738
DXIL::NodeLaunchType NodeLaunchTy = DXIL::NodeLaunchType::Invalid;
740739
HLSLReachableDiagnoseVisitor Visitor(
741-
self, shaderModel, EntrySK, NodeLaunchTy, nullptr, DiagnosedCalls,
742-
DeclAvailabilityChecked, DiagnosedTypeLocs);
740+
self, shaderModel, shaderModel->GetKind(), NodeLaunchTy, nullptr,
741+
DiagnosedCalls, DeclAvailabilityChecked, DiagnosedTypeLocs);
743742
QualType QT = VD->getType();
744743
if (const RecordType *RT = QT->getAs<RecordType>()) {
745744
RecordDecl *RD = RT->getDecl();
@@ -749,4 +748,4 @@ void hlsl::DiagnoseTranslationUnit(clang::Sema *self) {
749748
}
750749
}
751750
}
752-
}
751+
}

tools/clang/test/HLSLFileCheck/d3dreflect/rayquery-reflection.hlsl renamed to tools/clang/test/HLSLFileCheck/d3dreflect/raytracingpipelineconfig1.hlsl

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
// RUsN: %dxilver 1.9 | %dxc -T lib_6_9 %s | FileCheck %s
2-
// RUN: %dxilver 1.8 | %dxc -T lib_6_8 %s | FileCheck -check-prefix=UNDER69 %s
3-
// RUsN: %dxilver 1.9 | %dxc -T lib_6_9 -ast-dump %s | FileCheck -check-prefix=AST %s
4-
// RUsN: %dxilver 1.9 | %dxc -T lib_6_9 -ast-dump-implicit %s | FileCheck -check-prefix=ASTIMPL %s
1+
// RUN: %dxilver 1.9 | %dxc -T lib_6_9 %s | FileCheck %s
2+
// RUN: %dxilver 1.9 | %dxc -T lib_6_9 -ast-dump %s | FileCheck -check-prefix=AST %s
3+
// RUN: %dxilver 1.9 | %dxc -T lib_6_9 -ast-dump-implicit %s | FileCheck -check-prefix=ASTIMPL %s
54

65

76
// CHECK: ; RaytracingPipelineConfig1 rpc = { MaxTraceRecursionDepth = 32, Flags = RAYTRACING_PIPELINE_FLAG_ALLOW_OPACITY_MICROMAPS };
@@ -18,6 +17,3 @@
1817
// ASTIMPL-NEXT: AvailabilityAttr 0x{{.+}} <<invalid sloc>> Implicit 6.9 0 0 ""
1918

2019
RaytracingPipelineConfig1 rpc = { 32, RAYTRACING_PIPELINE_FLAG_ALLOW_OPACITY_MICROMAPS };
21-
22-
// UNDER69: Potential misuse
23-
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// RUN: %dxilver 1.8 | %dxc -T lib_6_8 -verify %s
2+
3+
// expected-warning@+1{{potential misuse of built-in constant 'RAYTRACING_PIPELINE_FLAG_ALLOW_OPACITY_MICROMAPS' in shader model lib_6_8; introduced in shader model 6.9}}
4+
RaytracingPipelineConfig1 rpc = { 32, RAYTRACING_PIPELINE_FLAG_ALLOW_OPACITY_MICROMAPS };
5+
6+

0 commit comments

Comments
 (0)