Since cling::Transaction is public and the fact that on commit of transaction a
new transaction could be triggered, every compile should return the transaction that it actually compiled. I.e. the cling::IncrementalParser::getLastTransaction in many cases might not be the transaction we expect. For example in ROOT's case plugin manager is triggered for some reason and the last transaction is not the one that I'd personally expect. This should be fix roottest/.../runMemory.C git-svn-id: http://root.cern.ch/svn/root/trunk@47465 27541ba8-7e3a-0410-8455-c3a389f83636
This commit is contained in:
parent
e49c5fb31e
commit
009338beb7
@ -298,15 +298,21 @@ namespace cling {
|
||||
assert(!m_VirtualFileID.isInvalid() && "No VirtualFileID created?");
|
||||
}
|
||||
|
||||
IncrementalParser::EParseResult
|
||||
IncrementalParser::Compile(llvm::StringRef input,
|
||||
const CompilationOptions& Opts) {
|
||||
Transaction* IncrementalParser::Compile(llvm::StringRef input,
|
||||
const CompilationOptions& Opts) {
|
||||
|
||||
beginTransaction(Opts);
|
||||
EParseResult Result = ParseInternal(input);
|
||||
commitTransaction(endTransaction());
|
||||
Transaction* CurT = beginTransaction(Opts);
|
||||
EParseResult ParseRes = ParseInternal(input);
|
||||
|
||||
return Result;
|
||||
if (ParseRes == kSuccessWithWarnings)
|
||||
CurT->setIssuedDiags(Transaction::kWarnings);
|
||||
else if (ParseRes == kFailed)
|
||||
CurT->setIssuedDiags(Transaction::kErrors);
|
||||
|
||||
endTransaction();
|
||||
commitTransaction(CurT);
|
||||
|
||||
return CurT;
|
||||
}
|
||||
|
||||
Transaction* IncrementalParser::Parse(llvm::StringRef input,
|
||||
|
@ -157,9 +157,9 @@ namespace cling {
|
||||
///
|
||||
///\param[in] input - The code to compile.
|
||||
///\param[in] Opts - The compilation options to use.
|
||||
///\returns whether the operation was successful.
|
||||
///\returns the declarations that were compiled.
|
||||
///
|
||||
EParseResult Compile(llvm::StringRef input, const CompilationOptions& Opts);
|
||||
Transaction* Compile(llvm::StringRef input, const CompilationOptions& Opts);
|
||||
|
||||
///\brief Parses the given input without calling the custom consumers and
|
||||
/// code generation.
|
||||
|
@ -439,12 +439,12 @@ namespace cling {
|
||||
std::string WrapperName;
|
||||
std::string Wrapper = input;
|
||||
WrapInput(Wrapper, WrapperName);
|
||||
if (m_IncrParser->Compile(Wrapper, CO) == IncrementalParser::kSuccess) {
|
||||
const Transaction* lastT = m_IncrParser->getLastTransaction();
|
||||
|
||||
const Transaction* lastT = m_IncrParser->Compile(Wrapper, CO);
|
||||
if (lastT->getIssuedDiags() == Transaction::kNone)
|
||||
if (lastT->getState() == Transaction::kCommitted
|
||||
&& RunFunction(lastT->getWrapperFD()) < kExeFirstError)
|
||||
return Interpreter::kSuccess;
|
||||
}
|
||||
|
||||
return Interpreter::kFailure;
|
||||
}
|
||||
@ -513,9 +513,10 @@ namespace cling {
|
||||
const CompilationOptions& CO,
|
||||
const clang::Decl** D /* = 0 */) {
|
||||
|
||||
if (m_IncrParser->Compile(input, CO) != IncrementalParser::kFailed) {
|
||||
const Transaction* lastT = m_IncrParser->Compile(input, CO);
|
||||
if (lastT->getIssuedDiags() == Transaction::kNone) {
|
||||
if (D)
|
||||
*D = m_IncrParser->getLastTransaction()->getFirstDecl().getSingleDecl();
|
||||
*D = lastT->getFirstDecl().getSingleDecl();
|
||||
return Interpreter::kSuccess;
|
||||
}
|
||||
|
||||
@ -534,17 +535,15 @@ namespace cling {
|
||||
std::string WrapperName;
|
||||
std::string Wrapper = input;
|
||||
WrapInput(Wrapper, WrapperName);
|
||||
Transaction* lastT = 0;
|
||||
if (V) {
|
||||
Transaction* CurT = m_IncrParser->Parse(Wrapper, CO);
|
||||
assert(CurT->size() && "No decls created by Parse!");
|
||||
lastT = m_IncrParser->Parse(Wrapper, CO);
|
||||
assert(lastT->size() && "No decls created by Parse!");
|
||||
|
||||
m_IncrParser->commitTransaction(CurT);
|
||||
m_IncrParser->commitTransaction(lastT);
|
||||
}
|
||||
else
|
||||
m_IncrParser->Compile(Wrapper, CO);
|
||||
|
||||
// get the result
|
||||
const Transaction* lastT = m_IncrParser->getLastTransaction();
|
||||
lastT = m_IncrParser->Compile(Wrapper, CO);
|
||||
|
||||
if (lastT->getState() == Transaction::kCommitted
|
||||
&& RunFunction(lastT->getWrapperFD(), V) < kExeFirstError)
|
||||
|
Loading…
Reference in New Issue
Block a user