We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1e28c6f commit 78d1f32Copy full SHA for 78d1f32
clang/test/Analysis/loop-assumptions.c
@@ -200,3 +200,20 @@ void innerLoopOpaqueCondition(int arg) {
200
}
201
202
203
+
204
+void onlyLoopConditions(int arg) {
205
+ // This "don't assume third iteration" logic only examines the conditions of
206
+ // loop statements and does not affect the analysis of code that implements
207
+ // similar behavior with different language features like if + break, goto,
208
+ // recursive functions, ...
209
+ int i = 0;
210
+ while (1) {
211
+ clang_analyzer_numTimesReached(); // expected-warning {{4}}
212
213
+ // This is not a loop condition.
214
+ if (i++ > arg)
215
+ break;
216
+ }
217
218
+ clang_analyzer_warnIfReached(); // expected-warning {{REACHABLE}}
219
+}
0 commit comments