Commit 40f42a1
committed
Fix cppcheck-opensource#8192: FN knownConditionTrueFalse for always-false 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.
Signed-off-by: Francois Berder <fberder@outlook.fr>1 parent caff3d4 commit 40f42a1
2 files changed
Lines changed: 44 additions & 19 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5180 | 5180 | | |
5181 | 5181 | | |
5182 | 5182 | | |
5183 | | - | |
| 5183 | + | |
| 5184 | + | |
| 5185 | + | |
| 5186 | + | |
| 5187 | + | |
| 5188 | + | |
| 5189 | + | |
| 5190 | + | |
| 5191 | + | |
| 5192 | + | |
| 5193 | + | |
| 5194 | + | |
| 5195 | + | |
5184 | 5196 | | |
| 5197 | + | |
5185 | 5198 | | |
5186 | 5199 | | |
5187 | 5200 | | |
| |||
5390 | 5403 | | |
5391 | 5404 | | |
5392 | 5405 | | |
5393 | | - | |
5394 | | - | |
5395 | | - | |
5396 | | - | |
5397 | | - | |
5398 | | - | |
5399 | | - | |
5400 | | - | |
5401 | | - | |
5402 | | - | |
5403 | | - | |
5404 | | - | |
5405 | | - | |
5406 | | - | |
5407 | | - | |
5408 | | - | |
5409 | | - | |
| 5406 | + | |
| 5407 | + | |
| 5408 | + | |
| 5409 | + | |
| 5410 | + | |
| 5411 | + | |
| 5412 | + | |
| 5413 | + | |
| 5414 | + | |
| 5415 | + | |
| 5416 | + | |
| 5417 | + | |
| 5418 | + | |
| 5419 | + | |
| 5420 | + | |
| 5421 | + | |
| 5422 | + | |
| 5423 | + | |
| 5424 | + | |
| 5425 | + | |
| 5426 | + | |
| 5427 | + | |
| 5428 | + | |
| 5429 | + | |
| 5430 | + | |
| 5431 | + | |
| 5432 | + | |
| 5433 | + | |
| 5434 | + | |
5410 | 5435 | | |
5411 | 5436 | | |
5412 | 5437 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5581 | 5581 | | |
5582 | 5582 | | |
5583 | 5583 | | |
5584 | | - | |
| 5584 | + | |
5585 | 5585 | | |
5586 | 5586 | | |
5587 | 5587 | | |
| |||
0 commit comments