From 64ee6457444e03cc1749a0b4706be6c0d950a576 Mon Sep 17 00:00:00 2001 From: Vassil Vassilev Date: Sat, 7 Nov 2020 09:14:51 +0000 Subject: [PATCH 1/3] Revert "Add ASTConsumer::HandleInvalidTagDeclDefinition." This reverts commit c6ed96918f93d19353036bd5940acd3838ec784f. --- .../llvm/src/tools/clang/include/clang/AST/ASTConsumer.h | 6 ------ .../src/tools/clang/lib/Sema/SemaTemplateInstantiate.cpp | 4 +--- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/interpreter/llvm/src/tools/clang/include/clang/AST/ASTConsumer.h b/interpreter/llvm/src/tools/clang/include/clang/AST/ASTConsumer.h index c2beceb7f8db0..dc216a89c205f 100644 --- a/interpreter/llvm/src/tools/clang/include/clang/AST/ASTConsumer.h +++ b/interpreter/llvm/src/tools/clang/include/clang/AST/ASTConsumer.h @@ -71,12 +71,6 @@ class ASTConsumer { /// can be defined in declspecs). virtual void HandleTagDeclDefinition(TagDecl *D) {} - /// HandleInvalidTagDeclDefinition - This callback is invoked each time a TagDecl - /// (e.g. struct, union, enum, class) end up invalid after attempting completion. - /// This allows the client to record (and possibly remove from the AST) the - /// decl. - virtual void HandleInvalidTagDeclDefinition(TagDecl *D) {} - /// This callback is invoked the first time each TagDecl is required to /// be complete. virtual void HandleTagDeclRequiredDefinition(const TagDecl *D) {} diff --git a/interpreter/llvm/src/tools/clang/lib/Sema/SemaTemplateInstantiate.cpp b/interpreter/llvm/src/tools/clang/lib/Sema/SemaTemplateInstantiate.cpp index 5a7548bdb6321..284e8f4bc6c7e 100644 --- a/interpreter/llvm/src/tools/clang/lib/Sema/SemaTemplateInstantiate.cpp +++ b/interpreter/llvm/src/tools/clang/lib/Sema/SemaTemplateInstantiate.cpp @@ -2235,9 +2235,7 @@ Sema::InstantiateClass(SourceLocation PointOfInstantiation, // Exit the scope of this instantiation. SavedContext.pop(); - if (Instantiation->isInvalidDecl()) { - Consumer.HandleInvalidTagDeclDefinition(Instantiation); - } else { + if (!Instantiation->isInvalidDecl()) { Consumer.HandleTagDeclDefinition(Instantiation); // Always emit the vtable for an explicit instantiation definition From 0bf989ec3b2e17f13494b8dbaf50bf0a9b72df29 Mon Sep 17 00:00:00 2001 From: Vassil Vassilev Date: Sat, 7 Nov 2020 09:31:35 +0000 Subject: [PATCH 2/3] Revert "[llvm] Fix InvalidTagDeclDefinition in Multiplexer" This reverts commit 8c8a6dbfbd442de20f9c262d12d2114f27dbaa56. --- .../tools/clang/include/clang/Frontend/MultiplexConsumer.h | 1 - .../llvm/src/tools/clang/lib/Frontend/MultiplexConsumer.cpp | 5 ----- 2 files changed, 6 deletions(-) diff --git a/interpreter/llvm/src/tools/clang/include/clang/Frontend/MultiplexConsumer.h b/interpreter/llvm/src/tools/clang/include/clang/Frontend/MultiplexConsumer.h index f8b9190a1122e..ca6ed8310ae9e 100644 --- a/interpreter/llvm/src/tools/clang/include/clang/Frontend/MultiplexConsumer.h +++ b/interpreter/llvm/src/tools/clang/include/clang/Frontend/MultiplexConsumer.h @@ -64,7 +64,6 @@ class MultiplexConsumer : public SemaConsumer { void HandleCXXImplicitFunctionInstantiation(FunctionDecl *D) override; void HandleTopLevelDeclInObjCContainer(DeclGroupRef D) override; void HandleImplicitImportDecl(ImportDecl *D) override; - void HandleInvalidTagDeclDefinition(TagDecl *D) override; void CompleteTentativeDefinition(VarDecl *D) override; void AssignInheritanceModel(CXXRecordDecl *RD) override; void HandleVTable(CXXRecordDecl *RD) override; diff --git a/interpreter/llvm/src/tools/clang/lib/Frontend/MultiplexConsumer.cpp b/interpreter/llvm/src/tools/clang/lib/Frontend/MultiplexConsumer.cpp index e555358ed535c..ed7028769d349 100644 --- a/interpreter/llvm/src/tools/clang/lib/Frontend/MultiplexConsumer.cpp +++ b/interpreter/llvm/src/tools/clang/lib/Frontend/MultiplexConsumer.cpp @@ -317,11 +317,6 @@ void MultiplexConsumer::HandleImplicitImportDecl(ImportDecl *D) { Consumer->HandleImplicitImportDecl(D); } -void MultiplexConsumer::HandleInvalidTagDeclDefinition(TagDecl *D) { - for (auto &Consumer : Consumers) - Consumer->HandleInvalidTagDeclDefinition(D); -} - void MultiplexConsumer::CompleteTentativeDefinition(VarDecl *D) { for (auto &Consumer : Consumers) Consumer->CompleteTentativeDefinition(D); From 8705f586e51b21645b3ec38343993c99676c1578 Mon Sep 17 00:00:00 2001 From: Vassil Vassilev Date: Sat, 7 Nov 2020 09:35:19 +0000 Subject: [PATCH 3/3] Reimplement HandleInvalidTagDeclDefinition without clang support. See https://reviews.llvm.org/D92248 --- .../cling/lib/Interpreter/DeclCollector.cpp | 16 ++++----------- .../cling/lib/Interpreter/DeclCollector.h | 1 - .../lib/Sema/SemaTemplateInstantiate.cpp | 20 +++++++------------ 3 files changed, 11 insertions(+), 26 deletions(-) diff --git a/interpreter/cling/lib/Interpreter/DeclCollector.cpp b/interpreter/cling/lib/Interpreter/DeclCollector.cpp index 2949aa96a53ab..8cf0f0c7861f3 100644 --- a/interpreter/cling/lib/Interpreter/DeclCollector.cpp +++ b/interpreter/cling/lib/Interpreter/DeclCollector.cpp @@ -263,24 +263,16 @@ namespace cling { Transaction::DelayCallInfo DCI(DeclGroupRef(TD), Transaction::kCCIHandleTagDeclDefinition); m_CurTransaction->append(DCI); + if (TD->isInvalidDecl()) { + m_CurTransaction->setIssuedDiags(Transaction::kErrors); + return; + } if (m_Consumer && (!comesFromASTReader(DeclGroupRef(TD)) || !shouldIgnore(TD))) m_Consumer->HandleTagDeclDefinition(TD); } - void DeclCollector::HandleInvalidTagDeclDefinition(clang::TagDecl *TD){ - assertHasTransaction(m_CurTransaction); - Transaction::DelayCallInfo DCI(DeclGroupRef(TD), - Transaction::kCCIHandleTagDeclDefinition); - m_CurTransaction->append(DCI); - m_CurTransaction->setIssuedDiags(Transaction::kErrors); - if (m_Consumer - && (!comesFromASTReader(DeclGroupRef(TD)) - || !shouldIgnore(TD))) - m_Consumer->HandleInvalidTagDeclDefinition(TD); - } - void DeclCollector::HandleVTable(CXXRecordDecl* RD) { assertHasTransaction(m_CurTransaction); Transaction::DelayCallInfo DCI(DeclGroupRef(RD), diff --git a/interpreter/cling/lib/Interpreter/DeclCollector.h b/interpreter/cling/lib/Interpreter/DeclCollector.h index 28f3cb81a86b8..eac66bcf2f111 100644 --- a/interpreter/cling/lib/Interpreter/DeclCollector.h +++ b/interpreter/cling/lib/Interpreter/DeclCollector.h @@ -96,7 +96,6 @@ namespace cling { bool HandleTopLevelDecl(clang::DeclGroupRef DGR) final; void HandleInterestingDecl(clang::DeclGroupRef DGR) final; void HandleTagDeclDefinition(clang::TagDecl* TD) final; - void HandleInvalidTagDeclDefinition(clang::TagDecl* TD) final; void HandleVTable(clang::CXXRecordDecl* RD) final; void CompleteTentativeDefinition(clang::VarDecl* VD) final; void HandleTranslationUnit(clang::ASTContext& Ctx) final; diff --git a/interpreter/llvm/src/tools/clang/lib/Sema/SemaTemplateInstantiate.cpp b/interpreter/llvm/src/tools/clang/lib/Sema/SemaTemplateInstantiate.cpp index 284e8f4bc6c7e..3c76a05bcae93 100644 --- a/interpreter/llvm/src/tools/clang/lib/Sema/SemaTemplateInstantiate.cpp +++ b/interpreter/llvm/src/tools/clang/lib/Sema/SemaTemplateInstantiate.cpp @@ -2235,19 +2235,13 @@ Sema::InstantiateClass(SourceLocation PointOfInstantiation, // Exit the scope of this instantiation. SavedContext.pop(); - if (!Instantiation->isInvalidDecl()) { - Consumer.HandleTagDeclDefinition(Instantiation); - - // 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); - } + Consumer.HandleTagDeclDefinition(Instantiation); + + // 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); return Instantiation->isInvalidDecl(); }