diff options
Diffstat (limited to 'clang/lib/StaticAnalyzer/Core/ExprEngine.cpp')
-rw-r--r-- | clang/lib/StaticAnalyzer/Core/ExprEngine.cpp | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp index 43b067b6d2b..3629d72cf7d 100644 --- a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp +++ b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp @@ -519,10 +519,13 @@ void ExprEngine::ProcessLoopExit(const Stmt* S, ExplodedNode *Pred) { ExplodedNodeSet Dst; Dst.Add(Pred); NodeBuilder Bldr(Pred, Dst, *currBldrCtx); + ProgramStateRef NewState = Pred->getState(); - LoopExit PP(S, Pred->getLocationContext()); - Bldr.generateNode(PP, Pred->getState(), Pred); + if(AMgr.options.shouldUnrollLoops()) + NewState = processLoopEnd(S, NewState); + LoopExit PP(S, Pred->getLocationContext()); + Bldr.generateNode(PP, NewState, Pred); // Enqueue the new nodes onto the work list. Engine.enqueue(Dst, currBldrCtx->getBlock(), currStmtIdx); } @@ -1519,22 +1522,17 @@ void ExprEngine::processCFGBlockEntrance(const BlockEdge &L, PrettyStackTraceLocationContext CrashInfo(Pred->getLocationContext()); // If we reach a loop which has a known bound (and meets // other constraints) then consider completely unrolling it. - if (AMgr.options.shouldUnrollLoops()) { - const CFGBlock *ActualBlock = nodeBuilder.getContext().getBlock(); - const Stmt *Term = ActualBlock->getTerminator(); - if (Term && shouldCompletelyUnroll(Term, AMgr.getASTContext(), Pred)) { - ProgramStateRef UnrolledState = markLoopAsUnrolled( - Term, Pred->getState(), - cast<FunctionDecl>(Pred->getStackFrame()->getDecl())); - if (UnrolledState != Pred->getState()) - nodeBuilder.generateNode(UnrolledState, Pred); - return; + if(AMgr.options.shouldUnrollLoops()) { + const Stmt *Term = nodeBuilder.getContext().getBlock()->getTerminator(); + if (Term) { + ProgramStateRef NewState = updateLoopStack(Term, AMgr.getASTContext(), + Pred); + if (NewState != Pred->getState()){ + Pred = nodeBuilder.generateNode(NewState, Pred); + } } - - if (ActualBlock->empty()) - return; - - if (isUnrolledLoopBlock(ActualBlock, Pred, AMgr)) + // Is we are inside an unrolled loop then no need the check the counters. + if(isUnrolledState(Pred->getState())) return; } |