Paul Fultz II
02287d9d34
Fix issue 7324: valueFlowForward : decrement ( #2737 )
2020-08-24 13:10:36 +02:00
Daniel Marjamäki
2bb73840fc
astyle formatting
2020-08-23 17:17:33 +02:00
Paul Fultz II
ac846b96d1
New check: Iterating a known empty container ( #2740 )
2020-08-22 09:16:26 +02:00
Daniel Marjamäki
e0e70c2531
Fixed compiler warnings
2020-08-21 17:23:55 +02:00
Paul
7776fb82a2
Fix issue 737: new check: Dereference end iterator
2020-08-17 16:36:45 -05:00
Paul
a509de4d70
Add moves
2020-08-11 11:50:27 -05:00
Paul
8c7e91c985
Remove old container forward
2020-08-10 22:09:33 -05:00
Paul
71c228a01a
Check for containers that modify the size using square bracket
2020-08-10 22:07:22 -05:00
Paul
a5b0a1c9e2
Evaluate container size in program memory
2020-08-10 20:08:49 -05:00
Paul
fec2914700
Add tests for container changes
2020-08-09 22:52:03 -05:00
Paul
26693df788
Use forward analyzer for container forward
2020-08-08 00:10:03 -05:00
Daniel Marjamäki
b263b93f73
Merge pull request #2732 from pfultz2/invalid-container-subobj
...
Fix issue 9780: FP: invalidContainer calling push_back after getting the address of the vector
2020-08-07 09:52:25 +02:00
Paul
56affc9080
Fix issue 9780: FP: invalidContainer calling push_back after getting the address of the vector
2020-08-06 21:08:30 -05:00
Paul
0cc1f69862
Fix issue 9770: FP returnDanglingLifetime for class method taking const char* and returning std::string
2020-08-05 23:17:35 -05:00
Daniel Marjamäki
fa32624c93
ValueFlow: Avoid UB in shift when rhs is negative
2020-07-25 14:13:21 +02:00
Ken-Patrick LEHRMANN
a923115710
Add missing operators <<= and >>=
...
This fixes issues (at least false positives) in code using them.
For instance:
```
unsigned compute(unsigned long long a) {
unsigned num = 0;
while (a > 0xFFFFFFFF) {
a >>= 32;
num += 32;
}
if (a > 0xFFFF) {
a >>= 16;
num += 16;
}
if (a > 0xFF) {
num += 8;
}
return num;
}
```
would give false positive:
```
cppcheck --enable=style sl3.cpp
Checking sl3.cpp ...
sl3.cpp:11:11: style: Condition 'a>0xFF' is always false [knownConditionTrueFalse]
if (a > 0xFF) {
^
sl3.cpp:3:14: note: Assuming that condition 'a>0xFFFFFFFF' is not redundant
while (a > 0xFFFFFFFF) {
^
sl3.cpp:11:11: note: Condition 'a>0xFF' is always false
if (a > 0xFF) {
^
```
2020-07-23 14:36:34 +02:00
Daniel Marjamäki
25ad22c6af
astyle formatting
...
[ci skip]
2020-07-23 10:09:06 +02:00
Daniel Marjamäki
df99d8aa0a
Merge pull request #2719 from pfultz2/fp-unreachable-alias
...
Fix issue 9807: False positive: ValueFlow in unreachable code, || lhs is true
2020-07-23 09:52:54 +02:00
Daniel Marjamäki
2fd44fa464
Merge pull request #2710 from pfultz2/fp-invalid-container-pointer
...
Fix issue 9796: False positive: lifetime, pointer item is not deallocated by pop_back
2020-07-22 09:24:54 +02:00
Paul
0def5d7a9a
Reduce variable scope
2020-07-21 19:09:58 -05:00
Paul
dbb410cdae
Merge branch 'main' into condition-in-expr
2020-07-21 13:28:59 -05:00
Paul
38e1b57bc9
Use refs
2020-07-21 13:18:45 -05:00
Paul
e2a81a382f
Track reading aliases during valueflow forward
2020-07-19 23:25:35 -05:00
Paul
831690f89b
Use parseDecl instead
2020-07-16 14:33:39 -05:00
Paul
423dcfd005
Fix issue 9796: False positive: lifetime, pointer item is not deallocated by pop_back
2020-07-15 12:22:36 -05:00
Daniel Marjamäki
1567ccf97b
Merge pull request #2700 from pfultz2/afterConditionFunction
...
Extend scope of afterCondition until end of function
2020-06-30 08:28:08 +02:00
Paul
67e06c18a9
Use the already available function scope
2020-06-29 15:36:01 -05:00
Daniel Marjamäki
f34ff9325a
Fixed testrunner
2020-06-29 21:53:14 +02:00
Daniel Marjamäki
a0770f05e1
Reuse 'extractForLoopValues' in ValueFlow
2020-06-29 21:01:43 +02:00
Paul
07d8cb4f01
Extend scope of afterCondition until end of function
2020-06-29 11:55:59 -05:00
Paul
d5b6d49d96
Fix issue 9578: false negative: (style) Condition '...' is always false
2020-06-28 15:28:08 -05:00
Ken-Patrick Lehrmann
5a3789a23f
9769: Improve value flow for ternary operator
...
In some cases, the condition of the ternary operator is assigned a known
value after the two possible results, and in such cases, we would not
take the opportunity to assign a value to the ternary operator (and to
the other parents in the ast).
This patch adds this capability.
2020-06-20 10:29:28 +02:00
Daniel Marjamäki
2b0e4926bc
valueFlowAfterAssign: variable initialization
2020-06-14 21:14:05 +02:00
Daniel Marjamäki
6600453b44
Try to make Travis happy
2020-06-13 07:45:31 +02:00
Paul Fultz II
3109d16b42
Fix issue 9742: FP iterators3 for address of reference to vector in struct ( #2668 )
2020-06-01 08:53:08 +02:00
Paul Fultz II
eb4754b7d9
Fix issue 9587: False positive: parameter can be declared with const ( #2667 )
2020-05-31 10:10:10 +02:00
Daniel Marjamäki
d64631219b
Fixed #9741 (Wrong value for sizeof)
2020-05-28 21:24:48 +02:00
Paul Fultz II
c9798590ba
Fix issue 9701: False positive. 3rd expression in for uses comma operator. ( #2664 )
2020-05-28 07:41:47 +02:00
Oliver Stöneberg
4f68d85633
optimized non-matchcompiled Token::simpleMatch() a bit ( #2640 )
2020-05-26 20:13:56 +02:00
Daniel Marjamäki
ff17cc2e8f
astyle formatting
...
[ci skip]
2020-05-24 10:52:58 +02:00
Paul Fultz II
bbe6157e16
Fix issue 9712: False positive: Returning pointer to local variable when return line implicitly cast to return type ( #2662 )
2020-05-23 23:12:00 +02:00
Oliver Stöneberg
37bc0483a4
made check.h less heavy ( #2633 )
2020-05-23 07:16:49 +02: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
Daniel Marjamäki
4c5310433c
astyle formatting
...
[ci skip]
2020-05-22 08:48:28 +02:00
Paul Fultz II
8301fa8244
Fix issue 8144: valueFlowBeforeCondition: struct ( #2645 )
2020-05-21 08:47:48 +02:00
Ken-Patrick Lehrmann
a96a879b6d
Fix crash in addons/test/test-misra.py ( #2652 )
2020-05-20 16:02:13 +02:00
Daniel Marjamäki
299e11c991
Fixed Cppcheck warnings
2020-05-19 21:55:28 +02:00
PKEuS
dc701276de
Optimizations to ValueFlow and ForwardAnalyzer:
...
- Remove errorPath of a value on assignment (this fixes enormous memory consumption for code with many subsequent assignments)
- De-virtualized a simple get function that was virtual for no reason
- Cloned function isAliasOf() for single values to avoid instantiating unnecessary std::list objects (
- Replaced a couple of trivial Token::Match/simpleMatch expressions by direct comparison
- Treat enumerators as literal values
2020-05-19 21:07:04 +02:00
PKEuS
793ed68029
Refactorization: Moved code from header to source
...
- from utils.h to new utils.cpp
- from token.h to token.cpp
- from valueflow.h to valueflow.cpp
- from errorlogger.h to errorlogger.cpp
2020-05-19 08:35:12 +02:00
Oliver Stöneberg
e0e50139cb
cleaned up includes based on include-what-you-use ( #2632 )
...
* cleaned up includes based on include-what-you-use
* token.cpp: fixed -Wextra-semi-stmt warning
2020-05-10 16:45:45 +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
Oliver Stöneberg
1af959af2c
fixed -Wextra-semi-stmt Clang warnings ( #2553 )
...
* fixed -Wextra-semi-stmt Clang warnings
* adjusted REDIRECT macro to require a semicolon
* testmathlib.cpp: rolled back accidental change
2020-04-21 17:27:51 +02:00
Daniel Marjamäki
e8bbfdbfee
Fixed #9559 (Multiple checks to std::atomic are not redundant)
2020-04-19 17:29:40 +02:00
Paul Fultz II
e2efb338b6
Fix issue 9678: False positive: generic valueflow forward analysis ( #2611 )
2020-04-19 08:28:07 +02:00
Daniel Marjamäki
efb583e3d1
astyle formatting
...
[ci skip]
2020-04-04 10:31:38 +02:00
Oliver Stöneberg
8968edeabd
avoid unnecessary creation of lists in SingleValueFlowForwardAnalyzer.isAlias() and MultiValueFlowForwardAnalyzer.isAlias() ( #2586 )
...
Comparing before and after (Ir per call) when scanning the Cppcheck source:
SingleValueFlowForwardAnalyzer.isAlias()
1246 -> 1101
MultiValueFlowForwardAnalyzer.isAlias()
4202 -> 1617
2020-04-03 09:25:21 +02:00
Paul Fultz II
71deaaeb18
Fix issue 9608: False Positive: returnDanglingLifetime with braced-init-list ( #2583 )
2020-04-02 10:17:58 +02:00
Paul Fultz II
6cc58e1086
Set a max for the combination of arguments that can be passsed through valueFlowSubFunction ( #2579 )
...
* Set a max for the combination of arguments that can be passsed
* Skip mismatch path ids when computing the cross product
2020-04-01 22:33:09 +02:00
Paul Fultz II
f2527f5340
Fix crash in valueFlowForLoopSimplifyAfter ( #2573 )
2020-03-20 07:16:05 +01:00
orbitcowboy
85a26802e3
Running astyle [ci skip]
2020-03-01 20:39:00 +01:00
Paul Fultz II
6ea4f60600
Enable valueFlowSubfunction for multiple parameters ( #2550 )
2020-03-01 16:46:20 +01:00
Oliver Stöneberg
1863ccb0a7
fixed Clang warnings about unused variables ( #2554 )
2020-02-26 14:52:43 +01:00
Paul Fultz II
392060aefe
Fix issue 7804: ValueFlow: possible value in second if body ( #2543 )
2020-02-19 07:55:04 +01:00
Daniel Marjamäki
95ac456e13
Fixed #9582 (false positive "error: Out of bounds access" with std::array and constant)
2020-02-19 07:36:02 +01:00
Armin Müller
75b1ade316
Typos found by running "codespell" ( #2542 )
2020-02-17 18:28:58 +01:00
Paul Fultz II
3b20684aca
Fix issue 9360: False positive: arrayIndexOutOfBounds when function is called with different array sizes ( #2541 )
2020-02-17 10:31:08 +01:00
amai2012
efeb7deb7a
Run dmake and astyle
2020-02-16 19:58:09 +01:00
Paul Fultz II
921887a281
Use valueFlowGeneric for valueFlowForwardExpression ( #2537 )
2020-02-16 16:02:22 +01:00
Daniel Marjamäki
e04b9fe4a4
Remove unused functions
2020-02-14 20:37:33 +01:00
Daniel Marjamäki
5f4a900f88
astyle formatting
...
[ci skip]
2020-02-13 17:04:05 +01:00
Paul Fultz II
7368a54629
Add generic valueflow forward analysis ( #2511 )
2020-02-13 16:27:06 +01:00
Daniel Marjamäki
3ec03b8915
Fixed #9571 (False positive: containerSize)
2020-02-12 18:53:36 +01:00
Paul Fultz II
8fa7dd0fe0
Fix issue 9595: False positive: Using pointer to temporary doesn't account for const ref extended temporary lifetimes ( #2525 )
2020-02-10 18:01:11 +01:00
Daniel Marjamäki
2b336ac147
Refactoring; stricter lambda capture
2020-02-01 08:28:18 +01:00
Daniel Marjamäki
6c1cc54671
Refactoring; Avoid template<>
2020-02-01 08:24:31 +01:00
Rikard Falkeborn
0bb98aeef9
Fix 9577 (endless recursion in Valueflow::bifurcate()) ( #2492 )
...
Ensure bifurcate() does not recurse endlessly where a variable is
initialized recursively, or a variable is initialized as x(0) or x{0}
followed by a recursive assignment (for example int x(0); x = x / 1;).
The first case is solved by bailing out if there initialization is done
using x(0) or x{0}, the second by adding a missing depth argument to a
recursive call.
2020-01-17 03:17:26 +01:00
Daniel Marjamäki
380cc78077
Clang; Run ValueFlow
2020-01-11 14:00:41 +01:00
Daniel Marjamäki
6b983a9587
Revert ValueFlow changes, there was unexpected problems in testrunner
2020-01-11 13:11:19 +01:00
Daniel Marjamäki
052eaba632
Clang; run ValueFlow analysis
2020-01-11 13:04:51 +01:00
Daniel Marjamäki
96ff57e275
ValueFlow; Refactoring
2020-01-11 09:17:32 +01:00
Daniel Marjamäki
a9dbf129f0
Clang import; some small tweaks
2020-01-09 13:52:17 +01:00
Daniel Marjamäki
1589ac5352
Clang import; Set links properly
2020-01-09 12:42:29 +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
Paul Fultz II
e1a97c524d
Fix issue 9554: False positive: The address of local variable 'x' is accessed at non-zero index. ( #2470 )
...
* Fix issue 9554: False positive: The address of local variable 'x' is accessed at non-zero index.
* Format
* Remove unnecesary condition check
2020-01-04 11:39:52 +01:00
Paul Fultz II
82c91f9484
Fix issue 9550: False positive: Same iterator is used with containers 'x' that are defined in different scopes ( #2463 )
2019-12-31 08:09:04 +01:00
Paul Fultz II
75de485c4d
Fix issue 9551: Out-of-bounds in getLifetimeTokens() ( #2461 )
2019-12-29 08:23:58 +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
42d44f02a2
Use lifetime analysis for checking mismatching containers ( #2456 )
...
* Use lifetimes to check for mismatching containers
* Fix error messages
* Format
* Remove unused variables
* Fix configuration and track iterators through algorithms
* Fix iterator value types in qt config
* Fix library issue with QStringList
* Remove unused functions
* Fix cppcheck errors
2019-12-25 09:32:50 +01:00
Daniel Marjamäki
fe23d017f3
Fixed #8419 (False positive accessMoved on int)
2019-12-21 07:39:14 +01:00
Daniel Marjamäki
33ec78fe6e
Fixed #9036 (false positive: (style) Condition 's.x<127U' is always true)
2019-12-20 19:06:35 +01:00
Daniel Marjamäki
a241be0ecc
Fixed #9434 (False positive: Out of bounds access when using const pointer)
2019-12-15 20:10:28 +01:00
Daniel Marjamäki
bcfc5924fa
Fixed #9532 (False positive: Out of bounds access in expression 'v[0]' because 'v' is empty.)
2019-12-14 19:04:19 +01:00
Rikard Falkeborn
1c92170179
ValueFlow: Remove unused argument ( #2442 )
2019-12-10 17:48:27 +01:00
Sebastian
95e0b0d0f9
Fix #9510 : Crash in valueflow.cpp solveExprValues() (division by zero) ( #2420 )
...
`break` if divider `intval` is 0 to avoid division by 0 as suggested by @pfultz2
Trac ticket: https://trac.cppcheck.net/ticket/9510
2019-12-06 08:08:40 +01:00
versat
e712df7cb4
Run astyle [ci skip]
2019-12-04 13:53:10 +01:00
Paul Fultz II
36977becba
Fix issue 9196: Lambda confuses check ( #2415 )
2019-12-03 18:30:52 +01:00
Paul Fultz II
79a2e61721
Fix issue 6850: Valueflow: pointer alias, conditional value ( #2402 )
2019-11-30 09:22:03 +01:00