Skip to content

Commit 8cc2154

Browse files
committed
some analysis
1 parent d8385ec commit 8cc2154

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

tools/clang/lib/Sema/SemaHLSLDiagnoseTU.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,7 @@ 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();
593594

594595
llvm::SmallVector<VarDecl *, 16> GlobalsWithInit;
595596
GatherGlobalsWithInitializers(self->getASTContext().getTranslationUnitDecl(),
@@ -706,7 +707,6 @@ void hlsl::DiagnoseTranslationUnit(clang::Sema *self) {
706707
}
707708
}
708709

709-
DXIL::ShaderKind EntrySK = shaderModel->GetKind();
710710
DXIL::NodeLaunchType NodeLaunchTy = DXIL::NodeLaunchType::Invalid;
711711
if (EntrySK == DXIL::ShaderKind::Library) {
712712
// For library, check if the exported function is entry with shader
@@ -731,23 +731,25 @@ void hlsl::DiagnoseTranslationUnit(clang::Sema *self) {
731731
for (VarDecl *VD : InitGlobals)
732732
Visitor.TraverseDecl(VD);
733733
for (FunctionDecl *FD : callGraph.GetVisitedFunctions())
734-
Visitor.TraverseDecl(FD);
735-
734+
Visitor.TraverseDecl(FD);
735+
}
736+
737+
if (EntrySK == DXIL::ShaderKind::Library) {
736738
for (VarDecl *VD : GlobalsWithInit) {
737739
DXIL::NodeLaunchType NodeLaunchTy = DXIL::NodeLaunchType::Invalid;
738740
HLSLCallDiagnoseVisitor Visitor(self, shaderModel, EntrySK, NodeLaunchTy,
739-
VD, DiagnosedCalls,
741+
nullptr, DiagnosedCalls,
740742
DeclAvailabilityChecked);
741743
if (InitListExpr *ILE = dyn_cast<InitListExpr>(VD->getInit())) {
742744
if (auto RT = ILE->getType()->getAs<RecordType>()) {
743745
if (const RecordDecl *RD = RT->getDecl()) {
744-
if (RD->getName() == "RaytracingPipelineConfig1"){
746+
if (RD->getName() == "RaytracingPipelineConfig1") {
745747
Visitor.TraverseDecl(VD);
746748
}
747749
}
748750
}
749751
}
750752
break;
751-
}
753+
}
752754
}
753755
}

tools/clang/test/HLSLFileCheck/d3dreflect/rayquery-reflection.hlsl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
// ASTIMPL: VarDecl 0x{{.+}} <<invalid sloc>> <invalid sloc> implicit referenced RAYTRACING_PIPELINE_FLAG_ALLOW_OPACITY_MICROMAPS 'const unsigned int' static cinit
1717
// ASTIMPL-NEXT: IntegerLiteral 0x{{.+}} <<invalid sloc>> 'const unsigned int' 1024
1818
// ASTIMPL-NEXT: AvailabilityAttr 0x{{.+}} <<invalid sloc>> Implicit 6.9 0 0 ""
19+
1920
RaytracingPipelineConfig1 rpc = { 32, RAYTRACING_PIPELINE_FLAG_ALLOW_OPACITY_MICROMAPS };
2021

2122
// UNDER69: Potential misuse

0 commit comments

Comments
 (0)