Merge transaction unlinking into deregisterTransaction; pass nullptr if Transaction gets unloaded.
This commit is contained in:
parent
1ec7136eeb
commit
97c5bafb2f
@ -352,7 +352,7 @@ namespace cling {
|
||||
return ParseResultTransaction(T, ParseResult);
|
||||
}
|
||||
|
||||
void IncrementalParser::commitTransaction(ParseResultTransaction PRT) {
|
||||
void IncrementalParser::commitTransaction(ParseResultTransaction& PRT) {
|
||||
Transaction* T = PRT.getPointer();
|
||||
if (!T) {
|
||||
if (PRT.getInt() != kSuccess) {
|
||||
@ -392,6 +392,8 @@ namespace cling {
|
||||
Diags.Reset(/*soft=*/true);
|
||||
Diags.getClient()->clear();
|
||||
|
||||
PRT.setPointer(nullptr);
|
||||
PRT.setInt(kFailed);
|
||||
m_Interpreter->unload(*T);
|
||||
|
||||
if (MustStartNewModule) {
|
||||
@ -418,8 +420,10 @@ namespace cling {
|
||||
|
||||
for (Transaction::const_nested_iterator I = T->nested_begin(),
|
||||
E = T->nested_end(); I != E; ++I)
|
||||
if ((*I)->getState() != Transaction::kCommitted)
|
||||
commitTransaction(ParseResultTransaction(*I, PR));
|
||||
if ((*I)->getState() != Transaction::kCommitted) {
|
||||
ParseResultTransaction PRT(*I, PR);
|
||||
commitTransaction(PRT);
|
||||
}
|
||||
}
|
||||
|
||||
// If there was an error coming from the transformers.
|
||||
@ -515,6 +519,7 @@ namespace cling {
|
||||
// trigger emission of weak symbols by providing use.
|
||||
ParseResultTransaction PRT = endTransaction(deserT);
|
||||
commitTransaction(PRT);
|
||||
deserT = PRT.getPointer();
|
||||
|
||||
// This llvm::Module is done; finalize it and pass it to the execution
|
||||
// engine.
|
||||
@ -537,7 +542,9 @@ namespace cling {
|
||||
// Reset the module builder to clean up global initializers, c'tors, d'tors
|
||||
getCodeGenerator()->HandleTranslationUnit(Context);
|
||||
FileName = OldName;
|
||||
commitTransaction(endTransaction(deserT));
|
||||
auto PRT = endTransaction(deserT);
|
||||
commitTransaction(PRT);
|
||||
deserT = PRT.getPointer();
|
||||
|
||||
std::unique_ptr<llvm::Module> M(getCodeGenerator()->ReleaseModule());
|
||||
|
||||
@ -576,13 +583,17 @@ namespace cling {
|
||||
}
|
||||
|
||||
void IncrementalParser::deregisterTransaction(Transaction& T) {
|
||||
if (!T.getParent()) {
|
||||
if (Transaction* Parent = T.getParent()) {
|
||||
Parent->removeNestedTransaction(&T);
|
||||
T.setParent(0);
|
||||
} else {
|
||||
// Remove from the queue
|
||||
assert(&T == m_Transactions.back() && "Out of order transaction removal");
|
||||
m_Transactions.pop_back();
|
||||
if (!m_Transactions.empty())
|
||||
m_Transactions.back()->setNext(0);
|
||||
}
|
||||
|
||||
m_TransactionPool->releaseTransaction(&T);
|
||||
}
|
||||
|
||||
|
@ -130,7 +130,7 @@ namespace cling {
|
||||
///\param[in] PRT - the transaction (ParseResultTransaction, really) to be
|
||||
/// committed
|
||||
///
|
||||
void commitTransaction(ParseResultTransaction PRT);
|
||||
void commitTransaction(ParseResultTransaction& PRT);
|
||||
|
||||
///\brief Runs the consumers (e.g. CodeGen) on a non-parsed transaction.
|
||||
///
|
||||
|
@ -693,10 +693,12 @@ namespace cling {
|
||||
m_IncrParser->addTransaction(T);
|
||||
m_IncrParser->markWholeTransactionAsUsed(T);
|
||||
T->setState(Transaction::kCollecting);
|
||||
m_IncrParser->commitTransaction(m_IncrParser->endTransaction(T));
|
||||
auto PRT = m_IncrParser->endTransaction(T);
|
||||
m_IncrParser->commitTransaction(PRT);
|
||||
|
||||
if (executeTransaction(*T))
|
||||
return Interpreter::kSuccess;
|
||||
if ((T = PRT.getPointer()))
|
||||
if (executeTransaction(*T))
|
||||
return Interpreter::kSuccess;
|
||||
|
||||
return Interpreter::kFailure;
|
||||
}
|
||||
|
@ -1228,13 +1228,6 @@ namespace cling {
|
||||
}
|
||||
|
||||
|
||||
void TransactionUnloader::unlinkTransactionFromParent(Transaction* T) {
|
||||
if (Transaction* Parent = T->getParent()) {
|
||||
Parent->removeNestedTransaction(T);
|
||||
T->setParent(0);
|
||||
}
|
||||
}
|
||||
|
||||
bool TransactionUnloader::unloadDeclarations(Transaction* T,
|
||||
clang::DeclUnloader& DeclU) {
|
||||
bool Successful = true;
|
||||
@ -1311,7 +1304,6 @@ namespace cling {
|
||||
bool TransactionUnloader::RevertTransaction(Transaction* T) {
|
||||
clang::DeclUnloader DeclU(m_Sema, m_CodeGen, T);
|
||||
|
||||
unlinkTransactionFromParent(T);
|
||||
bool Successful = unloadDeclarations(T, DeclU);
|
||||
Successful = unloadFromPreprocessor(T, DeclU) && Successful;
|
||||
Successful = unloadDeserializedDeclarations(T, DeclU) && Successful;
|
||||
|
@ -31,7 +31,6 @@ namespace cling {
|
||||
clang::CodeGenerator* m_CodeGen;
|
||||
cling::IncrementalExecutor* m_Exe;
|
||||
|
||||
void unlinkTransactionFromParent(Transaction* T);
|
||||
bool unloadDeclarations(Transaction* T, clang::DeclUnloader& DeclU);
|
||||
bool unloadDeserializedDeclarations(Transaction* T,
|
||||
clang::DeclUnloader& DeclU);
|
||||
|
Loading…
Reference in New Issue
Block a user