Paul Fultz II
f603b529df
Fix issue 8413: Condition is always false 'i=expr; if (i != expr) {}' ( #1295 )
...
* Follow variables when comparing same expression
* Remove assert include
* Dont follow function arguments
* Improve the checking to check more cases
* Add more tests
* Check if the variable is used inside a loop
* Follow both variables
* Only skip loops when variable is modified in scope
* Fix FP when followed variable is modified
* Dont follow arrays
* Skip pointer indirection
* Make recursive
* Improve checking more variables
* Fix test with sizeof
* Skip following operators
* Fix test when using sizeof
* Dont check every step
* Use early returns
* Update test to use a loop instead of conditional
* Add static
* Check variables are global
* Check local variables in another scope
* Fix issue with const pointers
* Distinguish between pointer indirection and multiply
* Use simple match
* Prevent crash with uniform initialization
* Use unary op and ast to detect pointer indirection
* Expand error message when expression do not match exactly
* Add errorpath to issameexpression
* Revert "Clarify warning message for 'Same expression on both sides of operator'"
This reverts commit 0e491b41a8
.
* Check if the tokens are the same
* Report the operator and not the expressions
2018-08-07 09:32:16 +02:00
Daniel Marjamäki
1b933f4dd1
astyle formatting
...
[ci skip]
2018-08-05 22:40:21 +02:00
Paul Fultz II
b839ad60dd
Fix issue 6856: add checks in isOppositeCond when using == and < or > ( #1298 )
...
* Fix issue 6856: add checks in isOppositeCond when using == and < or >
* Move tests to testcondition
* Fix some more tests
* Fix test messages
* Remove the float check
2018-08-05 22:39:40 +02:00
Paul Fultz II
9895ea5ff2
Fix issue 470: Condition is always true or false on logical operators ( #1294 )
...
* Fix issue 470: Condition is always true or false on logical operators
* Dont warn on literals
* Compute logical operators using valueflow
* Fix FP when using literals
* Always warn on subconditions that are always true
* Use percent matches first
* Add test for logical operators
* Check if parent is null
2018-07-23 08:51:59 +02:00
Daniel Marjamäki
77b653bf94
Clarify warnings when char literals are converted to bool in conditions
2018-07-21 18:40:06 +02:00
Paul Fultz II
5d1fdf7958
Fix issue 7904: Handle double nots in isSameExpression ( #1305 )
...
* Fix issue 7904: Handle double nots in isSameExpression
* Skip checking double nots in assignments
* Use ast to check for double not
2018-07-15 11:30:02 +02:00
Paul Fultz II
42f075c3fa
Skip literals for always true/false ( #1304 )
2018-07-12 23:06:47 +02:00
Daniel Marjamäki
7e2858f158
astyle formatting
...
[ci skip]
2018-07-10 22:56:18 +02:00
Daniel Marjamäki
03faa25d12
Conditions: Better handling of function calls
2018-07-08 15:58:04 +02:00
amai2012
c2f0828a61
#6645 false negative: condition is always false. Add a regression test
2018-07-03 08:25:37 +02:00
IOBYTE
ce50df8047
Fix override warnings. ( #1234 )
2018-05-15 16:37:40 +02:00
Paul Fultz II
c520735009
Improve checking of size condition against empty to avoid FPs ( #1213 )
...
* Improve checking of size condition against empty to avoid FPs
* Add const and todo for reverse conditions
2018-05-11 10:22:06 +02:00
Paul Fultz II
e571e598b6
Fix false positive with inner conditions when using pointers ( #1195 )
2018-04-28 18:56:13 +02:00
Daniel Marjamäki
1b4f4d7130
Fixed #8495 (False positive: boolean result used in bitwise operation when & is overloaded)
2018-04-17 22:14:17 +02:00
PKEuS
bbfcccf078
Refactorization: Replace several push_back-sequences by initializer lists
2018-04-09 09:41:24 +02:00
Daniel Marjamäki
795b9f5e0f
astyle formatting
2018-04-08 09:25:59 +02:00
Paul Fultz II
b85dda77da
Add a check for identical inner conditions ( #1156 )
2018-04-08 08:13:44 +02:00
Paul Fultz II
0c6f184423
Fix false positive for opposite conditions when using different containers ( #1143 )
...
* Fix false positive for opposite conditions when using different containers
* Add additional test
2018-04-05 06:43:13 +02:00
Daniel Marjamäki
7e4dba6a7e
Updated copyright year
2018-03-31 20:59:09 +02:00
Paul
43be20a824
Check more opposite conditions
2018-03-24 07:58:37 +01:00
Daniel Marjamäki
c4caee6b18
Updated copyright year
2018-01-14 15:37:52 +01:00
Daniel Marjamäki
28cfee2d4f
Fixed #8250 (New check: Pointer calculation result cant be NULL unless there is overflow)
2017-10-22 14:32:54 +02:00
Daniel Marjamäki
5993c40d5b
Improve 'opposite inner condition' check
2017-09-22 14:01:20 +02:00
Daniel Marjamäki
927b14b60f
Fixed #8217 (Crash in isVariableChanged())
2017-09-14 15:45:15 +02:00
Daniel Marjamäki
bb20c0504e
CheckCondition: Fix FP in daca (iqtree) 'in >> ch'
2017-09-13 22:46:36 +02:00
Daniel Marjamäki
9f4fc7b323
Rename sameConditionAfterEarlyExit to identicalConditionAfterEarlyExit
2017-09-10 22:59:39 +02:00
Daniel Marjamäki
db321c2617
CheckCondition: Fix FP when there is increment/decrement in condition (daca icu)
2017-09-10 22:58:05 +02:00
Daniel Marjamäki
c34fdd1905
CheckCondition: Fix FP for undeclared variables (daca)
2017-09-10 22:30:41 +02:00
Daniel Marjamäki
899ad8479d
CheckCondition: Fixed FP when condition contains global static variable
2017-09-08 15:44:56 +02:00
Daniel Marjamäki
d9adb5432a
astyle formatting
...
[ci skip]
2017-09-08 15:41:14 +02:00
Nekto89
9cbfa0e383
Fix #7803 : false negative: condition is always true 'if (flags & A)' ( #938 )
2017-09-08 14:30:42 +02:00
Daniel Marjamäki
58db814d72
Rephraze /Same/Identical/
2017-09-08 12:41:33 +02:00
Daniel Marjamäki
120d0f86d0
CheckCondition: Fix FP about same condition when switch case is used (daca)
2017-09-07 22:05:01 +02:00
Daniel Marjamäki
f2d56363d3
CheckCondition: Fix TODO assertion
2017-09-06 22:53:36 +02:00
Daniel Marjamäki
e0c7f7f8f2
CheckCondition: Fix FP when there are method calls in condition
2017-09-06 22:26:00 +02:00
Daniel Marjamäki
35736364f8
Fixed #8199 (false negative: (warning) Same condition '...', second condition is always false)
2017-09-05 22:45:28 +02:00
Daniel Marjamäki
e5e6f37e41
Fixed #7405 (false positive: (warning) Opposite conditions in nested 'if' blocks lead to a dead code block.)
2017-09-05 22:03:29 +02:00
Daniel Marjamäki
c1000998f0
CheckCondition: Fix FP found in daca results (ace)
2017-09-05 09:33:35 +02:00
Daniel Marjamäki
d82805b7fe
CheckCondition: Improved checking for same conditions
2017-09-04 22:40:34 +02:00
Daniel Marjamäki
abae5e0156
Fixed #8198 (false positive: (warning) Same condition, second condition is always false)
2017-09-04 22:25:20 +02:00
Daniel Marjamäki
ad494b996c
TestCondition: break out tests to functions
2017-09-04 22:11:53 +02:00
Daniel Marjamäki
d838dc2129
CheckCondition::multiCondition2: Fix FN for pointers
2017-09-04 15:58:22 +02:00
Daniel Marjamäki
9465dca583
CheckCondition: Fix FPs for aliased variables (daca)
2017-09-04 09:34:03 +02:00
Daniel Marjamäki
ef4a7ba7f2
Fix FP in CheckCondition::multiCondition2
2017-09-03 14:46:37 +02:00
Daniel Marjamäki
b9849d9e4e
CheckCondition::multiCondition2: Handle loops better
2017-09-03 11:03:01 +02:00
Daniel Marjamäki
01e65d3e00
Improved CheckCondition::multiCondition2 so deeper bugs are found
2017-09-03 10:44:22 +02:00
Daniel Marjamäki
f2ec5f24ce
Fixed #5845 (new check: same condition after noreturn conditional code => second condition is always false)
2017-09-03 10:34:34 +02:00
Daniel Marjamäki
0b751dcc1b
Opposite conditions: Better matching when outer condition uses &&
2017-09-01 23:24:15 +02:00
Daniel Marjamäki
3b4f60fd21
Updated error message
2017-09-01 13:33:47 +02:00
Daniel Marjamäki
7fad1b9a36
Improved checking for opposite conditions
2017-08-31 22:53:21 +02:00