@@ -313,13 +313,13 @@ void GatherGlobalsWithInitializers(
313313 (VD->getStorageClass () == SC_Static ||
314314 VD->hasAttr <HLSLGroupSharedAttr>())) {
315315 // Place subobjects in a separate collection.
316- QualType QT = VD->getType ();
317- if (const RecordType *RT = QT->getAs <RecordType>()) {
318- RecordDecl *RD = RT->getDecl ();
319- if (RD->hasAttr <HLSLSubObjectAttr>())
316+ if (const RecordType *RT = VD->getType ()->getAs <RecordType>()) {
317+ if (RT->getDecl ()->hasAttr <HLSLSubObjectAttr>()) {
320318 SubObjects.push_back (VD);
321- } else
322- GlobalsWithInit.push_back (VD);
319+ continue ;
320+ }
321+ }
322+ GlobalsWithInit.push_back (VD);
323323 }
324324 } else if (auto *DC = dyn_cast<DeclContext>(D)) {
325325 // Recurse into DeclContexts like namespace, cbuffer, class/struct, etc.
@@ -611,11 +611,11 @@ void hlsl::DiagnoseTranslationUnit(clang::Sema *self) {
611611 GlobalsWithInit, SubObjects);
612612
613613 if (shaderModel->GetKind () == DXIL::ShaderKind::Library) {
614+ DXIL::NodeLaunchType NodeLaunchTy = DXIL::NodeLaunchType::Invalid;
615+ HLSLReachableDiagnoseVisitor Visitor (
616+ self, shaderModel, shaderModel->GetKind (), NodeLaunchTy, nullptr ,
617+ DiagnosedCalls, DeclAvailabilityChecked, DiagnosedTypeLocs);
614618 for (VarDecl *VD : SubObjects) {
615- DXIL::NodeLaunchType NodeLaunchTy = DXIL::NodeLaunchType::Invalid;
616- HLSLReachableDiagnoseVisitor Visitor (
617- self, shaderModel, shaderModel->GetKind (), NodeLaunchTy, nullptr ,
618- DiagnosedCalls, DeclAvailabilityChecked, DiagnosedTypeLocs);
619619 Visitor.TraverseDecl (VD);
620620 }
621621 }
0 commit comments