@@ -850,12 +850,10 @@ GetOrCreateTemplateSpecialization(ASTContext &context, Sema &sema,
850
850
if (specializationDecl->getInstantiatedFrom().isNull()) {
851
851
// InstantiateClassTemplateSpecialization returns true if it finds an
852
852
// error.
853
- bool errorFound = sema.InstantiateClassTemplateSpecialization(
854
- NoLoc, specializationDecl,
855
- TemplateSpecializationKind::TSK_ImplicitInstantiation, true);
856
- // Template specialization is suppressed if a fatal error has already been
857
- // registered so don't assert in such cases.
858
- DXVERIFY_NOMSG(sema.Diags.hasFatalErrorOccurred() || !errorFound);
853
+ if (sema.InstantiateClassTemplateSpecialization(
854
+ NoLoc, specializationDecl,
855
+ TemplateSpecializationKind::TSK_ImplicitInstantiation, true))
856
+ return QualType();
859
857
}
860
858
return context.getTemplateSpecializationType(
861
859
TemplateName(templateDecl), templateArgs.data(), templateArgs.size(),
@@ -866,19 +864,20 @@ GetOrCreateTemplateSpecialization(ASTContext &context, Sema &sema,
866
864
context, TagDecl::TagKind::TTK_Class, currentDeclContext, NoLoc, NoLoc,
867
865
templateDecl, templateArgsForDecl.data(), templateArgsForDecl.size(),
868
866
nullptr);
869
- // InstantiateClassTemplateSpecialization returns true if it finds an error.
870
- bool errorFound = sema.InstantiateClassTemplateSpecialization(
871
- NoLoc, specializationDecl,
872
- TemplateSpecializationKind::TSK_ImplicitInstantiation, true);
873
- // Template specialization is suppressed if a fatal error has already been
874
- // registered so don't assert in such cases.
875
- DXVERIFY_NOMSG(sema.Diags.hasFatalErrorOccurred() || !errorFound);
867
+ // template specialization isn't performed if a fatal error has occurred
868
+ if (!sema.Diags.hasFatalErrorOccurred()) {
869
+ // InstantiateClassTemplateSpecialization returns true if it finds an error.
870
+ [[maybe_unused]] bool errorFound =
871
+ sema.InstantiateClassTemplateSpecialization(
872
+ NoLoc, specializationDecl,
873
+ TemplateSpecializationKind::TSK_ImplicitInstantiation, true);
874
+ assert(!errorFound && "template specialization failed");
875
+ }
876
876
templateDecl->AddSpecialization(specializationDecl, InsertPos);
877
877
specializationDecl->setImplicit(true);
878
-
879
878
QualType canonType = context.getTypeDeclType(specializationDecl);
880
- DXASSERT (isa<RecordType>(canonType),
881
- "type of non-dependent specialization is not a RecordType");
879
+ assert (isa<RecordType>(canonType) &&
880
+ "type of non-dependent specialization is not a RecordType");
882
881
TemplateArgumentListInfo templateArgumentList(NoLoc, NoLoc);
883
882
TemplateArgumentLocInfo NoTemplateArgumentLocInfo;
884
883
for (unsigned i = 0; i < templateArgs.size(); i++) {
@@ -913,18 +912,17 @@ static QualType GetOrCreateMatrixSpecialization(
913
912
context, *sema, matrixTemplateDecl,
914
913
ArrayRef<TemplateArgument>(templateArgs));
915
914
916
- #ifndef NDEBUG
917
- // Verify that we can read the field member from the template record.
918
- DXASSERT (matrixSpecializationType->getAsCXXRecordDecl(),
915
+ if (!matrixSpecializationType.isNull() &&
916
+ !sema->Diags.hasFatalErrorOccurred()) {
917
+ assert (matrixSpecializationType->getAsCXXRecordDecl() &&
919
918
"type of non-dependent specialization is not a RecordType");
920
- DeclContext::lookup_result lookupResult =
921
- matrixSpecializationType->getAsCXXRecordDecl()->lookup(
922
- DeclarationName(&context.Idents.get(StringRef("h"))));
923
- // Template specialization is suppressed if a fatal error has been registered
924
- // so only assert if lookup failed for some other reason.
925
- DXASSERT(sema->Diags.hasFatalErrorOccurred() || !lookupResult.empty(),
919
+ // Verify that we can read the field member from the template record.
920
+ [[maybe_unused]] DeclContext::lookup_result lookupResult =
921
+ matrixSpecializationType->getAsCXXRecordDecl()->lookup(
922
+ DeclarationName(&context.Idents.get(StringRef("h"))));
923
+ assert(!lookupResult.empty() &&
926
924
"otherwise matrix handle cannot be looked up");
927
- #endif
925
+ }
928
926
929
927
return matrixSpecializationType;
930
928
}
@@ -950,18 +948,17 @@ GetOrCreateVectorSpecialization(ASTContext &context, Sema *sema,
950
948
context, *sema, vectorTemplateDecl,
951
949
ArrayRef<TemplateArgument>(templateArgs));
952
950
953
- #ifndef NDEBUG
954
- // Verify that we can read the field member from the template record.
955
- DXASSERT (vectorSpecializationType->getAsCXXRecordDecl(),
951
+ if (!vectorSpecializationType.isNull() &&
952
+ !sema->Diags.hasFatalErrorOccurred()) {
953
+ assert (vectorSpecializationType->getAsCXXRecordDecl() &&
956
954
"type of non-dependent specialization is not a RecordType");
957
- DeclContext::lookup_result lookupResult =
958
- vectorSpecializationType->getAsCXXRecordDecl()->lookup(
959
- DeclarationName(&context.Idents.get(StringRef("h"))));
960
- // Template specialization is suppressed if a fatal error has been registered
961
- // so only assert if lookup failed for some other reason.
962
- DXASSERT(sema->Diags.hasFatalErrorOccurred() || !lookupResult.empty(),
955
+ // Verify that we can read the field member from the template record.
956
+ [[maybe_unused]] DeclContext::lookup_result lookupResult =
957
+ vectorSpecializationType->getAsCXXRecordDecl()->lookup(
958
+ DeclarationName(&context.Idents.get(StringRef("h"))));
959
+ assert(!lookupResult.empty() &&
963
960
"otherwise vector handle cannot be looked up");
964
- #endif
961
+ }
965
962
966
963
return vectorSpecializationType;
967
964
}
@@ -980,18 +977,16 @@ GetOrCreateNodeOutputRecordSpecialization(ASTContext &context, Sema *sema,
980
977
QualType specializationType = GetOrCreateTemplateSpecialization(
981
978
context, *sema, templateDecl, ArrayRef<TemplateArgument>(templateArgs));
982
979
983
- #ifdef DBG
984
- // Verify that we can read the field member from the template record.
985
- DXASSERT(specializationType->getAsCXXRecordDecl(),
980
+ if (!specializationType.isNull() && !sema->Diags.hasFatalErrorOccurred()) {
981
+ assert(specializationType->getAsCXXRecordDecl() &&
986
982
"type of non-dependent specialization is not a RecordType");
987
- DeclContext::lookup_result lookupResult =
988
- specializationType->getAsCXXRecordDecl()->lookup(
989
- DeclarationName(&context.Idents.get(StringRef("h"))));
990
- // Template specialization is suppressed if a fatal error has been registered
991
- // so only assert if lookup failed for some other reason.
992
- DXASSERT(sema->Diags.hasFatalErrorOccurred() || !lookupResult.empty(),
983
+ // Verify that we can read the field member from the template record.
984
+ [[maybe_unused]] DeclContext::lookup_result lookupResult =
985
+ specializationType->getAsCXXRecordDecl()->lookup(
986
+ DeclarationName(&context.Idents.get(StringRef("h"))));
987
+ assert(!lookupResult.empty() &&
993
988
"otherwise *NodeOutputRecords handle cannot be looked up");
994
- #endif
989
+ }
995
990
996
991
return specializationType;
997
992
}
0 commit comments