evaluate now builds DeclRefExpr if there is DeclStmt.

Don't run the wrapper function when the transaction was rolled back.


git-svn-id: http://root.cern.ch/svn/root/trunk@46674 27541ba8-7e3a-0410-8455-c3a389f83636
This commit is contained in:
Vassil Vassilev 2012-10-19 12:23:34 +00:00
parent d916876642
commit d132d3d5ba
2 changed files with 11 additions and 7 deletions

View File

@ -457,7 +457,8 @@ namespace cling {
WrapInput(Wrapper, WrapperName);
if (m_IncrParser->Compile(Wrapper, CO) == IncrementalParser::kSuccess) {
const Transaction* lastT = m_IncrParser->getLastTransaction();
if (RunFunction(lastT->getWrapperFD(), QualType()))
if (lastT->getState() == Transaction::kCommitted
&& RunFunction(lastT->getWrapperFD(), QualType()))
return Interpreter::kSuccess;
}
@ -544,8 +545,10 @@ namespace cling {
Transaction* CurT = m_IncrParser->Parse(Wrapper, CO);
assert(CurT->size() && "No decls created by Parse!");
// FIXME: Don't we have to create a DeclRefExpr if we had int a = 5;?
if (Expr* E = utils::Analyze::GetOrCreateLastExpr(CurT->getWrapperFD())) {
if (Expr* E = utils::Analyze::GetOrCreateLastExpr(CurT->getWrapperFD(),
/*foundAt*/0,
/*omitDS*/false,
&getSema())) {
resTy = E->getType();
}
@ -556,7 +559,9 @@ namespace cling {
// get the result
const Transaction* lastT = m_IncrParser->getLastTransaction();
if (RunFunction(lastT->getWrapperFD(), resTy, V))
if (lastT->getState() == Transaction::kCommitted
&& RunFunction(lastT->getWrapperFD(), resTy, V))
return Interpreter::kSuccess;
else if (V)
*V = StoredValueRef::invalidValue();

View File

@ -25,10 +25,9 @@ V // CHECK: (cling::StoredValueRef) boxes [(int *) 0x12]
// Savannah #96277
gCling->evaluate("double sin(double); double one = sin(3.141/2);", V);
V // CHECK: (cling::StoredValueRef) boxes [(void)]
one // expected-error {{use of undeclared identifier 'one'}}
V // CHECK: (cling::StoredValueRef) boxes [(double) 1.000000e+00]
gCling->process("double sin(double); double one = sin(3.141/2);", &V);
V // CHECK: (cling::StoredValueRef) boxes [(void)]
V // CHECK: (cling::StoredValueRef) boxes [(double) 1.000000e+00]
one // CHECK: (double) 1.000
int one; // expected-error {{saying something like redecl but verify is broken!}}