Paul Fultz II
3e0d1141d3
Fix issue 9277: FP: Dont warn for knwon conditions in if constexpr ( #2085 )
2019-08-16 07:56:39 +02:00
Daniel Marjamäki
5dc4f44091
Replace 'unsigned' with 'nonneg' in checkcondition
2019-07-16 08:21:25 +02:00
Daniel Marjamäki
0eedcfc160
Fixed #7464 (warn about opposite if and else-if conditions)
2019-06-30 23:26:49 +02:00
Daniel Marjamäki
175070ca50
Revert "Fixed #8938 (FP identicalInnerCondition)"
...
This reverts commit 0edf0b5628
.
This bailout seems to cause many false negatives
2019-06-22 21:57:19 +02:00
Paul Fultz II
c4325bbec3
Fix issue 9103: False positive duplicateConditionAssign ( #1808 )
...
* Fix issue 9103: False positive duplicateConditionAssign
* Update conditional message
2019-04-26 12:30:41 +02:00
Daniel Marjamäki
76e13c45c7
temporarily disable duplicateConditionalAssign
2019-04-25 07:44:19 +02:00
Daniel Marjamäki
0edf0b5628
Fixed #8938 (FP identicalInnerCondition)
2019-04-22 16:54:59 +02:00
Paul Fultz II
103002578d
Add check for duplicate condition and assignment ( #1799 )
...
* Add check duplicate condition and expression
* Format
* Add assign token
* Add to classInfo
* Change note messages
2019-04-18 20:20:24 +02:00
orbitcowboy
e47b6bf862
Revert quick fix: 0ace50204b (comments)
2019-04-09 08:38:08 +02:00
orbitcowboy
0ace50204b
Fixed a crash on garbage code. The test input was found by afl_cppcheck (type2). Unforunately, the cppcheck-fuzzer-client was crashing only when executing the binary input from afl-fuzz. Using the translated-input (C-code) did not lead to crash. I tested it with activated address/undefined behaviour sanitizer as well as non-instrumented source code. Since the translated output is too long (164 lines), i will not add it the testgarbage.cpp.
2019-04-07 13:27:33 +02:00
Daniel Marjamäki
4ce6de39c5
CheckCondition: Moved checks to 'normal'
2019-03-09 22:00:59 +01:00
Paul Fultz II
0ee3f678b5
Fix issue 8987: False positive knownConditionTrueFalse ( #1678 )
2019-02-20 15:28:31 +01:00
Daniel Marjamäki
bd7790fd8c
Update copyright year
2019-02-09 07:24:06 +01:00
Paul Fultz II
4e147a4c59
Add a check for duplicate if statements
...
This will warn for this:
```cpp
int f(int val)
{
int i = 0;
if( val & 0xff)
i = 1;
if( val & 0xff)
i = 1;
return i;
}
```
2019-01-09 20:41:01 +01:00
Paul Fultz II
9b973e652c
Issue 8830: New check: Function argument evaluates to constant value
...
Add a check for function arguments that can be constant:
```cpp
extern void bar(int);
void f(int x) {
bar((x & 0x01) >> 7); // function 'bar' is always called with a '0'-argument
}
```
2018-12-17 06:04:24 +01:00
Daniel Marjamäki
b049a31e7c
Refactoring; Use visitAstNodes
2018-11-23 20:41:39 +01:00
Paul Fultz II
54453c5802
Fix FP when copying pointer to string ( #1479 )
2018-11-14 06:59:25 +01:00
Daniel Marjamäki
d5a478d5c5
astyle formatting
...
[ci skip]
2018-11-10 21:30:01 +01:00
rikardfalkeborn
a3e717bea9
Use functions instead of comparing with enum ( #1471 )
...
* Use isComparisonOp() instead of enum
* Use isAssignmentOp() instead of enum
2018-11-09 06:30:41 +01:00
Paul Fultz II
7373be2bfa
Add a pass in valueflow for terminating conditions ( #1323 )
...
* Add valueflow for terminating conditions
* Add valueflow test
* Dont check for same expressions for now to avoid double diagnostics
* Check nesting
* Add more tests
* Ensure conditions happen in order
* Check for null
* Add error path
* Support same expression check as well
* Use early continue
* Skip checking the same token
* Avoid double condtion diagnosis
* Fix FP when in switch statements
* Fix FP when time function
* Skip conditional escapes
* Use simpleMatch
* Fix naming
* Fix typo
2018-11-07 06:49:07 +01:00
Paul Fultz II
fafd0742d4
Fix FPs with return conditions ( #1455 )
...
* Fix 8815: FP with identical inner conditions
* Fix issue 8801: FP when not returning a bool
* Fix FP
* Add missing semicolon
* Move returnVar
2018-10-31 09:47:48 +01:00
Daniel Marjamäki
86782af43c
Fix Cppcheck warning
2018-10-25 07:15:32 +02:00
Daniel Marjamäki
2348dcde6c
#8801 : Quick fix for false positives
2018-10-24 19:57:50 +02:00
Daniel Marjamäki
64fbffc90d
astyle formatting
...
[ci skip]
2018-10-21 20:28:46 +02:00
Paul Fultz II
edde0eedaa
Fix FP issue 8801: Condition 'a+b' is always true ( #1444 )
2018-10-21 08:04:00 +02:00
Daniel Marjamäki
e2ea8bc2b0
astyle formatting
...
[ci skip]
2018-10-20 09:28:28 +02:00
Paul Fultz II
40cb9cb1bc
Check conditions in return statements ( #1411 )
...
* Identify return conditions in multiconditions
* Improve error messages
* Check return statements are always true or false
* Add more tests for FPs
* Fix FP when returning const like variables
* Fix FP when returning pointers or classes
* Fix FP with member variable access
* Check non-local variables
* Use simplematch
* Check for null
2018-10-18 21:01:47 +02:00
Paul Fultz II
1fe1ec09a8
Reenable follow var for logical conjunction ( #1400 )
2018-10-01 14:40:03 +02:00
Paul Fultz II
2c91b95d2a
Reenable followVar for multicondition ( #1401 )
2018-10-01 14:34:55 +02:00
Paul Fultz II
f65cf220ba
Fix false positives in unknownEvaluationOrder when using followVar ( #1391 )
...
Fix false positives in unknownEvaluationOrder when using followVar
2018-09-28 08:38:24 +02:00
Daniel Marjamäki
df9df70ba7
astyle formatting
...
[ci skip]
2018-09-08 09:07:59 +02:00
Paul Fultz II
5a2362b2a0
Fix issue 8738: Dont warn about multiconditions when value is known ( #1369 )
2018-09-07 15:02:34 +02:00
Paul Fultz II
2da958efb5
Fix issue 8722: Avoid duplicate messages due for followVar ( #1367 )
2018-09-06 06:55:36 +02:00
Paul Fultz II
ab55b9eccb
Check for same expression in condition check to avoid duplicate messages ( #1359 )
2018-09-02 08:43:17 +02:00
Paul Fultz II
bbf876256c
Add error path to more diagnostics that rely on isSameExpression ( #1342 )
2018-08-17 09:25:07 +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
Daniel Marjamäki
c60763bc14
Refactoring; Use range for loop
2018-07-14 08:18:10 +02:00
Daniel Marjamäki
5b1d96b346
Clarify code with Token::isUnaryOp()
2018-07-14 08:04:08 +02:00
Daniel Marjamäki
2b125e013a
Code refactoring, no functional change intended
2018-07-13 09:20:53 +02:00
Paul Fultz II
42f075c3fa
Skip literals for always true/false ( #1304 )
2018-07-12 23:06:47 +02:00
Daniel Marjamäki
79ffe1d4fc
Rename _tokenizer, _settings, _errorLogger
2018-06-16 16:10:28 +02:00
Daniel Marjamäki
45379a3aa6
Updated copyright year for modified files
...
[ci skip]
2018-06-10 22:07:21 +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
f336c2efe7
Refactoring; Renamed Scope::classStart and Scope::classEnd
2018-04-27 22:36:30 +02:00
Daniel Marjamäki
3d78320d04
CheckCondition: Use isLikelyStreamRead
2018-04-22 09:48:54 +02:00
Daniel Marjamäki
7ee636b934
Refactoring: Reuse isLikelyStreamRead in isVariableChanged
2018-04-18 17:46:10 +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