Merge unloadTransaction and rollbackTransaction.

This commit is contained in:
Vassil Vassilev 2014-03-24 12:02:41 +01:00 committed by sftnight
parent cad76c3090
commit 4d5e607256
3 changed files with 17 additions and 34 deletions

View File

@ -455,7 +455,7 @@ namespace cling {
T->setIssuedDiags(Transaction::kErrors);
}
bool IncrementalParser::transformTransactionIR(Transaction* T) const {
bool IncrementalParser::transformTransactionIR(Transaction* T) {
// Transform IR
bool success = true;
for (size_t i = 0; success && i < m_IRTransformers.size(); ++i)
@ -465,11 +465,15 @@ namespace cling {
return success;
}
void IncrementalParser::rollbackTransaction(Transaction* T) const {
assert(T->getIssuedDiags() == Transaction::kErrors
&& "Rolling back with no errors");
void IncrementalParser::rollbackTransaction(Transaction* T) {
assert(T && "Must have value");
assert(T == getLastTransaction() && "We always must revert the last T");
assert((T->getState() != Transaction::kRolledBack ||
T->getState() != Transaction::kRolledBackWithErrors) &&
"Transaction already rolled back.");
if (m_Interpreter->getOptions().ErrorOut)
return;
ASTNodeEraser NodeEraser(&getCI()->getSema(), m_CodeGen.get(),
m_Interpreter->getExecutionEngine());
@ -477,6 +481,10 @@ namespace cling {
T->setState(Transaction::kRolledBack);
else
T->setState(Transaction::kRolledBackWithErrors);
// Remove from the queue
m_Transactions.pop_back();
//m_TransactionPool->releaseTransaction(T);
}
std::vector<const Transaction*> IncrementalParser::getAllTransactions() {
@ -629,26 +637,6 @@ namespace cling {
return IncrementalParser::kSuccess;
}
void IncrementalParser::unloadTransaction(Transaction* T) {
if (!T)
T = getLastTransaction();
assert (T == getLastTransaction() && "We always must revert the last T");
if (T->getState() == Transaction::kRolledBackWithErrors)
return; // The transaction was already 'unloaded'/'reverted'.
assert(T->getState() == Transaction::kCommitted &&
"Unloading not commited transaction?");
ASTNodeEraser NodeEraser(&getCI()->getSema(), m_CodeGen.get(),
m_Interpreter->getExecutionEngine());
NodeEraser.RevertTransaction(T);
// Remove from the queue
m_Transactions.pop_back();
//m_TransactionPool->releaseTransaction(T);
}
void IncrementalParser::printTransactionStructure() const {
for(size_t i = 0, e = m_Transactions.size(); i < e; ++i) {
m_Transactions[i]->printStructureBrief();

View File

@ -133,14 +133,15 @@ namespace cling {
///
void codeGenTransaction(Transaction* T);
///\brief Reverts the AST into its previous state.
///\brief Reverts the interpreter into its previous state.
///
/// If one of the declarations caused error in clang it is rolled back from
/// the AST. This is essential feature for the error recovery subsystem.
/// Also this is a key entry point for the code unloading.
///
///\param[in] T - The transaction to be reverted from the AST
///
void rollbackTransaction(Transaction* T) const;
void rollbackTransaction(Transaction* T);
///\brief Returns the first transaction the incremental parser saw.
///
@ -194,12 +195,6 @@ namespace cling {
///
Transaction* Parse(llvm::StringRef input, const CompilationOptions& Opts);
///\brief Unloads a given transaction.
///
///\param[in] T - The transaction to unload.
///
void unloadTransaction(Transaction* T);
void printTransactionStructure() const;
///\brief Adds a UsedAttr to all decls in the transaction.
@ -225,7 +220,7 @@ namespace cling {
///
///\param[in] T - the transaction to be transformed.
///
bool transformTransactionIR(Transaction* T) const;
bool transformTransactionIR(Transaction* T);
///\brief Initializes a virtual file, which will be able to produce valid
/// source locations, with the proper offsets.

View File

@ -940,7 +940,7 @@ namespace cling {
callbacks->TransactionUnloaded(*T);
if (m_Executor) // we also might be in fsyntax-only mode.
m_Executor->runAndRemoveStaticDestructors(T);
m_IncrParser->unloadTransaction(T);
m_IncrParser->rollbackTransaction(T);
if (!--numberOfTransactions)
break;