Skip to content

Commit 57f67e2

Browse files
committed
Rename option to assume-at-least-one-iteration
1 parent d938ccc commit 57f67e2

File tree

4 files changed

+16
-15
lines changed

4 files changed

+16
-15
lines changed

clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ ANALYZER_OPTION(
295295
"Whether the analysis should try to unroll loops with known bounds.", false)
296296

297297
ANALYZER_OPTION(
298-
bool, ShouldAssumeOneIteration, "assume-one-iteration",
298+
bool, ShouldAssumeAtLeastOneIteration, "assume-at-least-one-iteration",
299299
"Whether the analyzer should always assume at least one iteration in "
300300
"loops where the loop condition is opaque (i.e. the analyzer cannot "
301301
"determine if it's true or false). Setting this to true eliminates some "

clang/lib/StaticAnalyzer/Core/ExprEngine.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2844,8 +2844,8 @@ void ExprEngine::processBranch(
28442844
if (StFalse) {
28452845
// In a loop, if both branches are feasible (i.e. the analyzer doesn't
28462846
// understand the loop condition), we are before the first iteration and
2847-
// the analyzer option `assume-one-iteration` is set to `true`, then avoid
2848-
// creating the execution path where the analyzer skips the loop.
2847+
// the analyzer option `assume-at-least-one-iteration` is set to `true`,
2848+
// then avoid creating the execution path where the loop is skipped.
28492849
//
28502850
// In some situations this "loop is skipped" execution path is an
28512851
// important corner case that may evade the notice of the developer and
@@ -2856,7 +2856,7 @@ void ExprEngine::processBranch(
28562856
// skipped.
28572857
bool BeforeFirstIteration = IterationsCompletedInLoop == std::optional{0};
28582858
bool SkipFalseBranch = BothFeasible && BeforeFirstIteration &&
2859-
AMgr.options.ShouldAssumeOneIteration;
2859+
AMgr.options.ShouldAssumeAtLeastOneIteration;
28602860
if (!SkipFalseBranch)
28612861
Builder.generateNode(StFalse, false, PredN);
28622862
}

clang/test/Analysis/analyzer-config.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
// CHECK-NEXT: alpha.cplusplus.STLAlgorithmModeling:AggressiveStdFindModeling = false
1111
// CHECK-NEXT: alpha.osx.cocoa.DirectIvarAssignment:AnnotatedFunctions = false
1212
// CHECK-NEXT: apply-fixits = false
13+
// CHECK-NEXT: assume-at-least-one-iteration = false
1314
// CHECK-NEXT: assume-controlled-environment = false
14-
// CHECK-NEXT: assume-one-iteration = false
1515
// CHECK-NEXT: avoid-suppressing-null-argument-paths = false
1616
// CHECK-NEXT: c++-allocator-inlining = true
1717
// CHECK-NEXT: c++-container-inlining = false

clang/test/Analysis/loop-assumptions.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
// RUN: -analyzer-config eagerly-assume=false \
55
// RUN: -verify=expected,noassumeone,noeagerlyassume,combo %s
66
// RUN: %clang_analyze_cc1 -analyzer-checker=debug.ExprInspection \
7-
// RUN: -analyzer-config assume-one-iteration=true \
7+
// RUN: -analyzer-config assume-at-least-one-iteration=true \
88
// RUN: -verify=expected,eagerlyassume,combo %s
99
// RUN: %clang_analyze_cc1 -analyzer-checker=debug.ExprInspection \
10-
// RUN: -analyzer-config assume-one-iteration=true,eagerly-assume=false \
10+
// RUN: -analyzer-config assume-at-least-one-iteration=true,eagerly-assume=false \
1111
// RUN: -verify=expected,noeagerlyassume %s
1212

1313
// The verify tag "combo" is used for one unique warning which is produced in three
@@ -18,8 +18,8 @@
1818
// if the code does not imply that they are possible.
1919
// In particular, if two (or more) iterations are already completed in a loop,
2020
// we don't assume that there can be another iteration. Moreover, if the
21-
// analyzer option `assume-one-iteration` is enabled, then we don't assume that
22-
// a loop can be skipped completely.
21+
// analyzer option `assume-at-least-one-iteration` is enabled, then we don't
22+
// assume that a loop can be skipped completely.
2323

2424
void clang_analyzer_numTimesReached(void);
2525
void clang_analyzer_dump(int);
@@ -37,7 +37,7 @@ void clearTrueCondition(void) {
3737

3838
void clearFalseCondition(void) {
3939
// If the analyzer can definitely determine that the loop condition is false,
40-
// then the loop is (obviously) skipped, even in `assume-one-iteration` mode.
40+
// then the loop is skipped, even in `assume-at-least-one-iteration` mode.
4141
int i;
4242
for (i = 0; i > 10; i++)
4343
clang_analyzer_numTimesReached(); // Unreachable, no report.
@@ -51,8 +51,8 @@ void opaqueCondition(int arg) {
5151
// that more than two iterations are possible. (It _does_ imply that two
5252
// iterations may be possible at least in some cases, because otherwise an
5353
// `if` would've been enough.)
54-
// Moreover, if `assume-one-iteration` is enabled, then assume at least one
55-
// iteration.
54+
// Moreover, if `assume-at-least-one-iteration` is enabled, then assume at
55+
// least one iteration.
5656
int i;
5757
for (i = 0; i < arg; i++)
5858
clang_analyzer_numTimesReached(); // expected-warning {{2}}
@@ -175,9 +175,10 @@ void eagerlyAssumeInSubexpression(int arg) {
175175
clang_analyzer_numTimesReached(); // eagerlyassume-warning {{4}} noeagerlyassume-warning {{2}}
176176
}
177177

178-
// The 'combo' warning intentionally appears when `assume-one-iteration` is
179-
// disabled, but also appears as a bug (or at least inaccuracy) when
180-
// `assume-one-iteration` is true but `EagerlyAssume` is also enabled.
178+
// The 'combo' note intentionally appears if `assume-at-least-one-iteration`
179+
// is disabled, but also appears as a bug (or at least inaccuracy) when
180+
// `assume-at-least-one-iteration` is true but `EagerlyAssume` is also
181+
// enabled.
181182
clang_analyzer_dump(i); // combo-warning {{0}} expected-warning {{1}} expected-warning {{2}} eagerlyassume-warning {{3}}
182183
}
183184

0 commit comments

Comments
 (0)