Do not value print dynamic expressions when they are in a inner compound stmt.

This commit is contained in:
Vassil Vassilev 2013-06-04 16:03:06 +02:00 committed by sftnight
parent 2d18a9f7e9
commit 92415de6bd
3 changed files with 19 additions and 6 deletions

View File

@ -115,8 +115,8 @@ namespace cling {
EvaluateTSynthesizer::EvaluateTSynthesizer(Sema* S)
: TransactionTransformer(S), m_EvalDecl(0), m_LifetimeHandlerDecl(0),
m_LHgetMemoryDecl(0), m_DynamicExprInfoDecl(0), m_DeclContextDecl(0),
m_gCling(0),
m_CurDeclContext(0), m_Context(&S->getASTContext()), m_UniqueNameCounter(0)
m_gCling(0), m_CurDeclContext(0), m_Context(&S->getASTContext()),
m_UniqueNameCounter(0), m_NestedCompoundStmts(0)
{ }
// pin the vtable here.
@ -287,6 +287,7 @@ namespace cling {
}
ASTNodeInfo EvaluateTSynthesizer::VisitCompoundStmt(CompoundStmt* Node) {
++m_NestedCompoundStmts;
ASTNodes Children;
ASTNodes NewChildren;
if (GetChildren(Children, Node)) {
@ -310,9 +311,12 @@ namespace cling {
bool valuePrinterReq = false;
// If this was the last or the last is not null stmt, means that
// we need to value print.
if ((it+1) == Children.end() ||
((it+2) == Children.end() && !isa<NullStmt>(*(it+1))))
valuePrinterReq = true;
// If this is in a wrapper function's body then look for VP.
if (FunctionDecl* FD = dyn_cast<FunctionDecl>(m_CurDeclContext))
valuePrinterReq
= m_NestedCompoundStmts < 2 && utils::Analyze::IsWrapper(FD)
&& ((it+1) == Children.end() || ((it+2) == Children.end()
&& !isa<NullStmt>(*(it+1))));
// Assume void if still not escaped
NewChildren.push_back(SubstituteUnknownSymbol(m_Context->VoidTy,E,
@ -327,8 +331,8 @@ namespace cling {
Node->setStmts(*m_Context, NewChildren.data(), NewChildren.size());
--m_NestedCompoundStmts;
return ASTNodeInfo(Node, 0);
}
ASTNodeInfo EvaluateTSynthesizer::VisitDeclStmt(DeclStmt* Node) {

View File

@ -157,6 +157,10 @@ namespace cling {
/// \brief Counter used when we need unique names.
unsigned long long m_UniqueNameCounter;
/// \brief Counter used when entering/exitting compound stmt. Needed for
/// value printing of dynamic expressions.
unsigned m_NestedCompoundStmts;
public:
typedef clang::StmtVisitor<EvaluateTSynthesizer, ASTNodeInfo>

View File

@ -40,3 +40,8 @@ if (h->Add(b, c)) { // runtime result type int
}
// CHECK: Sum more than 0!
for (int i = 0; i < 2; ++i) {
dependentInLoop->Add(b, c);
}
//CHECK-NOT:(int) 1
.q