From 1e10357aaf3c25745754c56accd6cdc07239e105 Mon Sep 17 00:00:00 2001 From: Axel Naumann Date: Fri, 4 Nov 2016 10:14:56 +0100 Subject: [PATCH 1/2] Unloaded declarations are now put back into CodeGen; no need to mark them used. --- interpreter/cling/lib/Interpreter/CIFactory.cpp | 2 -- interpreter/cling/lib/Interpreter/DeclCollector.cpp | 12 +----------- interpreter/cling/lib/Interpreter/DeclCollector.h | 8 +------- 3 files changed, 2 insertions(+), 20 deletions(-) diff --git a/interpreter/cling/lib/Interpreter/CIFactory.cpp b/interpreter/cling/lib/Interpreter/CIFactory.cpp index f6186dc7c413d..7490b68ffb9c6 100644 --- a/interpreter/cling/lib/Interpreter/CIFactory.cpp +++ b/interpreter/cling/lib/Interpreter/CIFactory.cpp @@ -752,8 +752,6 @@ namespace { std::unique_ptr stateCollector(new cling::DeclCollector()); - // Set up the ASTConsumers - CI->getASTContext().setASTMutationListener(stateCollector.get()); // Add the callback keeping track of the macro definitions PP.addPPCallbacks(stateCollector->MakePPAdapter()); CI->setASTConsumer(std::move(stateCollector)); diff --git a/interpreter/cling/lib/Interpreter/DeclCollector.cpp b/interpreter/cling/lib/Interpreter/DeclCollector.cpp index 69ac526043ea0..93f1a01893404 100644 --- a/interpreter/cling/lib/Interpreter/DeclCollector.cpp +++ b/interpreter/cling/lib/Interpreter/DeclCollector.cpp @@ -73,17 +73,7 @@ namespace cling { // pin the vtable here. DeclCollector::~DeclCollector() { } - void DeclCollector::AddedCXXImplicitMember(const CXXRecordDecl *RD, - const Decl *D) { - assert(D->isImplicit()); - // We need to mark the decls coming from the modules - if (comesFromASTReader(RD) || comesFromASTReader(D)) { - Decl* implicitD = const_cast(D); - implicitD->addAttr(UsedAttr::CreateImplicit(implicitD->getASTContext())); - } - } - - ASTTransformer::Result DeclCollector::TransformDecl(Decl* D) const { + ASTTransformer::Result DeclCollector::TransformDecl(Decl* D) const { // We are sure it's safe to pipe it through the transformers // Consume late transformers init for (size_t i = 0; D && i < m_TransactionTransformers.size(); ++i) { diff --git a/interpreter/cling/lib/Interpreter/DeclCollector.h b/interpreter/cling/lib/Interpreter/DeclCollector.h index ace34757f9947..ac2afff462662 100644 --- a/interpreter/cling/lib/Interpreter/DeclCollector.h +++ b/interpreter/cling/lib/Interpreter/DeclCollector.h @@ -11,7 +11,6 @@ #define CLING_DECL_COLLECTOR_H #include "clang/AST/ASTConsumer.h" -#include "clang/AST/ASTMutationListener.h" #include "clang/Lex/PPCallbacks.h" #include "ASTTransformer.h" @@ -57,8 +56,7 @@ namespace cling { /// cling::DeclCollector is responsible for appending all the declarations /// seen by clang. /// - class DeclCollector: public clang::ASTMutationListener, - public clang::ASTConsumer { + class DeclCollector: public clang::ASTConsumer { private: ///\brief Contains the transaction AST transformers. /// @@ -120,10 +118,6 @@ namespace cling { void MacroDefined(const clang::Token &MacroNameTok, const clang::MacroDirective *MD); /// \} - /// \name ASTMutationListeners overrides - virtual void AddedCXXImplicitMember(const clang::CXXRecordDecl *RD, - const clang::Decl *D); - /// \} /// \{ /// \name ASTConsumer overrides From f6c542677539b014d789b8e5e9999afd0885e3d5 Mon Sep 17 00:00:00 2001 From: Axel Naumann Date: Fri, 4 Nov 2016 10:18:41 +0100 Subject: [PATCH 2/2] Unloaded Decls are now put back into CodeGen, no need to mark used. --- .../lib/Interpreter/IncrementalParser.cpp | 25 ------------------- .../cling/lib/Interpreter/IncrementalParser.h | 6 ----- .../cling/lib/Interpreter/Interpreter.cpp | 1 - 3 files changed, 32 deletions(-) diff --git a/interpreter/cling/lib/Interpreter/IncrementalParser.cpp b/interpreter/cling/lib/Interpreter/IncrementalParser.cpp index 720a0adced9a7..3679ded27036f 100644 --- a/interpreter/cling/lib/Interpreter/IncrementalParser.cpp +++ b/interpreter/cling/lib/Interpreter/IncrementalParser.cpp @@ -417,31 +417,6 @@ namespace cling { } - void IncrementalParser::markWholeTransactionAsUsed(Transaction* T) const { - ASTContext& C = m_CI->getASTContext(); - for (Transaction::const_iterator I = T->decls_begin(), E = T->decls_end(); - I != E; ++I) { - // Copy DCI; it might get relocated below. - Transaction::DelayCallInfo DCI = *I; - // FIXME: implement for multiple decls in a DGR. - assert(DCI.m_DGR.isSingleDecl()); - Decl* D = DCI.m_DGR.getSingleDecl(); - if (!D->hasAttr()) - D->addAttr(::new (D->getASTContext()) - clang::UsedAttr(D->getSourceRange(), D->getASTContext(), - 0/*AttributeSpellingListIndex*/)); - } - for (Transaction::iterator I = T->deserialized_decls_begin(), - E = T->deserialized_decls_end(); I != E; ++I) { - // FIXME: implement for multiple decls in a DGR. - assert(I->m_DGR.isSingleDecl()); - Decl* D = I->m_DGR.getSingleDecl(); - if (!D->hasAttr()) - D->addAttr(::new (C) clang::UsedAttr(D->getSourceRange(), C, - 0/*AttributeSpellingListIndex*/)); - } - } - void IncrementalParser::emitTransaction(Transaction* T) { for (auto DI = T->decls_begin(), DE = T->decls_end(); DI != DE; ++DI) m_Consumer->HandleTopLevelDecl(DI->m_DGR); diff --git a/interpreter/cling/lib/Interpreter/IncrementalParser.h b/interpreter/cling/lib/Interpreter/IncrementalParser.h index 8f022e2bb81c1..14e58d1d53a32 100644 --- a/interpreter/cling/lib/Interpreter/IncrementalParser.h +++ b/interpreter/cling/lib/Interpreter/IncrementalParser.h @@ -192,12 +192,6 @@ namespace cling { void printTransactionStructure() const; - ///\brief Adds a UsedAttr to all decls in the transaction. - /// - ///\param[in] T - the transaction for which all decls will get a UsedAttr. - /// - void markWholeTransactionAsUsed(Transaction* T) const; - ///\brief Runs the static initializers created by codegening a transaction. /// ///\param[in] T - the transaction for which to run the initializers. diff --git a/interpreter/cling/lib/Interpreter/Interpreter.cpp b/interpreter/cling/lib/Interpreter/Interpreter.cpp index ed6714cd26b64..0f112ca883150 100644 --- a/interpreter/cling/lib/Interpreter/Interpreter.cpp +++ b/interpreter/cling/lib/Interpreter/Interpreter.cpp @@ -637,7 +637,6 @@ namespace cling { assert(!isInSyntaxOnlyMode() && "No CodeGenerator?"); m_IncrParser->emitTransaction(T); m_IncrParser->addTransaction(T); - m_IncrParser->markWholeTransactionAsUsed(T); T->setState(Transaction::kCollecting); auto PRT = m_IncrParser->endTransaction(T); m_IncrParser->commitTransaction(PRT);