diff options
author | Anna Zaks <ganna@apple.com> | 2011-10-24 18:26:03 +0000 |
---|---|---|
committer | Anna Zaks <ganna@apple.com> | 2011-10-24 18:26:03 +0000 |
commit | f011a4a6f9b7cad52eea74c5c7c89d7e626e9ad5 (patch) | |
tree | 2a56d4469050fd32a864d8e913db496c98b56e6a /clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp | |
parent | 0bb9d1b91754afb50685b2b830ddf6a713731bcf (diff) | |
download | bcm5719-llvm-f011a4a6f9b7cad52eea74c5c7c89d7e626e9ad5.tar.gz bcm5719-llvm-f011a4a6f9b7cad52eea74c5c7c89d7e626e9ad5.zip |
[analyzer] Convert VisitUnaryOperator to use short lived Node builders
To convert iteratively, we take the nodes the local builder will
process from the from the global builder and add the generated nodes
after the short lived builder is done. PureStmtNodeBuilder is the
one we should eventually use everywhere. Added Stmt index and Builder
context as ExprEngine globals. To avoid passing them around.
llvm-svn: 142828
Diffstat (limited to 'clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp')
-rw-r--r-- | clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp | 41 |
1 files changed, 25 insertions, 16 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp b/clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp index 68ccc59ac95..eeb6b44ef2b 100644 --- a/clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp +++ b/clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp @@ -530,9 +530,15 @@ VisitUnaryExprOrTypeTraitExpr(const UnaryExprOrTypeTraitExpr *Ex, void ExprEngine::VisitUnaryOperator(const UnaryOperator* U, ExplodedNode *Pred, - ExplodedNodeSet &Dst) { + ExplodedNodeSet &Dst) { + Builder->takeNodes(Pred); + PureStmtNodeBuilder Bldr(Pred, Dst, *currentBuilderContext); + bool IncDec = false; switch (U->getOpcode()) { default: + Builder->addNodes(Pred); + IncDec = true; + VisitIncrementDecrementOperator(U, Pred, Dst); break; case UO_Real: { const Expr *Ex = U->getSubExpr()->IgnoreParens(); @@ -544,17 +550,16 @@ void ExprEngine::VisitUnaryOperator(const UnaryOperator* U, // FIXME: We don't have complex SValues yet. if (Ex->getType()->isAnyComplexType()) { // Just report "Unknown." - Dst.Add(*I); continue; } // For all other types, UO_Real is an identity operation. assert (U->getType() == Ex->getType()); const ProgramState *state = (*I)->getState(); - MakeNode(Dst, U, *I, state->BindExpr(U, state->getSVal(Ex))); + Bldr.generateNode(U, *I, state->BindExpr(U, state->getSVal(Ex))); } - return; + break; } case UO_Imag: { @@ -567,17 +572,16 @@ void ExprEngine::VisitUnaryOperator(const UnaryOperator* U, // FIXME: We don't have complex SValues yet. if (Ex->getType()->isAnyComplexType()) { // Just report "Unknown." - Dst.Add(*I); continue; } // For all other types, UO_Imag returns 0. const ProgramState *state = (*I)->getState(); SVal X = svalBuilder.makeZeroVal(Ex->getType()); - MakeNode(Dst, U, *I, state->BindExpr(U, X)); + Bldr.generateNode(U, *I, state->BindExpr(U, X)); } - return; + break; } case UO_Plus: @@ -598,10 +602,10 @@ void ExprEngine::VisitUnaryOperator(const UnaryOperator* U, for (ExplodedNodeSet::iterator I=Tmp.begin(), E=Tmp.end(); I!=E; ++I) { const ProgramState *state = (*I)->getState(); - MakeNode(Dst, U, *I, state->BindExpr(U, state->getSVal(Ex))); + Bldr.generateNode(U, *I, state->BindExpr(U, state->getSVal(Ex))); } - return; + break; } case UO_LNot: @@ -619,7 +623,7 @@ void ExprEngine::VisitUnaryOperator(const UnaryOperator* U, SVal V = state->getSVal(Ex); if (V.isUnknownOrUndef()) { - MakeNode(Dst, U, *I, state->BindExpr(U, V)); + Bldr.generateNode(U, *I, state->BindExpr(U, V)); continue; } @@ -660,14 +664,19 @@ void ExprEngine::VisitUnaryOperator(const UnaryOperator* U, break; } - - MakeNode(Dst, U, *I, state); + Bldr.generateNode(U, *I, state); } - - return; + break; } } - + + if (!IncDec) + Builder->addNodes(Dst); +} + +void ExprEngine::VisitIncrementDecrementOperator(const UnaryOperator* U, + ExplodedNode *Pred, + ExplodedNodeSet &Dst) { // Handle ++ and -- (both pre- and post-increment). assert (U->isIncrementDecrementOp()); ExplodedNodeSet Tmp; @@ -729,7 +738,7 @@ void ExprEngine::VisitUnaryOperator(const UnaryOperator* U, // It isn't feasible for the original value to be null. // Propagate this constraint. Constraint = svalBuilder.evalEQ(state, SymVal, - svalBuilder.makeZeroVal(U->getType())); + svalBuilder.makeZeroVal(U->getType())); state = state->assume(Constraint, false); |