Paul Fultz II
7d9fdf582b
Fix 10121: False positive: Condition 'ab->a!=123' is always false when modifying an alias ( #3293 )
2021-08-01 10:10:11 +02:00
chrchr-github
9d51b4450b
Add test cases for tickets #9976 and #10371 ( #3364 )
2021-07-27 22:26:19 +02:00
Paul Fultz II
14802b932e
Fix 10362: ValueFlow: global variable might be modified by function call ( #3358 )
2021-07-26 22:21:56 +02:00
Daniel Marjamäki
797de4ef92
Fixed #10363 (FP: compareValueOutOfTypeRangeError)
2021-07-16 19:08:08 +02:00
Daniel Marjamäki
cbb07b6247
misra; implement rule 14.3
2021-07-15 09:43:38 +02:00
Paul Fultz II
66956ed959
Fix 10323: Wrong known value. x!=0 does not mean that x==1 ( #3308 )
2021-06-26 09:16:45 +02:00
Paul Fultz II
508188df2b
Fix 10297: Regression; ValueFlow known value, sign conversion ( #3307 )
2021-06-26 09:16:04 +02:00
Daniel Marjamäki
9769afe434
knownConditionTrueFalse; avoid several warnings when nonzero expression is compared to see if it is positive or negative
2021-06-25 16:25:25 +02:00
Paul Fultz II
486e440c4a
Fix 10298: ValueFlow: Wrong known value, 'x == -1' implicit unsigned cast for rhs ( #3277 )
2021-06-04 17:17:41 +02:00
Paul Fultz II
4b11bb4ad3
10278: ValueFlow: Wrong known value, sign conversion ( #3260 )
2021-05-18 07:28:45 +02:00
Daniel Marjamäki
08184f4681
Fixed #10070 (FP warning: Logical disjunction always evaluates to true)
2021-05-04 13:47:09 +02:00
Paul Fultz II
691f681d86
Fix issue 10235: Regression: oppositeInnerCondition ( #3223 )
2021-04-19 09:15:03 +02:00
Paul Fultz II
563c9dd9cc
Fix issue 10208: FP: knownConditionTrueFalse in for loop with function that assigns by ref ( #3198 )
2021-04-18 21:42:27 +02:00
orbitcowboy
f7e6d216b2
Running astyle [ci skip]
2021-04-09 08:53:32 +02:00
orbitcowboy
b5719418ea
#8206 - Added a regression test
2021-04-09 08:53:01 +02:00
Daniel Marjamäki
c8e661f61f
assignmentInCondition: Clarify error message
2021-04-07 19:46:00 +02:00
Daniel Marjamäki
72802554c9
Fixed #3593 (New Check: Check for assignment within conditional expression)
2021-04-07 17:21:34 +02:00
Paul Fultz II
5077663684
Fix issue 9979: false positive: containerOutOfBounds with conditional resize ( #3136 )
2021-03-30 14:02:28 +02:00
Daniel Marjamäki
42437277dc
Update Copyright year
2021-03-21 20:58:32 +01:00
PKEuS
141d2ac215
Refactorization: Improved internal implementation of severity and certainty levels
...
Backported from LCppC.
2021-02-24 22:00:06 +01:00
PKEuS
cf1937294a
Refactorization: Removed unnecessary \n and spaces in strings
...
Merged from LCppC.
2021-02-20 12:58:42 +01:00
Daniel Marjamäki
49e6e83bc3
astyle formatting
...
[ci skip]
2021-01-29 10:27:32 +01:00
Paul Fultz II
a81427f97f
Fix issue 10022: Logical conjunction error between two completely unrelated members ( #3094 )
2021-01-29 10:26:57 +01:00
Paul Fultz II
e17d22eb87
Fix issue 10134: False positive: value is not known. Early return. ( #3086 )
2021-01-28 12:37:56 +01:00
Paul Fultz II
d80f2fb46f
Reapply f1cc3ad
and fix performance regression ( #3076 )
2021-01-23 08:47:39 +01:00
Daniel Marjamäki
0fa89ff2ba
Revert 14365ffc7
and f1cc3ada8
, there was a performance regression
2021-01-22 10:51:46 +01:00
Paul Fultz II
f1cc3ada86
Refactor valueFlowTerminatingCondition to handle inner conditions and complex conditions ( #3060 )
2021-01-21 20:18:53 +01:00
Daniel Marjamäki
76f759fcc4
Fixed #9702 (False positive: Opposite inner condition when modifying member variable used by inner condition)
2021-01-15 20:51:47 +01:00
Paul Fultz II
f0b5668436
Fix issue 9890: ValueFlow: known value not found (variable is changed in path that returns) ( #3010 )
2021-01-05 16:49:08 +01:00
Daniel Marjamäki
b3b7ecc7ea
Removed integerOverflowOptimization checking and merged functionality into invalidTestForOverflow
2021-01-05 11:38:19 +01:00
Paul Fultz II
626dcd0eba
Fix issue 10037: False positive when passing variables to functions by address ( #2957 )
2020-12-19 08:29:37 +01:00
Rikard Falkeborn
829c543331
TestCondition: Don't warn when sizeof is involved ( #2896 )
2020-11-11 08:01:11 +01:00
Paul Fultz II
bd7e915c20
Add generic reverse valueflow ( #2878 )
2020-11-10 16:00:55 +01:00
Daniel Marjamäki
47914b9960
Crash: Add regression test
2020-10-22 07:40:06 +02:00
Ken-Patrick Lehrmann
e4a54a24db
Fix regression in CheckCondition ( #2854 )
...
Introduced by e2a81a382f
.
2020-10-20 07:56:41 +02:00
Paul Fultz II
857722f859
Fix issue 9711: FP knownConditionTrueFalse for variable modified via pointer ( #2813 )
2020-09-20 14:27:09 +02:00
Paul Fultz II
c2e8051196
Fix issue 9904: False positive: duplicateCondition when modifying variable in lambda ( #2811 )
2020-09-18 07:44:26 +02:00
Paul Fultz II
bfe53fce04
Fix issue 9878: false positive: multiCondition ( #2787 )
2020-09-09 15:39:36 +02:00
Paul Fultz II
a4f43fc2ad
Fix issue 8234: false negative: (warning) Opposite inner 'if' condition leads to a dead code block. ( #2781 )
2020-09-07 07:53:41 +02:00
Daniel Marjamäki
040da4ff32
astyle formatting
2020-09-04 18:43:17 +02:00
shaneasd
84dd0c961f
False positive dynamic_cast auto variable which has been checked against null ( #2769 )
2020-09-04 07:06:26 +02:00
shaneasd
08ea6435ac
fix false positives in constParameter ( #2758 )
2020-09-03 18:44:44 +02:00
Paul Fultz II
ba84196dca
Fix issue 9865: false positive: knownConditionTrueFalse ( #2764 )
2020-09-01 11:22:38 +02:00
Paul Fultz II
3e99bff764
Same expression when comparing with zero ( #2762 )
2020-08-31 08:48:48 +02:00
Paul Fultz II
1c5f496350
Fix issue 8373: false negative: invalid iterator ( #2761 )
2020-08-31 08:46:56 +02:00
Paul Fultz II
82bdbcd73b
Fix issue 9859: false positive: knownConditionTrueFalse ( #2759 )
2020-08-28 19:26:09 +02:00
Paul
46e008c3e2
Fixed #9816 (False positive: Condition '!b' is always false in nested do-while loop)
2020-07-24 08:13:14 +02:00
Paul
dbb410cdae
Merge branch 'main' into condition-in-expr
2020-07-21 13:28:59 -05:00
Daniel Marjamäki
e0be224f4e
Merge pull request #2709 from pfultz2/fp-duplicate-cond-this
...
Fix FP of duplicateCondition when modifying the this variable
2020-07-13 21:14:58 +02:00
Paul
519f2a537a
Format
2020-07-13 13:55:45 -05:00
Paul
450bdfedf3
Fix FP of duplicateCondition when modifying the this variable
2020-07-13 12:40:01 -05:00
Rikard Falkeborn
d8e7e9176b
Fix FN with known condition and sizeof
...
cppcheck behaved differently if sizeof was to the left or right of the
comparison. In order to fix this, we cannot break the while loop until
all operands have been processed.
2020-07-10 23:39:16 +02:00
Daniel Marjamäki
f56a17bf3d
Fixed #8858 (FP: identicalConditionAfterEarlyExit when there is #if)
2020-07-01 07:48:32 +02:00
Paul
edcf668ae2
Update test mesg
2020-06-29 10:15:36 -05:00
Paul
d5b6d49d96
Fix issue 9578: false negative: (style) Condition '...' is always false
2020-06-28 15:28:08 -05:00
Paul Fultz II
0832830a95
Fix issue 9721: ValueFlow: Comparison is always false, but ValueFlow says it is always true ( #2658 )
2020-05-23 07:15:13 +02:00
orbitcowboy
9861a5291e
Formatted the code, there are no functional changes [ci skip]
2020-05-20 23:45:00 +02:00
PKEuS
fb1afe2345
Fixed test suite: Do no longer apply simplifyTokenList2 to token lists, except for those tests that test those simplifications, because checks are no longer run on that simplified token list
...
Changed failing unit test to TODO tests, as they indicate patterns we do no longer understand properly.
2020-05-20 18:54:16 +02:00
PKEuS
c9d8f607df
Optimization: Reduced peak memory usage (30% in my test case) by immediately deleting simplecpp::TokenList while creating the cppcheck TokenList.
2020-05-19 12:08:17 +02:00
Paul Fultz II
d123279fc1
Fix issue 9709: ValueFlow: variable value is not known ( #2643 )
2020-05-14 14:10:32 +02:00
Daniel Marjamäki
08ddd84780
Update copyright year
2020-05-10 11:16:32 +02:00
Daniel Marjamäki
3e0218299b
Revert "Update copyright year"
...
This reverts commit 6eec6c4bd5
.
2020-05-10 11:13:05 +02:00
Daniel Marjamäki
6eec6c4bd5
Update copyright year
2020-05-10 11:11:34 +02:00
Paul Fultz II
3773d0e875
Find more redundant conditions ( #2597 )
2020-04-07 07:15:15 +02:00
Rikard Falkeborn
f6e7fb4bd9
Bugfix valuetype for some integer constants ( #2545 )
2020-02-19 07:51:39 +01:00
Paul Fultz II
7368a54629
Add generic valueflow forward analysis ( #2511 )
2020-02-13 16:27:06 +01:00
Paul Fultz II
90f82d0374
Fix issue 9541: false negative: knownConditionTrueFalse ( #2473 )
...
* Fix issue 9541: false negative: knownConditionTrueFalse
* Add another test case
* Add another test
* Fix FPs
* Format
* Fix compile error
* Remove double conditions
* Fix compile error
2020-01-05 16:25:33 +01:00
Ken-Patrick Lehrmann
a9d423eef2
Fix #8938 : FP identicalInnerCondition ( #2471 )
2020-01-04 11:38:56 +01:00
Paul Fultz II
dd05839a7e
Fix false positives in knownConditionTrueFalse when using expressions with const variables ( #2469 )
2020-01-03 19:35:28 +01:00
Daniel Marjamäki
31bddb6ae0
astyle formatting
...
[ci skip]
2019-12-26 15:48:29 +01:00
Paul Fultz II
ce1fc56e96
Fix issue 6890: ValueFlow: min/max value for variable, after condition ( #2460 )
...
* Set bounds when combining values
* Adust bounds when they are negated
* Try to infer conditional values
* Switch false and true
* Fix checking of conditions
* Fix compare
* Fix remaining tests
* Fix overflows
2019-12-26 15:47:53 +01:00
Paul Fultz II
4aa6385a97
Regression test for 9106: False positive duplicateCondition for struct member ( #2434 )
2019-12-09 06:51:58 +01:00
Daniel Marjamäki
7cd7aff60a
Fixed #9285 (Misleading warning message)
2019-11-16 17:24:54 +01:00
Daniel Marjamäki
fadf209e18
Add test for #9326 (FP knownConditionTrueFalse - Returning bool variable treated as condition)
2019-11-03 08:49:39 +01:00
Daniel Marjamäki
df8bdabddd
Testing; Readded tests
2019-11-03 08:45:34 +01:00
Daniel Marjamäki
9094ff01d3
Fixed #9363 (knownConditionTrueFalse: False positive about function parameter)
2019-10-31 08:34:09 +01:00
Paul Fultz II
0df4876059
Fix issue 9367: FP knownConditionTrueFalse ( #2209 )
2019-09-24 08:15:03 +02:00
Paul Fultz II
a903aa7070
Fix issue 9351: false negative: (style) Condition '...' is always true ( #2201 )
2019-09-23 08:49:04 +02:00
Paul Fultz II
c1961cec1c
Fix issue 9362: FP: (style) Condition '(v&1)==0' is always false ( #2200 )
2019-09-21 19:53:54 +02:00
Paul Fultz II
40f1635c35
Fix issue 9361: false positive: (style) Condition 'isdigit(c)!=0' is always true ( #2199 )
2019-09-21 08:19:54 +02:00
Paul Fultz II
ad8abdb0c3
Add impossible values to ValueFlow ( #2186 )
...
* Add impossible category
* Replace values
* Try to adjust known values
* Add ! for impossible values
* Add impossible with possible values
* Remove contradictions
* Add values when the branch is not dead
* Only copy possible values
* Dont bail on while loops
* Load std lib in valueflow
* Check for function calls
* Fix stl errors
* Fix incorrect impossible check
* Fix heap-after-use error
* Remove impossible values when they are lowered
* Show the bound and remove overlaps
* Infer conditions
* Dont push pointer values through dynamic_cast
* Add test for dynamic_cast issue
* Add shifttoomanybits test
* Add test for div by zero
* Add a test for issue 9315
* Dont make impossible value inconclusive
* Fix FP with shift operator
* Improve handleKnownValuesInLoop for impossible values
* Fix cppcheck warning
* Fix impossible values for ctu
* Bailout for streams
* Check equality conditions
* Fix overflows
* Add regression test for 9332
* Remove duplicate conditions
* Skip impossible values for invalid value
* Check for null
* Rename bound to range
* Formatting
2019-09-20 15:06:37 +02:00
Paul Fultz II
dc0b3527ad
Fix issue 9311: False positive duplicateCondition "same if condition" with pointer inside array of struct ( #2166 )
...
* Check for typeOf through an array
* Handle array constructors
* Format
* Fix compile error on gcc 4.8
2019-09-10 19:41:35 +02:00
Paul Fultz II
70cad280ea
Fix issue 9319: FP knownConditionTrueFalse related to aggregate initialization of struct ( #2147 )
2019-09-05 19:36:45 +02:00
Paul Fultz II
9e140831eb
Fix issue 9329: FP knownConditionTrueFalse - vector modified by function calls ( #2145 )
2019-09-05 16:42:26 +02:00
Paul Fultz II
ee7fe3aaa1
Fix FP: Unitialized variable when using a pointer
...
This fixes the FP in cases like this:
```cpp
void f() {
bool b;
bool * x = &b;
if (x != nullptr)
x = 1;
}
```
It tracks the indirection of the uninit value in valueflow.
2019-08-17 07:36:41 +02:00
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
Paul Fultz II
0c1dff5c93
Fix issue 9268: false negative: (style) Condition '...' is always true ( #2080 )
...
* Fix issue 9268: false negative: (style) Condition '...' is always true
* Fix copy and paste mistake
2019-08-14 06:34:27 +02:00
Paul Fultz II
c0c6f92221
Fix issue 8431 and 8776: Size of constant string
...
Fixes these cases:
```cpp
void f(void) {
const std::string msg="xyz";
if(!msg.empty()){} // Always true
}
```
And out of bounds access:
```cpp
#include <string>
char fstr1(){const std::string s = "<a><b>"; return s[42]; }
wchar_t fwstr1(){const std::wstring s = L"<a><b>"; return s[42]; }
```
2019-08-12 20:24:16 +02:00
Paul Fultz II
aadc404958
Issue 8634: false negative: (style) Condition '...' is always true ( #2075 )
2019-08-12 11:04:01 +02:00
Paul Fultz II
bd02ca5ccb
Fix issue 9207: Not detected 'always true' and unreachable code
2019-08-08 07:46:47 +02:00
Paul Fultz II
ffdd2dc793
Fix issue 8924: Re-enable valueFlowTerminatingCondition
2019-08-05 07:18:06 +02:00
Paul Fultz II
bb52a63c4e
Add check for const variables
...
When a local reference is declared, this will check if that local reference can be declared as `const`.
2019-07-24 09:59:01 +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
Daniel Marjamäki
57c6628732
Revert 'Cleaning up unsimplified templates'. This fix caused problems.
2019-05-16 21:11:04 +02:00
Paul Fultz II
195da2b3d2
Fix issue 8993: False positive duplicateCondition related to auto ( #1831 )
2019-05-14 08:57:36 +02:00
Daniel Marjamäki
d58d4273f9
Cleaning up unsimplified templates
2019-05-11 13:00:03 +02:00
Daniel Marjamäki
0e8f2cdf63
Use multiline in testing
2019-04-28 07:48:38 +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