Commit 2209cc3
committed
Fix #8192: FN condition always false in for loop condition
When a for loop's condition is impossible given the initial value (e.g.
`for (int i = 0; i > 10; i++)`), cppcheck was not emitting a
knownConditionTrueFalse warning.
Fix by populating memory1, memory2 and memoryAfter with the init state
when the condition is immediately false (and no error occured). We can
then set the value for the condition token and thus emit a
knownConditionTrueFalse warning.
Signed-off-by: Francois Berder <fberder@outlook.fr>1 parent 950567e commit 2209cc3
2 files changed
Lines changed: 43 additions & 19 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5175 | 5175 | | |
5176 | 5176 | | |
5177 | 5177 | | |
5178 | | - | |
| 5178 | + | |
| 5179 | + | |
| 5180 | + | |
| 5181 | + | |
| 5182 | + | |
| 5183 | + | |
| 5184 | + | |
| 5185 | + | |
| 5186 | + | |
| 5187 | + | |
| 5188 | + | |
| 5189 | + | |
| 5190 | + | |
5179 | 5191 | | |
| 5192 | + | |
5180 | 5193 | | |
5181 | 5194 | | |
5182 | 5195 | | |
| |||
5385 | 5398 | | |
5386 | 5399 | | |
5387 | 5400 | | |
5388 | | - | |
5389 | | - | |
5390 | | - | |
5391 | | - | |
5392 | | - | |
5393 | | - | |
5394 | | - | |
5395 | | - | |
5396 | | - | |
5397 | | - | |
5398 | | - | |
5399 | | - | |
5400 | | - | |
5401 | | - | |
5402 | | - | |
5403 | | - | |
5404 | | - | |
| 5401 | + | |
| 5402 | + | |
| 5403 | + | |
| 5404 | + | |
| 5405 | + | |
| 5406 | + | |
| 5407 | + | |
| 5408 | + | |
| 5409 | + | |
| 5410 | + | |
| 5411 | + | |
| 5412 | + | |
| 5413 | + | |
| 5414 | + | |
| 5415 | + | |
| 5416 | + | |
| 5417 | + | |
| 5418 | + | |
| 5419 | + | |
| 5420 | + | |
| 5421 | + | |
| 5422 | + | |
| 5423 | + | |
| 5424 | + | |
| 5425 | + | |
| 5426 | + | |
| 5427 | + | |
| 5428 | + | |
5405 | 5429 | | |
5406 | 5430 | | |
5407 | 5431 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5639 | 5639 | | |
5640 | 5640 | | |
5641 | 5641 | | |
5642 | | - | |
| 5642 | + | |
5643 | 5643 | | |
5644 | 5644 | | |
5645 | 5645 | | |
| |||
0 commit comments