Commit Graph

1373 Commits

Author SHA1 Message Date
Oliver Stöneberg 77c479a6c4
pass `TokenList` as reference into `ValueFlow::setValues()` (#4868)
This avoid lots of unchecked pointer dereferences.

There was a single case which checked it and that looked like a
leftover. The only way this might have been a `nullptr` pointer was
through several default constructors which were not used at all so I
removed them.
2023-08-04 18:17:27 +02:00
chrchr-github faf8047050
Fix FP truncLongCastReturn on Windows (#5262) 2023-08-02 12:27:29 +02:00
Oliver Stöneberg 45de338f1b
cleaned up includes based on include-what-you-use / iwyu.yml: updated to yet another distro to get the latest version and updated the Chaotic-AUR key (#5267)
This is a mess. The version is AUR is still outdated and also doesn't
install anymore. Fedora 38 carries the latest version of it so use that
now. Keep the old steps in case we need to switch again in the future.
2023-08-02 10:36:17 +02:00
chrchr-github d2546d5252
Fix #11788 False positive: unreadVariable in else (#5248) 2023-07-18 21:11:03 +02:00
chrchr-github e4827cb3df
Fix #11828 False positive when getting a span via an out argument (#5243)
We didn't warn for the TODO even before this change.
2023-07-15 17:53:40 +02:00
chrchr-github dde45455bf
uselessOverride: Detect code duplication in overriding function (#5219) 2023-07-05 22:58:01 +02:00
chrchr-github 7507d400de
Fix regression: wrong array size (#5194) 2023-06-26 06:51:01 +02:00
chrchr-github bb962e2bc3
Enable and mitigate readability-else-after-return (#5175) 2023-06-20 18:43:21 +02:00
chrchr-github 78c7e3351f
Fix #11697 FP negativeContainerIndex after index is validated (#5172) 2023-06-20 10:55:14 +02:00
Daniel Marjamäki 38b2c5ee3f
Fix #11777 (False positive: uninitialized variable, handling 'false ||' in valueflow) (#5169) 2023-06-17 21:08:22 +02:00
Daniel Marjamäki b462d070bf Minor tweaking of constness 2023-06-15 19:41:47 +02:00
Daniel Marjamäki 1c28457d2c
ValueFlow: Fix uninitvar false positive after initialization '*((int*)&x) = ..' (#5142) 2023-06-10 15:22:17 +02:00
Daniel Marjamäki 3c8caac772
Fix #11688 (FP uninitvar in for loop iteration expression) (#5140) 2023-06-10 09:58:08 +02:00
chrchr-github d4705ca8ab
Fix #10809 cppcheckError Cyclic reverse analysis (#5137)
* Fix #10809 cppcheckError Cyclic reverse analysis

* Handle fixed AST in ValueFlow, fix FN

* Remove
2023-06-10 07:41:52 +02:00
chrchr-github 4dbbae62a7
Fix #11753 FN: invalidLifetime (#5128)
* Fix #11753 FN: invalidLifetime

* Format

* Format

* Only forward for local variables

* Format

* Format
2023-06-08 07:45:59 +02:00
chrchr-github ac86eda6b3
Revert "Revert "Skip forwarding values for unique expressions (#5103)"" (#5124) 2023-06-07 11:11:48 +02:00
Daniel Marjamäki 7d4472616b Revert "Skip forwarding values for unique expressions (#5103)"
This reverts commit 26ed052e8d.
2023-06-06 17:31:24 +02:00
Paul Fultz II 26ed052e8d
Skip forwarding values for unique expressions (#5103) 2023-06-05 20:49:19 +02:00
chrchr-github a32fb63443
Fix hang on huge array (followup to #11649) (#5094)
* Fix hang on huge array

* Fix another hang
2023-05-31 20:56:12 +02:00
chrchr-github 78182d4773
Fix FN constVariablePointer (#5076)
* Fix FN constVariablePointer

* Fix FP

* Add const

* Fix tests

* Add const
2023-05-22 19:53:51 +02:00
chrchr-github 1999bc68bf
Set values when assigning init list (#5057)
* Assign values to pointers with C++11 init

* Handle assigning empty init list

* Fix #10596 FN uninitdata with value initialization

* Fix test

* Set values when assigning init list
2023-05-14 17:01:07 +02:00
chrchr-github dc7550ed9f
Assign values to pointers with C++11 init (#5055)
* Assign values to pointers with C++11 init

* Handle assigning empty init list
2023-05-13 14:09:47 +02:00
chrchr-github 2a0143c8e1
Fix #10358 Bad ValueFlow depending on initialization (#5052) 2023-05-12 07:19:44 +02:00
chrchr-github d3bdb84650
Fix #11701 performance regression (hang) in 2.11dev (#5032) 2023-05-04 11:59:03 +02:00
chrchr-github 100d17df4f
Fix #11681 FN constParameterPointer with std::vector (#5000) 2023-05-04 11:10:58 +02:00
Paul Fultz II 9770dd7e0b
Fix 11673: FP uninitvar when capturing by reference (#4984)
* Fix 11673: FP uninitvar when capturing by reference

* Format

* Fix tests
2023-05-04 06:03:47 +02:00
Paul Fultz II 9d21379c7d
Add non-const overloads for next(), previous(), and link() (#5002)
* Add non-const overloads for next(), previous(), and link()

* Format

* Add CPPCHECKLIB
2023-05-02 06:55:31 +02:00
Paul Fultz II 86757de4d5
ValueFlow: Add pass runner to check timeout and report time (#4952) 2023-04-30 20:39:05 +02:00
chrchr-github 4fdcb0c784
Fix #11649 Hang in setTokenValue() on huge array (#5010)
* Fix #11649 Hang in setTokenValue() on huge array

* Fix function call
2023-04-25 21:02:49 +02:00
Paul Fultz II 1b9369b78b
Fix 11666: FP returnDanglingLifetime with specializations and ptr to member (#5003)
* Fix 11666: FP returnDanglingLifetime with specializations and ptr to member

* Format
2023-04-23 14:38:28 +02:00
Paul Fultz II 1f0376b32d
ValueFlow: Limit the combinations of arguments passed to subfunctions in normal analysis (#4950) 2023-04-12 22:09:48 +02:00
Paul Fultz II ac14fd218b
ValueFlow: Infer possible symbolic values (#4947) 2023-04-10 19:27:29 +02:00
Daniel Marjamäki 7726a5b5b3
Add a --check-level option (#4942) 2023-04-09 13:48:13 +02:00
Daniel Marjamäki 89a95ddc8f --performance-valueflow-max-if-count: review comments 2023-04-08 13:07:28 +02:00
Oliver Stöneberg 39f94f32f9
valueflow.cpp: fixed selfcheck suppression (#4940) 2023-04-08 12:15:16 +02:00
chrchr-github ab24e3a3c8
Fix remaining example from #11599, FN #11646, fix crash (#4929)
* Fix remainig example from #11599

* Fix FP, new warnings

* More warnings

* Use getTokenArgumentFunction()

* Fix crash

* Fix #11646 constParameter not reported with "const * const" parameter

* Fix test

* Fix new warnings

* Add suppression

* Add const, fix suppression
2023-04-06 18:46:45 +02:00
Paul Fultz II e22a740f0c
Fix 11647: FN knownConditionTrueFalse with strings of same length (#4936)
* Fix 11647: FN knownConditionTrueFalse with strings of same length

* Format

* Remove extra size

* Use simpleMatch
2023-04-06 18:42:24 +02:00
Paul Fultz II edfdfe658a
Fix 11651: FP negativeIndex with for loop (#4934) 2023-04-05 11:05:29 +02:00
Paul Fultz II 115f17cfe6
ValueFlow: Improve the starting point for uninitialized variables to find more uninitialized usages after many conditionals (#4930) 2023-04-04 21:55:09 +02:00
Paul Fultz II 634f5e254f
Fix 11512: FN containerOutOfBounds when empty vector is returned (#4928) 2023-04-02 11:58:04 +02:00
Daniel Marjamäki 2359b9ff82 valueflow: limit valueflow in functions that have many ifs 2023-04-01 20:58:15 +02:00
Paul Fultz II 7231d1cece
Update the isVariableChanged to correctly check the const bit (#4912) 2023-03-26 15:12:49 +02:00
Paul Fultz II fd8a7b9537
ValueFlow: Evaluate if statement for function returns (#4908) 2023-03-24 13:31:26 +01:00
Paul Fultz II cd21f55cdf
Fix 11630 and 11620 lifetime issues (#4913) 2023-03-24 13:29:43 +01:00
Paul Fultz II e1a4a18528
Fix 11609: False positive: Returning iterator to local container 'k' that will be invalid when returning where 'k' is an iterator. (#4907) 2023-03-21 23:18:01 +01:00
chrchr-github 716fcc5e96
Fix crash in valueFlowForwardLifetime() (#4891) 2023-03-18 14:53:49 +01:00
chrchr-github 3ccd0505cd
Enable and mitigate readability-simplify-boolean-expr (#4897) 2023-03-17 13:51:55 +01:00
Paul Fultz II 8324caf8b9
Fix 11557: FP derefInvalidIteratorRedundantCheck in and/or condition (#4892) 2023-03-16 15:00:27 +01:00
Paul Fultz II 61e8b84578
Fix 11610: false negative: knownConditionTrueFalse with address of variable (#4883) 2023-03-12 19:57:11 +01:00
Mateusz Michalak 2d5cabed4b
Add std::*begin and std::*end cfg (#4796) 2023-03-09 17:06:53 +01:00
Oliver Stöneberg 00fd3d92c6
made `ForwardTraversal::mSettings` and `ReverseTraversal::mSettings` references / adjusted some calling code to use references as well (#4858) 2023-03-07 12:26:17 +01:00
Oliver Stöneberg 20db3ff368
SymbolDatabase: made `mTokenizer` and `mSettings` references (#4857) 2023-03-07 12:22:06 +01:00
Oliver Stöneberg 5af6ca6637
made `Platform` a member of `Settings` instead of inheriting from it / cleanups (#4791) 2023-03-03 18:36:27 +01:00
Oliver Stöneberg 8023eff7c0
removed `TokenList::getSettings()` and replaced usage in ValueFlow with provided settings (#4843) 2023-03-03 18:31:38 +01:00
Oliver Stöneberg b70e1d5461
avoid some unchecked pointer dereferences (#4811) 2023-03-02 22:05:41 +01:00
Oliver Stöneberg bd1ae69b00
cleaned up includes based on `include-what-you-use` (#4599) 2023-03-02 21:50:14 +01:00
Oliver Stöneberg dac578e8b9
ValueFlow: avoid unnecessary `Value` copies (#4835) 2023-03-02 21:46:23 +01:00
chrchr-github 491299048b
Amend fix for #11449 Function call not recognized (#4838) 2023-03-02 21:45:15 +01:00
Oliver Stöneberg e99d7c6531
fixed some `-Wdeprecated-copy-dtor` Clang compiler warnings (#4836) 2023-03-02 21:02:29 +01:00
Daniel Marjamäki e5a22e3436 Revert "improved `Path` handling of mixed separators (#4808)"
This reverts commit 0797867758.
2023-02-24 06:21:02 +01:00
chrchr-github 96887c8130
Fix #11561 FN nullPointer with unnamed parameter (#4805) 2023-02-23 22:56:03 +01:00
Oliver Stöneberg 0797867758
improved `Path` handling of mixed separators (#4808) 2023-02-23 22:34:05 +01:00
Paul Fultz II 346ecdb53a
Improve valueflow after pushing to container (#4803) 2023-02-23 18:05:31 +01:00
Paul Fultz II 91d2526c41
Fix reverse analysis when modifying variable with function (#4800) 2023-02-23 18:04:16 +01:00
Mateusz Michalak 9b62caf0ef
Fix FP#11508 (#4774)
* Add tests to cover the issue

* Set lifetime of pointer to data passed as view to SubFunction

* Move isContainerOfPointers to separate function

* Revert "Set lifetime of pointer to data passed as view to SubFunction"

This reverts commit 30dafe23e40354606776d2573653608025cae754.

* Skip propagating lifetime of iterators/pointers for views

* Add indents to test cases

* Skip all non-local values in container view lifetime
2023-02-18 17:38:51 +01:00
chrchr-github ff0eee4d77
Fix #11558 FP knownConditionTrueFalse when checking for zero character (#4794)
* Fix #11558 FP knownConditionTrueFalse when checking for zero characte

* Fix test

* Set impossible value only for non-Boolean conditions, rename

* Fix condition
2023-02-18 17:35:12 +01:00
Paul Fultz II 2b9af94b9a
Fix 11548: FP knownConditionTrueFalse with empty() == false (#4788)
* Fix 11548: FP knownConditionTrueFalse with empty() == false

* Format

* Fix test
2023-02-11 10:42:13 +01:00
Oliver Stöneberg f7a415dbf3
Token: do not return non-`const` pointer from `const` methods - part 1 (#4761) 2023-02-08 21:07:16 +01:00
chrchr-github 4f915499d4
Fix #11091 FP: Using object that is a temporary (#4754) 2023-02-06 22:04:27 +01:00
Oliver Stöneberg afd13ea11d
ValueFlow: some interface and namespace cleanups (#4746) 2023-01-28 10:20:47 +01:00
Daniel Marjamäki 464fbe8d53 Update copyright year 2023-01-28 10:16:34 +01:00
Oliver Stöneberg bea6aec2b2
extracted `ValueFlow::Value` to `vfvalue.{cpp|h}` (#4642) 2023-01-26 22:23:22 +01:00
chrchr-github 3076f9def1
Fix #11449 Function call not recognized with extra parentheses / FP nullPointer (#4703) 2023-01-18 20:38:37 +01:00
Armin Müller a77f0d9403
Typos found by running "codespell" (#4702) 2023-01-10 15:15:27 +01:00
Paul Fultz II cefc105c5f
Fix 11468: false positive danglingTempReference warning (#4679) 2023-01-07 23:44:22 +01:00
Paul Fultz II 6020feb271
Fix 11461: arrayIndexOutOfBounds false positive (#4686) 2023-01-07 22:09:17 +01:00
Paul Fultz II a338be4682
Add source traces when using LifetimeStore (#4678) 2023-01-03 22:02:48 +01:00
chrchr-github 11f1a9d1f5
Fix crash on ternary with omitted operand (#4673)
* Fix MSVC compiler warning

* Fix crash on incomplete ternary operator

* Revert "Fix crash on incomplete ternary operator"

This reverts commit 28df0f0ab6ff794e733617447f847a97c1a7a609.

* Handle ternary with omitted operand
2023-01-02 17:44:17 +01:00
Oliver Stöneberg 71cdacdc97
fixed missing location for `valueFlowMaxIterations` debug warning / also added it to daca server overview (#4664) 2022-12-30 21:20:00 +01:00
Oliver Stöneberg 1cfe49e340
use `const_iterator` where possible (#4662) 2022-12-30 15:13:47 +01:00
Oliver Stöneberg b380fd2589
added command-line option `--valueflow-max-iterations` to control amount of valueflow iterations / also log debug warning when iterations are being exceeded (#4557) 2022-12-20 20:51:08 +01:00
Oliver Stöneberg 3c68b9b29f
use `cbegin()` and `cend()` with `const_ierator` loops (#4658) 2022-12-20 20:32:16 +01:00
Paul Fultz II 9da574f4a0
Fix 11227: ValueFlow: Known value not set in condition for ternary operator (#4653)
* Evaluate args before function call

* Fix tests

* Format

* Add test for 11227

* Format

* Fix known condition
2022-12-18 22:07:43 +01:00
Oliver Stöneberg dc5c5de10e
avoid some unnecessary copies (#4589) 2022-12-18 19:38:29 +01:00
chrchr-github b1abaf8809
Fix FP useStlAlgorithm (don't suggest std::accumulate when nothing is accumulated) (#4647) 2022-12-18 16:52:04 +01:00
Daniel Marjamäki 7799f820a3 Refactoring: Use static for local function getMinMaxValues 2022-12-17 21:21:18 +01:00
Paul Fultz II e2f398f81a
Fix 11250: FN: bufferAccessOutOfBounds (comma operator: int x = (3,4) ) (#4636)
* Fix 11250: FN: bufferAccessOutOfBounds (comma operator: int x = (3,4) )

* Format
2022-12-13 07:52:58 +01:00
Paul Fultz II b4d455df48
Fix 11349: FP negativeIndex for clamped array index (#4627)
* Fix 11349: FP negativeIndex for clamped array index

* Format

* Use emplace_back

* Use default constructor
2022-12-13 07:50:01 +01:00
Paul Fultz II 3f88744851
Fix 11358: FP containerOutOfBounds for container passed by pointer (#4626) 2022-12-09 19:43:21 +01:00
Paul Fultz II 6eccb2e36c
Throw internal error when tokens are not in order (#4623)
* Throw internal error when tokens are not in order

* Add semicolon
2022-12-09 07:17:16 +01:00
Paul Fultz II 7acbb656f3
Fix 11412: False positive: uninitvar (#4624)
* Dont remove modified variables from dead code

* Add test for 11412

* Format
2022-12-09 07:15:47 +01:00
Paul Fultz II c150317f02
Fix 11384: FP knownConditionTrueFalse when variable is modified in return statement (#4625)
* Fix 11384: FP knownConditionTrueFalse when variable is modified in return statement

* Format
2022-12-09 07:15:15 +01:00
Paul Fultz II 0cb742701d
Fix 11415: FP containerOutOfBounds for container initialized in virtual method (#4622) 2022-12-08 20:10:58 +01:00
chrchr-github 04b7c0c200
Fix #11404 FP knownConditionTrueFalse with iterator (#4619)
* Fix wrong value set in valueFlowSameExpressions()

* Fix  #11404 FP knownConditionTrueFalse with iterator
2022-12-08 10:40:55 +01:00
chrchr-github 7d6683fb78
Fix #11417 FP knownConditionTrueFalse with container and brace init (#4606)
* Fix #11417 FP knownConditionTrueFalse with container and brace init

* Format

* Format

* Move to getInitListSize()
2022-12-02 22:07:08 +01:00
chrchr-github 3273e51fd5
Fix #10412 FN useStlAlgorithm with iterators (#4157) 2022-10-16 13:46:26 +02:00
chrchr-github 6c24d2b865
Fix #11321 FP uninitvar for in-class member initialization (#4547) 2022-10-14 19:48:27 +02:00
Daniel Marjamäki ca32cf11ba Fix handling of --performance-valueflow-max-time=T 2022-10-04 20:01:19 +02:00
Daniel Marjamäki 8686997292 Add experimental option --performance-valueflow-max-time=T 2022-10-04 14:02:55 +02:00
Oliver Stöneberg cff1cd9cda
applied clang-tidy `misc-const-correctness` fixes for POD types, iterators and references (#4529)
* applied `misc-const-correctness` fixes for POD types and iterators

* applied `misc-const-correctness` fixes for references
2022-10-02 07:12:40 +02:00