Skip to content

Commit 9fdfa55

Browse files
author
Your Name
committed
Rename to pending
1 parent 91fd4f9 commit 9fdfa55

3 files changed

Lines changed: 13 additions & 12 deletions

File tree

lib/analyzer.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -156,13 +156,14 @@ struct Analyzer {
156156
Quiet = (1 << 0),
157157
Absolute = (1 << 1),
158158
ContainerEmpty = (1 << 2),
159-
// Do not record the program state at the branch boundaries. Used when assuming a
160-
// condition before the branch is traversed, where those states would be premature.
161-
// When this is not set the branch has already been traversed and control is continuing
162-
// past it, so the assumed state is anchored at the block's end (see the analyzer's
163-
// assume()): this keeps assumptions on variables modified inside the block from being
164-
// discarded as "modified" once control leaves it.
165-
NoState = (1 << 3),
159+
// The branch this condition guards is still pending traversal (it is walked by a
160+
// separate path), so this assume must not record the program state at the branch
161+
// boundaries - those states would be premature. When this is not set the branch has
162+
// already been traversed and control is continuing past it, so the assumed state is
163+
// anchored at the block's end (see the analyzer's assume()): this keeps assumptions on
164+
// variables modified inside the block from being discarded as "modified" once control
165+
// leaves it.
166+
Pending = (1 << 3),
166167
};
167168
};
168169

lib/forwardanalyzer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -793,15 +793,15 @@ namespace {
793793
// mode: the branch's effect is still tracked but nothing is reported in it.
794794
ForwardTraversal ft = fork(!analyzer->updateScope(thenBranch.endBlock, false));
795795
// The branch is traversed below, so don't record its boundary state here.
796-
ft.analyzer->assume(condTok, true, Analyzer::Assume::NoState);
796+
ft.analyzer->assume(condTok, true, Analyzer::Assume::Pending);
797797
Progress pThen = ft.updateBranch(thenBranch, depth - 1);
798798

799799
// Only commit the condition as false on the main path when it actually
800800
// matters. With an else the else block is traversed below (so suppress the
801801
// boundary state); without one the false path continues past the closing
802802
// brace and must record the assumed state there.
803803
if (thenBranch.isDead())
804-
analyzer->assume(condTok, false, hasElse ? Analyzer::Assume::NoState : Analyzer::Assume::None);
804+
analyzer->assume(condTok, false, hasElse ? Analyzer::Assume::Pending : Analyzer::Assume::None);
805805
// The else block is traversed on the main path. If it kills the value
806806
// (modified) the main path stops, but the then-fork may still carry the
807807
// value forward, so defer the break until after the fork continues.

lib/vf_analyzers.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -743,12 +743,12 @@ struct ValueFlowAnalyzer : Analyzer {
743743
endBlock = startBlock->link();
744744
}
745745

746-
// NoState is set only for the pre-traversal assume; without it the 'then' block has already
746+
// Pending is set only for the pre-traversal assume; without it the 'then' block has already
747747
// been traversed and control is leaving it, so anchor the assumed state at the end of the
748748
// block rather than at the condition. Assumptions about variables modified inside the block
749749
// (e.g. an 'if' that narrows a value computed in the block) then survive past it, instead of
750750
// being discarded because the variable was "modified" since the condition was evaluated.
751-
const bool scopeEnd = !(flags & Assume::NoState) && state && endBlock;
751+
const bool scopeEnd = !(flags & Assume::Pending) && state && endBlock;
752752
const Token* anchor = scopeEnd ? endBlock : tok;
753753
const Token* origin = scopeEnd ? endBlock : nullptr;
754754

@@ -760,7 +760,7 @@ struct ValueFlowAnalyzer : Analyzer {
760760
// On the false path the block was already traversed (the true path is handled by scopeEnd
761761
// above), so record the assumed state where control continues: past the else block, or past
762762
// the closing brace when there is no else, so it is available to the enclosing scope.
763-
if (isCondBlock && !(flags & Assume::NoState) && !state) {
763+
if (isCondBlock && !(flags & Assume::Pending) && !state) {
764764
if (Token::simpleMatch(endBlock, "} else {"))
765765
pms.addState(endBlock->linkAt(2)->previous(), getProgramState());
766766
else

0 commit comments

Comments
 (0)