@@ -868,12 +868,10 @@ GetOrCreateTemplateSpecialization(ASTContext &context, Sema &sema,
868868 if (specializationDecl->getInstantiatedFrom().isNull()) {
869869 // InstantiateClassTemplateSpecialization returns true if it finds an
870870 // error.
871- bool errorFound = sema.InstantiateClassTemplateSpecialization(
872- NoLoc, specializationDecl,
873- TemplateSpecializationKind::TSK_ImplicitInstantiation, true);
874- // Template specialization is suppressed if a fatal error has already been
875- // registered so don't assert in such cases.
876- DXVERIFY_NOMSG(sema.Diags.hasFatalErrorOccurred() || !errorFound);
871+ if (sema.InstantiateClassTemplateSpecialization(
872+ NoLoc, specializationDecl,
873+ TemplateSpecializationKind::TSK_ImplicitInstantiation, true))
874+ return QualType();
877875 }
878876 return context.getTemplateSpecializationType(
879877 TemplateName(templateDecl), templateArgs.data(), templateArgs.size(),
@@ -884,19 +882,20 @@ GetOrCreateTemplateSpecialization(ASTContext &context, Sema &sema,
884882 context, TagDecl::TagKind::TTK_Class, currentDeclContext, NoLoc, NoLoc,
885883 templateDecl, templateArgsForDecl.data(), templateArgsForDecl.size(),
886884 nullptr);
887- // InstantiateClassTemplateSpecialization returns true if it finds an error.
888- bool errorFound = sema.InstantiateClassTemplateSpecialization(
889- NoLoc, specializationDecl,
890- TemplateSpecializationKind::TSK_ImplicitInstantiation, true);
891- // Template specialization is suppressed if a fatal error has already been
892- // registered so don't assert in such cases.
893- DXVERIFY_NOMSG(sema.Diags.hasFatalErrorOccurred() || !errorFound);
885+ // template specialization isn't performed if a fatal error has occurred
886+ if (!sema.Diags.hasFatalErrorOccurred()) {
887+ // InstantiateClassTemplateSpecialization returns true if it finds an error.
888+ [[maybe_unused]] bool errorFound =
889+ sema.InstantiateClassTemplateSpecialization(
890+ NoLoc, specializationDecl,
891+ TemplateSpecializationKind::TSK_ImplicitInstantiation, true);
892+ assert(!errorFound && "template specialization failed");
893+ }
894894 templateDecl->AddSpecialization(specializationDecl, InsertPos);
895895 specializationDecl->setImplicit(true);
896-
897896 QualType canonType = context.getTypeDeclType(specializationDecl);
898- DXASSERT (isa<RecordType>(canonType),
899- "type of non-dependent specialization is not a RecordType");
897+ assert (isa<RecordType>(canonType) &&
898+ "type of non-dependent specialization is not a RecordType");
900899 TemplateArgumentListInfo templateArgumentList(NoLoc, NoLoc);
901900 TemplateArgumentLocInfo NoTemplateArgumentLocInfo;
902901 for (unsigned i = 0; i < templateArgs.size(); i++) {
@@ -931,18 +930,17 @@ static QualType GetOrCreateMatrixSpecialization(
931930 context, *sema, matrixTemplateDecl,
932931 ArrayRef<TemplateArgument>(templateArgs));
933932
934- #ifndef NDEBUG
935- // Verify that we can read the field member from the template record.
936- DXASSERT (matrixSpecializationType->getAsCXXRecordDecl(),
933+ if (!matrixSpecializationType.isNull() &&
934+ !sema->Diags.hasFatalErrorOccurred()) {
935+ assert (matrixSpecializationType->getAsCXXRecordDecl() &&
937936 "type of non-dependent specialization is not a RecordType");
938- DeclContext::lookup_result lookupResult =
939- matrixSpecializationType->getAsCXXRecordDecl()->lookup(
940- DeclarationName(&context.Idents.get(StringRef("h"))));
941- // Template specialization is suppressed if a fatal error has been registered
942- // so only assert if lookup failed for some other reason.
943- DXASSERT(sema->Diags.hasFatalErrorOccurred() || !lookupResult.empty(),
937+ // Verify that we can read the field member from the template record.
938+ [[maybe_unused]] DeclContext::lookup_result lookupResult =
939+ matrixSpecializationType->getAsCXXRecordDecl()->lookup(
940+ DeclarationName(&context.Idents.get(StringRef("h"))));
941+ assert(!lookupResult.empty() &&
944942 "otherwise matrix handle cannot be looked up");
945- #endif
943+ }
946944
947945 return matrixSpecializationType;
948946}
@@ -968,18 +966,17 @@ GetOrCreateVectorSpecialization(ASTContext &context, Sema *sema,
968966 context, *sema, vectorTemplateDecl,
969967 ArrayRef<TemplateArgument>(templateArgs));
970968
971- #ifndef NDEBUG
972- // Verify that we can read the field member from the template record.
973- DXASSERT (vectorSpecializationType->getAsCXXRecordDecl(),
969+ if (!vectorSpecializationType.isNull() &&
970+ !sema->Diags.hasFatalErrorOccurred()) {
971+ assert (vectorSpecializationType->getAsCXXRecordDecl() &&
974972 "type of non-dependent specialization is not a RecordType");
975- DeclContext::lookup_result lookupResult =
976- vectorSpecializationType->getAsCXXRecordDecl()->lookup(
977- DeclarationName(&context.Idents.get(StringRef("h"))));
978- // Template specialization is suppressed if a fatal error has been registered
979- // so only assert if lookup failed for some other reason.
980- DXASSERT(sema->Diags.hasFatalErrorOccurred() || !lookupResult.empty(),
973+ // Verify that we can read the field member from the template record.
974+ [[maybe_unused]] DeclContext::lookup_result lookupResult =
975+ vectorSpecializationType->getAsCXXRecordDecl()->lookup(
976+ DeclarationName(&context.Idents.get(StringRef("h"))));
977+ assert(!lookupResult.empty() &&
981978 "otherwise vector handle cannot be looked up");
982- #endif
979+ }
983980
984981 return vectorSpecializationType;
985982}
@@ -998,18 +995,16 @@ GetOrCreateNodeOutputRecordSpecialization(ASTContext &context, Sema *sema,
998995 QualType specializationType = GetOrCreateTemplateSpecialization(
999996 context, *sema, templateDecl, ArrayRef<TemplateArgument>(templateArgs));
1000997
1001- #ifdef DBG
1002- // Verify that we can read the field member from the template record.
1003- DXASSERT(specializationType->getAsCXXRecordDecl(),
998+ if (!specializationType.isNull() && !sema->Diags.hasFatalErrorOccurred()) {
999+ assert(specializationType->getAsCXXRecordDecl() &&
10041000 "type of non-dependent specialization is not a RecordType");
1005- DeclContext::lookup_result lookupResult =
1006- specializationType->getAsCXXRecordDecl()->lookup(
1007- DeclarationName(&context.Idents.get(StringRef("h"))));
1008- // Template specialization is suppressed if a fatal error has been registered
1009- // so only assert if lookup failed for some other reason.
1010- DXASSERT(sema->Diags.hasFatalErrorOccurred() || !lookupResult.empty(),
1001+ // Verify that we can read the field member from the template record.
1002+ [[maybe_unused]] DeclContext::lookup_result lookupResult =
1003+ specializationType->getAsCXXRecordDecl()->lookup(
1004+ DeclarationName(&context.Idents.get(StringRef("h"))));
1005+ assert(!lookupResult.empty() &&
10111006 "otherwise *NodeOutputRecords handle cannot be looked up");
1012- #endif
1007+ }
10131008
10141009 return specializationType;
10151010}
0 commit comments