From 3a1d4f9be904a948fc77d3edb91f9d29d8f69fcb Mon Sep 17 00:00:00 2001 From: Vassil Vassilev Date: Mon, 10 May 2021 14:24:33 +0000 Subject: [PATCH] Add the missing code path in addition to root-project/root@f7ae62fc71 --- .../clang/lib/Sema/SemaTemplateInstantiate.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/interpreter/llvm/src/tools/clang/lib/Sema/SemaTemplateInstantiate.cpp b/interpreter/llvm/src/tools/clang/lib/Sema/SemaTemplateInstantiate.cpp index 3c76a05bcae93..8d48fe5789ee3 100644 --- a/interpreter/llvm/src/tools/clang/lib/Sema/SemaTemplateInstantiate.cpp +++ b/interpreter/llvm/src/tools/clang/lib/Sema/SemaTemplateInstantiate.cpp @@ -2235,13 +2235,19 @@ Sema::InstantiateClass(SourceLocation PointOfInstantiation, // Exit the scope of this instantiation. SavedContext.pop(); - Consumer.HandleTagDeclDefinition(Instantiation); + if (!Instantiation->isInvalidDecl()) { + // Always emit the vtable for an explicit instantiation definition + // of a polymorphic class template specialization. Otherwise, eagerly + // instantiate only constexpr virtual functions in preparation for their use + // in constant evaluation. + if (TSK == TSK_ExplicitInstantiationDefinition) + MarkVTableUsed(PointOfInstantiation, Instantiation, true); + else if (MightHaveConstexprVirtualFunctions) + MarkVirtualMembersReferenced(PointOfInstantiation, Instantiation, + /*ConstexprOnly*/ true); + } - // Always emit the vtable for an explicit instantiation definition - // of a polymorphic class template specialization. - if (!Instantiation->isInvalidDecl() && - TSK == TSK_ExplicitInstantiationDefinition) - MarkVTableUsed(PointOfInstantiation, Instantiation, true); + Consumer.HandleTagDeclDefinition(Instantiation); return Instantiation->isInvalidDecl(); }