Skip to content

Commit

Permalink
Do not mark decls used, now that unloading tracks deferred decls.
Browse files Browse the repository at this point in the history
This reduces the number of emitted symbols.
  • Loading branch information
Axel-Naumann committed Nov 7, 2016
2 parents 80db0bc + f6c5426 commit 46cf799
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 52 deletions.
2 changes: 0 additions & 2 deletions interpreter/cling/lib/Interpreter/CIFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -752,8 +752,6 @@ namespace {
std::unique_ptr<cling::DeclCollector>
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));
Expand Down
12 changes: 1 addition & 11 deletions interpreter/cling/lib/Interpreter/DeclCollector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Decl*>(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) {
Expand Down
8 changes: 1 addition & 7 deletions interpreter/cling/lib/Interpreter/DeclCollector.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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.
///
Expand Down Expand Up @@ -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
Expand Down
25 changes: 0 additions & 25 deletions interpreter/cling/lib/Interpreter/IncrementalParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<clang::UsedAttr>())
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<clang::UsedAttr>())
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);
Expand Down
6 changes: 0 additions & 6 deletions interpreter/cling/lib/Interpreter/IncrementalParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 0 additions & 1 deletion interpreter/cling/lib/Interpreter/Interpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 46cf799

Please sign in to comment.