Skip to content

Commit 5d6eb20

Browse files
committed
Remove previous workaround
1 parent 5342456 commit 5d6eb20

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

clang/lib/StaticAnalyzer/Core/ExprEngine.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2557,18 +2557,17 @@ void ExprEngine::processCFGBlockEntrance(const BlockEdge &L,
25572557
if (!isa_and_nonnull<ForStmt, WhileStmt, DoStmt, CXXForRangeStmt>(Term))
25582558
return;
25592559

2560+
// Widen.
2561+
const LocationContext *LCtx = Pred->getLocationContext();
2562+
25602563
// FIXME:
25612564
// We cannot use the CFG element from the via `ExprEngine::getCFGElementRef`
25622565
// since we are currently at the block entrance and the current reference
25632566
// would be stale. Ideally, we should pass on the terminator of the CFG
25642567
// block, but the terminator cannot be referred as a CFG element.
2565-
// As a workaround, we pass on the first element of the block that we are
2566-
// processing.
2567-
ConstCFGElementRef Elem = *nodeBuilder.getContext().getBlock()->ref_begin();
2568-
// Widen.
2569-
const LocationContext *LCtx = Pred->getLocationContext();
2570-
ProgramStateRef WidenedState =
2571-
getWidenedLoopState(Pred->getState(), LCtx, BlockCount, Elem);
2568+
// Here we just pass the current stale block.
2569+
ProgramStateRef WidenedState = getWidenedLoopState(
2570+
Pred->getState(), LCtx, BlockCount, getCFGElementRef());
25722571
nodeBuilder.generateNode(WidenedState, Pred);
25732572
return;
25742573
}

clang/lib/StaticAnalyzer/Core/LoopWidening.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,6 @@ ProgramStateRef getWidenedLoopState(ProgramStateRef PrevState,
3131
const LocationContext *LCtx,
3232
unsigned BlockCount,
3333
ConstCFGElementRef Elem) {
34-
if (Elem.getParent()) {
35-
const Stmt *TermStmt = Elem.getParent()->getTerminatorStmt();
36-
assert((isa<ForStmt, WhileStmt, DoStmt, CXXForRangeStmt>(TermStmt)) &&
37-
"Terminator must be a loop statement");
38-
}
3934
// Invalidate values in the current state.
4035
// TODO Make this more conservative by only invalidating values that might
4136
// be modified by the body of the loop.

0 commit comments

Comments
 (0)