Simplify invocation of DeclUnloader::UnloadDecl().

This commit is contained in:
Axel Naumann 2016-06-26 18:26:35 +03:00 committed by sftnight
parent d695460d0c
commit bedc277fae
5 changed files with 22 additions and 21 deletions

View File

@ -227,8 +227,7 @@ namespace cling {
return true;
// Now that we will read the full enum, unload the forward decl.
DeclUnloader Unloader(m_Sema, 0, /*IncrementalExecutor*/ 0);
Unloader.UnloadDecl(D);
UnloadDecl(m_Sema, D);
return true;
}
};

View File

@ -26,8 +26,7 @@ namespace cling {
if (!CS->size() || (CS->size() == 1 && isa<NullStmt>(CS->body_back()))) {
// This is an empty wrapper function. Get rid of it.
// We know that it didn't end up in the EE by design.
DeclUnloader U(m_Sema, /*CodeGenerator*/ 0, /*Transaction*/ 0);
U.UnloadDecl(FD);
UnloadDecl(m_Sema, FD);
return Result(0, true);
}

View File

@ -275,6 +275,18 @@ namespace clang {
namespace cling {
using clang::DeclUnloader;
/// \brief Unload a Decl from the AST, but not from CodeGen or Module.
inline bool UnloadDecl(clang::Sema* S, clang::Decl* D) {
DeclUnloader Unloader(S, nullptr, nullptr);
return Unloader.UnloadDecl(D);
}
/// \brief Unload a Decl from the AST and CodeGen, but not from the Module.
inline bool UnloadDecl(clang::Sema* S, clang::CodeGenerator* CG, clang::Decl* D) {
DeclUnloader Unloader(S, CG, nullptr);
return Unloader.UnloadDecl(D);
}
} // namespace cling
#endif // CLING_DECL_UNLOADER

View File

@ -705,18 +705,14 @@ namespace cling {
TheDecl = TD->getDefinition();
if (TheDecl->isInvalidDecl()) {
// if the decl is invalid try to clean up
DeclUnloader U(&S, /*CodeGenerator*/0,
/*IncrementalExecutor*/ 0);
U.UnloadDecl(TheDecl);
UnloadDecl(&S, TheDecl);
*setResultType = nullptr;
return 0;
}
} else {
// NOTE: We cannot instantiate the scope: not a valid decl.
// Need to rollback transaction.
DeclUnloader U(&S, /*CodeGenerator*/0,
/*IncrementalExecutor*/ 0);
U.UnloadDecl(TD);
UnloadDecl(&S, TD);
*setResultType = nullptr;
return 0;
}
@ -916,8 +912,7 @@ namespace cling {
}
if (scopeDecl->isInvalidDecl()) {
// if the decl is invalid try to clean up
DeclUnloader U(&S, /*CodeGenerator*/0, /*IncrementalExecutor*/ 0);
U.UnloadDecl(const_cast<Decl*>(scopeDecl));
UnloadDecl(&S, const_cast<Decl*>(scopeDecl));
return 0;
}
@ -965,8 +960,7 @@ namespace cling {
}
if (scopeDecl->isInvalidDecl()) {
// if the decl is invalid try to clean up
DeclUnloader U(&S, /*CodeGenerator*/0, /*IncrementalExecutor*/ 0);
U.UnloadDecl(const_cast<Decl*>(scopeDecl));
UnloadDecl(&S, const_cast<Decl*>(scopeDecl));
return 0;
}
//
@ -1167,8 +1161,7 @@ namespace cling {
true /*recursive instantiation*/);
if (TheDecl->isInvalidDecl()) {
// if the decl is invalid try to clean up
DeclUnloader U(&S, /*CodeGenerator*/0, /*IncrementalExecutor*/ 0);
U.UnloadDecl(const_cast<FunctionDecl*>(TheDecl));
UnloadDecl(&S, const_cast<FunctionDecl*>(TheDecl));
return 0;
}
}
@ -1724,8 +1717,7 @@ namespace cling {
true /*recursive instantiation*/);
if (fdecl->isInvalidDecl()) {
// if the decl is invalid try to clean up
DeclUnloader U(&S, /*CodeGenerator*/0, /*IncrementalExecutor*/ 0);
U.UnloadDecl(fdecl);
UnloadDecl(&S, fdecl);
return 0;
}
return fdecl;

View File

@ -96,7 +96,7 @@ namespace cling {
}
bool TransactionUnloader::RevertTransaction(Transaction* T) {
clang::DeclUnloader DeclU(m_Sema, m_CodeGen, T);
DeclUnloader DeclU(m_Sema, m_CodeGen, T);
bool Successful = unloadDeclarations(T, DeclU);
Successful = unloadFromPreprocessor(T, DeclU) && Successful;
@ -134,8 +134,7 @@ namespace cling {
}
bool TransactionUnloader::UnloadDecl(Decl* D) {
DeclUnloader DeclU(m_Sema, m_CodeGen, 0);
return DeclU.UnloadDecl(D);
return cling::UnloadDecl(m_Sema, m_CodeGen, D);
}
} // end namespace cling