Commit Graph

12793 Commits

Author SHA1 Message Date
Oliver Stöneberg a17f6e89d1
pass `Suppressions` separately from `const Settings` into executors (#5278) 2023-08-07 18:39:57 +02:00
chrchr-github 73251544a4
Fix #11842 FN constParameterPointer with library function (#5257) 2023-08-05 18:48:43 +02:00
Samuel Poláček b2511fb3ae
Check if --cppcheck-build-dir exists (#5254)
Cppcheck does not report that cppcheck build dir does not exist and also
does not report any write issues to the non-existent directory.

This means that cppcheck build dir is actually not used.

We should either create the directory or fail.
2023-08-04 17:38:43 +02:00
Oliver Stöneberg 5d201c4e87
testrunner: use structs with designated initialization to pass options (#4975)
I need to add parameters to some `check()` functions in the tests and
things are already pretty messy with having to specify all the default
values - readability aside.

I found this on https://stackoverflow.com/a/49572324/532627 - apparently
the CC BY-SA license by StackOverflow allows the usage within GPL.
2023-08-04 13:56:18 +02:00
chrchr-github 5ff8955dbe
Fix #11862 FP truncLongCastAssignment with increment (#5290) 2023-08-03 13:49:11 +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
Paul Fultz II 389e446dc0
Fix 11848: Assert failure in getParentValueTypes() (#5274) 2023-08-02 10:29:19 +02:00
chrchr-github 931a59a724
Fix FN variableScope (#5273)
Co-authored-by: chrchr-github <chrchr@github>
2023-08-01 23:56:24 +02:00
chrchr-github bfaa7c075a
Fix #11845 FP variableScope if buffer is passed to a conditionally called function (#5265)
Co-authored-by: chrchr-github <chrchr@github>
2023-07-27 22:18:34 +02:00
chrchr-github 99f7f88f39
Fix FN constParameterPointer (#5270)
Co-authored-by: chrchr-github <chrchr@github>
2023-07-27 20:54:12 +02:00
Tobias f10851dc37
posix.cfg: erand48/nrand48/jrand48 fixed argument direction (#5253) 2023-07-27 07:50:46 +02:00
chrchr-github 2cf4b3a6f3
Fix functionConst TODO (#5261) 2023-07-24 16:26:23 +02:00
chrchr-github 101ddea1e6
Fix #11840 FP constStatement with template parameters on operator (#5258) 2023-07-21 17:33:18 +02:00
chrchr-github a6b0129725
Fix #11838 FP uninitvar with label matching variable name (#5251) 2023-07-20 10:45:44 +02:00
chrchr-github d2546d5252
Fix #11788 False positive: unreadVariable in else (#5248) 2023-07-18 21:11:03 +02:00
chrchr-github 2878c68ec0
Fix FP unknownMacro (#5249) 2023-07-18 12:16:54 +02:00
Paul Fultz II 92caa835b6
Fix 11806: FP uninitvar for reference to unitvar in ternary ?: operator (#5247) 2023-07-17 10:34:54 +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 72212331fb
Fix #11832 False positive: uninitialized variable '*(&var) = 0' (#5241) 2023-07-14 19:14:33 +02:00
chrchr-github a4a29bfbc5
Fix #11411 FP selfInitialization after initialization of previous member from initializer list (#5239) 2023-07-14 10:33:05 +02:00
chrchr-github 48dd4dc33e
Fix #11831 FP negativeContainerIndex / wrong return value from virtual function (#5240) 2023-07-13 20:38:47 +02:00
chrchr-github 258581ce2e
Fix FP uselessOverride with macro (#5238) 2023-07-13 12:18:29 +02:00
chrchr-github c0bd9f8bbd
Fix #11827 FP duplInheritedMember - different return type (#5231) 2023-07-12 15:56:07 +02:00
chrchr-github 709fec88f9
Revert "Fix #11765 FN: minsize not checked for string literal, buffer… (#5235)
… access out of bounds not found (#5154)"

This reverts commit 9ad18f51af.
2023-07-11 22:19:01 +02:00
chrchr-github 8d3fd88d3f
Fix #11802 FP stlcstr for string in shared_ptr copied elsewhere (#5230) 2023-07-10 15:27:33 +02:00
chrchr-github 9ad18f51af
Fix #11765 FN: minsize not checked for string literal, buffer access out of bounds not found (#5154) 2023-07-08 14:46:32 +02:00
chrchr-github 49b79b7674
Extend duplInheritedMember check to functions (#5226) 2023-07-08 12:05:19 +02:00
chrchr-github 218650dc85
Fix #11820 FP duplicateExpression with double negation (#5227) 2023-07-07 23:30:59 +02:00
chrchr-github d6d3c7b3fc
Fix #11139, #11817 FP unreadVariable (#5221) 2023-07-07 20:18:15 +02:00
chrchr-github e73183a182
Fix FP uselessOverride with shadowed member functions (#5225)
We should probably use `getDuplInheritedMemberFunctionsRecursive()` as
part of the `duplInheritedMember` check.
2023-07-07 20:17:58 +02:00
chrchr-github cc38ef4168
Fix #11818 FP constParameterReference / #11819 FP stlcstrConstructor / #11814 FP unknownMacro (#5224) 2023-07-07 15:54:07 +02:00
chrchr-github c738627d15
Fix uselessOverride FPs (#5223) 2023-07-07 13:18:00 +02:00
chrchr-github fa03f49d2b
Fix #11810 nullptr deref in compilePrecedence2() (II) (#5222) 2023-07-07 10:42:11 +02:00
chrchr-github dde45455bf
uselessOverride: Detect code duplication in overriding function (#5219) 2023-07-05 22:58:01 +02:00
chrchr-github ee5cf0f141
Fix #11810 nullptr deref in compilePrecedence2() (#5218) 2023-07-05 22:34:25 +02:00
chrchr-github db49687ae5
Fix getOverriddenFunction(), add test (#5213) 2023-07-01 17:23:26 +02:00
chrchr-github b99931c59c
Fix #11808 FP uselessOverride - grandchildren calling grandfather (#5212) 2023-07-01 14:11:28 +02:00
Daniel Marjamäki 96955ccfe9
Tokenizer: detect unknown macro 'if (x) MACRO }' (#5209) 2023-07-01 13:17:41 +02:00
Paul Fultz II 59a8944e30
Fix 11656: FP: containerOutOfBounds std::array (#5210) 2023-07-01 09:43:57 +02:00
chrchr-github 6d9fa6f10a
Fix #11803 FP uselessOverride - overloaded virtual member function (#5211) 2023-06-30 15:21:08 +02:00
chrchr-github e9feeef81d
Fix FPs: uselessOverride (#5208) 2023-06-29 20:46:12 +02:00
chrchr-github a40e5817bf
Fix #11757 Detect useless overriding functions (#5155) 2023-06-29 07:43:35 +02:00
chrchr-github 818ebb8d7e
Fix autovarInvalidDeallocation regression (#5203) 2023-06-29 07:42:53 +02:00
Daniel Marjamäki 55af68aaf7
Update type for Settings::checksMaxTime. (#5205)
It's a time offset not a size. It should not have value SIZE_MAX that
makes it ineffective (overflow in calculation of stop time).
2023-06-28 19:52:33 +02:00
chrchr-github 4f71bbe986
Detect lambda with template argument (#5202) 2023-06-27 16:19:12 +02:00
chrchr-github 0a72cd3b72
Fix #11795 debug: simplifyUsing: unmatched body end (#5198) 2023-06-27 15:45:25 +02:00
chrchr-github e063656173
checkLibraryCheckType: handle global scope operator / Fix FN unreadVariable (#5199) 2023-06-27 14:28:14 +02:00
Paul Fultz II 63b7e6a283
Fix 11088: False positive: Array index out of bounds (function pointer parameter is array) (#5200) 2023-06-27 10:44:11 +02:00
chrchr-github a0c4e20e2d
Add tests for #10587, #11539 (#5197) 2023-06-26 13:37:33 +02:00
Anton Lindqvist 4ebb8eaf0c
Ignore zero valued enum entries from badBitmaskCheck (#5195)
Usage of zero valued enum entries can be used for documenting purposes
and should be ignored just like zeroes expanded from macros.
2023-06-26 10:43:20 +02:00
chrchr-github 7507d400de
Fix regression: wrong array size (#5194) 2023-06-26 06:51:01 +02:00
chrchr-github 9dc38f80c0
Fix #11790 FP functionConst with template function (#5187) 2023-06-25 20:38:54 +02:00
Paul Fultz II a2ee32695f
Fix 11530: FP arrayIndexOutOfBounds with array of functions (#5191) 2023-06-25 20:38:44 +02:00
Paul Fultz II 4f466a5961
Fix 11505: FP zerodivcond with modulo (#5192) 2023-06-25 20:38:32 +02:00
chrchr-github 9b892f3239
Partial fix for #11552 Handle lambda return types (#5188) 2023-06-25 12:01:59 +02:00
Paul Fultz II 60321edd0d
Fix 11784: FP arrayIndexOutOfBounds when increment is counted twice (#5186) 2023-06-24 20:08:55 +02:00
chrchr-github 6c750d9ae9
Fix #11789 FP knownConditionTrueFalse with std::vector::size() (#5184)
There is special handling for `size_t` in
`ValueType::fromLibraryType()`, which gets preempted if it is also
configured as a podtype.
2023-06-23 20:31:25 +02:00
chrchr-github 55581fc2e9
Fix FP deallocuse (#5183) 2023-06-23 18:21:53 +02:00
chrchr-github b80460f3ae
Fix #11786 False positive: memory leak (#5182) 2023-06-22 23:03:55 +02:00
chrchr-github fe56b0c42a
LeakAutoVar: Handle C++ casts in function calls (#5181) 2023-06-22 16:01:21 +02:00
chrchr-github 4eebf2e733
Fix uninitdata regression (#5179) 2023-06-21 21:19:22 +02:00
Daniel Marjamäki 3abe8eeca5 Update copyright year 2023-06-21 19:58:11 +02:00
chrchr-github 9a95d4fe67
Fix #11785 Syntax error: typedef not first keyword in statement (#5178) 2023-06-21 18:26:28 +02:00
chrchr-github b26bfc9b4f
Use getAllocFuncInfo() (#5176) 2023-06-21 17:35:15 +02:00
Daniel Marjamäki f2510228cb
Fix #10847 (FP: unusedStructMember) (#5177) 2023-06-20 22:34:54 +02:00
chrchr-github bb962e2bc3
Enable and mitigate readability-else-after-return (#5175) 2023-06-20 18:43:21 +02:00
chrchr-github f96e3c9d84
Fix #11766 FP uninitdata with cast (#5170) 2023-06-20 18:06:57 +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
chrchr-github 082331c210
Fix #11770 cppcheckError for unknown macro after else (#5163) 2023-06-17 18:39:23 +02:00
chrchr-github 8f6b0b41e7
Simplify qt.cfg, wxwidgets.cfg (#5166) 2023-06-17 17:04:14 +02:00
chrchr-github 53cab34484
Fix #11769 cppcheckError for function with lambda as default parameter (#5159) 2023-06-17 17:03:19 +02:00
orbitcowboy fd3befe60a
Added a regression test for FP #10681 uninitvar. (#5168)
Test case is from: https://trac.cppcheck.net/ticket/10681#comment:10
2023-06-17 15:45:28 +02:00
Paul Fultz II d6e3182441
Fix 11721: False positive: constParameterReference with overloaded template function (#5151) 2023-06-17 11:31:47 +02:00
chrchr-github 7075b6e61d
Fix #11763 internalAstError caused by parameter pack simplification (#5150) 2023-06-17 11:31:02 +02:00
Daniel Marjamäki 9a290c959f
Fix #11776 (False positive: uninitialized variable, struct array member initialized in function) (#5165) 2023-06-17 10:20:20 +02:00
chrchr-github 58dd92dd1b
Merge pull request #5152 from chrchr-github/chr_Fix11189
Partial fix for #11189 checkLibraryNoReturn with std::function parameter
2023-06-16 23:59:17 +02:00
chrchr-github 8761e6b8fc
Merge pull request #5148 from chrchr-github/chr_Fix11764
Fix #11764 checkLibraryFunction/NoReturn when inheriting from container
2023-06-16 23:33:08 +02:00
chrchr-github 62dfa8877c
Merge pull request #5147 from chrchr-github/chr_astregr
Fix AST regression
2023-06-16 22:47:47 +02:00
chrchr-github 3f0f9e4476
Merge pull request #5158 from chrchr-github/chr_Fix11770
Partial fix for #11770 cppcheckError with unknown macro
2023-06-16 22:40:56 +02:00
chrchr-github 75e0bdfdd9
Merge pull request #5164 from chrchr-github/chr_Fix11768
Fix #11768 FP autovarInvalidDeallocation
2023-06-16 22:40:27 +02:00
chrchr-github 1ffff8dc06
Fix #11772 top() on empty stack in TypedefSimplifier::replace() (#5161) 2023-06-16 19:35:01 +02:00
Daniel Marjamäki aca6c47024
Fix #11774 (False positive: passing struct pointer to function that initialize it) (#5162) 2023-06-16 18:43:32 +02:00
chrchr b41f9af2c5 Fix #11768 FP autovarInvalidDeallocation 2023-06-16 17:21:37 +02:00
chrchr c02a9f403a Fix tests 2023-06-15 19:22:19 +02:00
chrchr 39d60ca63e Add test 2023-06-15 18:53:42 +02:00
chrchr 19d4ab7d31 Fix test 2023-06-15 18:52:52 +02:00
chrchr 9579b4509d Partial fix for #11770 cppcheckError with unknown macro 2023-06-15 18:36:21 +02:00
Daniel Marjamäki f934d6e5d0
Fix #11767 (False positive: uninitialized member after assignment) (#5157) 2023-06-15 14:42:58 +02:00
Daniel Marjamäki d75331d00d
Fix #11435 (FP ctuOneDefinitionRuleViolation for template specialization) (#5156) 2023-06-15 11:43:07 +02:00
Daniel Marjamäki 9339802be3
Fix #11740 (FP syntaxError from switch in C code) (#5153) 2023-06-14 10:41:37 +02:00
chrchr-github 457e0ce0c8 Partial fix for #11189 checkLibraryNoReturn with std::function parameter 2023-06-13 21:48:16 +02:00
chrchr 0afc5aba78 Fix #11764 checkLibraryFunction/NoReturn when inheriting from container 2023-06-13 15:04:25 +02:00
chrchr fad1f6b559 Fix AST regression 2023-06-13 14:32:31 +02:00
Anton Lindqvist 09cd3a8269
Fix FP deallocuse regression (#5144)
Introduced in commit 69116c838 ("Fix #11758 Regression: memleak / Fix #11746 FN:
deallocuse (#5139)").
2023-06-11 14:11:41 +02:00
Daniel Marjamäki f6a65afdee
Fix FP uninitStructMember when other variable is only nonzero if struct member is initialized (#5143) 2023-06-10 21:35:17 +02:00
Daniel Marjamäki 7840bc4c63 Execute runformat 2023-06-10 17:37:32 +02:00
chrchr-github 24b0d08753
Fix FP autoVariables (#5107)
* Fix #11732 FP autoVariables when reassigning argv

* Fix #11732 FN autoVariables with array and std::string

* Add test

* Format

* Format

* Simplify check, fix inconclusive

* Fix merge, add test

* Fix FPs

* Format

* Format

* Undo move

* Format
2023-06-10 16:28:29 +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 7e0f64688f
Fix #11275 internalAstError on C++20 templated lambda / Fix #11400 internalAstError on nested lambda (#5134)
* Fix #11275 internalAstError on C++20 templated lambda

* Fix #11400 internalAstError on nested lambda passed as argument
2023-06-10 07:42:10 +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 69116c8386
Fix #11758 Regression: memleak / Fix #11746 FN: deallocuse (#5139)
* Fix #11758 Regression: memleak

* Format

* Fix #11746 FN: deallocuse

* Complete the trifecta
2023-06-10 00:24:36 +02:00
Daniel Marjamäki 22e67d3534
Fixed #10442 (AST: wrong ast of ({}) in struct initialization) (#5135) 2023-06-09 22:31:14 +02:00
orbitcowboy 6ea88c2758
Added test case from #8302 (#5138)
* Added test case from #8302 and a TODO

* Check with in C++ mode to get rid of TODO.

* Updated expected error message text

* Updated expected error message text
2023-06-09 21:46:45 +02:00
chrchr-github bd6c5318ad
Detect container action and yield functions (#5117)
* Detect container action and yield functions

* Fix test

* Adapt getUseRetValType() to handle container yield functions
Add TODO

* Handle combined action/yield

* Add Yield::BUFFER

* Remove redundant functions

* Revert "Remove redundant functions"

This reverts commit 4f124a57de5c761ac757ebed83d9f047ef4a1328.

* Add Yield::AT_INDEX

* Add Yield::ITERATOR

* Simplify
2023-06-09 16:03:47 +02:00
Carl Morgan 6741f774b1
Support integer Z suffix and user defined literals with _ suffix (#10807, #11438) (#5130)
Co-authored-by: Carl Morgan <no-reply@crown.com>
2023-06-08 20:03:41 +02:00
chrchr-github be2824b003
Fix FN deallocuse with array access (#5121)
* Fix FN deallocuse with array access

* Fix another FN

* Undo
2023-06-08 07:55:49 +02:00
chrchr-github 901b775471
Fix scope for function returning rvalue reference, insert std:: in return statement (#5119)
* Fix scope for function returning rvalue reference

* Insert std:: in return statement

* Fix failing test
2023-06-08 07:47:21 +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 3ff8ce316c
Fix AST for parameter pack (#10199, #10492, #11103) (#5125)
* Fix AST for parameter pack (#10199, #10492, #11103)

* Skip ... after )
2023-06-07 20:46:14 +02:00
chrchr-github ec4267a2bd
Don't suggest const for smartptr::get() (#5126)
* Don't suggest const for smartptr::get()

* Fix test

* Fix merge

* get() doesn't change a smartpointer

* Parentheses
2023-06-07 20:45:48 +02:00
chrchr-github 12fe652321
Fix #11063 FP unreadVariable with extra parentheses and scope operator (#5122) 2023-06-07 20:45:27 +02:00
chrchr-github 39f958bcfb
Fix #11596 FP uninitvar with array of function pointers (#5098) 2023-06-07 11:41:22 +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
SChernykh 93595aeff0
Fixed `std::vector::data` return type (#5116)
This caused many `arithOperationsOnVoidPointer` false positives in my project which uses `std::vector<uint8_t>` in many places.
2023-06-05 20:47:42 +02:00
Daniel Marjamäki 5976faaaf5
Fixed #11745 (Fix AST for 'new type..[..]{..}') (#5118) 2023-06-05 20:43:17 +02:00
chrchr-github 18b60d2f2b
Fix #11670 FP constStatement (inconclusive) triggered by namespace (#5114) 2023-06-03 15:13:15 +02:00
chrchr-github f2976e5bb5
std.cfg: add support for smartptr member functions (#5113)
* std.cfg: add support for smartptr member functions

* Fix test

* Fix
2023-06-03 14:36:30 +02:00
chrchr-github 1b98be458d
Fix #11739 Assert failure in valueflow.cpp / setSymbolic() (#5104) 2023-06-03 11:08:06 +02:00
chrchr-github 82e9c076da
Fix #11744 FN functionConst/functionStatic with recursion (#5105)
* Fix FN functionStatic

* Fix FN functionConst, add test

* Fix build
2023-06-02 23:33:42 +02:00
chrchr-github 055489df5a
Fix #11742 Can't reduce scope as variable references itself (#5112) 2023-06-02 23:33:17 +02:00
chrchr-github 7c56514bd5
Fix #9104 reopened Improve check: missing virtual destructor (#5110)
* Fix #9104 reopened Improve check: missing virtual destructor

* Add support for missing container members

* Add more stuff

* Improve qt.cfg

* Improve wxwidgets.cfg, qt.cfg
2023-06-02 15:24:18 +02:00
chrchr-github 52c0f10fa1
Fix FP mismatchAllocDealloc, uninitdata for new with initializer (#5106) 2023-06-02 13:01:55 +02:00
orbitcowboy 9810bad869
#9708 (doublefree) - Added a regression test (#5109) 2023-06-02 10:32:33 +02:00
chrchr-github 238cf75f6f
Fix #11732 FN autoVariables with array and std::string (#5096)
* Fix #11732 FP autoVariables when reassigning argv

* Fix #11732 FN autoVariables with array and std::string

* Add test

* Format

* Format
2023-05-31 20:55:55 +02:00
chrchr-github 0b44429a7c
Fix spurious lambda detection (#5101) 2023-05-31 20:55:39 +02:00
chrchr-github a91222fad8
Partial fix for #11637 FN functionConst (#5102)
* Partial fix for #11637 FN functionConst

* Redundant check
2023-05-31 20:55:12 +02:00
chrchr-github 0ecf101fe3
Fix #11547 FN stlcstrConstructor, stlcstrAssignment with std::stringview (#5097)
* Fix #11547 FN stlcstrParam with std::string_view

* Add suppression

* Use emplace()

* Fix #11547 FN stlcstrConstructor, stlcstrAssignment with std::string_view
2023-05-31 16:51:37 +02:00
chrchr-github 7696bd1357
Fix #11225 FN constParameter with cast (#5100)
* Fix #11225 FN constParameter with cast

* Add const
2023-05-31 16:51:03 +02:00
chrchr-github ec2f00d7c2
Fix #1175 uninitialized data: casted to 'int *' and dereferenced (#5008) 2023-05-29 15:29:53 +02:00
chrchr-github cf4334904c
Fix #11626 FN functionConst with non-dereferenceable pointer access (#5074)
* Partial fix for #11626 FN functionConst with non-dereferenceable pointer access

* Fix #11626 FN functionConst with non-dereferenceable pointer access

* Fix test
2023-05-28 19:42:47 +02:00
chrchr-github 4c1e06a84b
Fix #8174 Regression: false negative autovarInvalidDeallocation since 1.79 (#5045) 2023-05-28 14:34:07 +02:00
chrchr-github 774123d28d
Remove hardcoded lists of functions/templates/types (#5069)
* Remove hardcoded list of functions

* Remove hardcoded list of templates

* Remove hardcoded list of types

* Format

* Fix test

* Unused variable

* Add tests

* auto -> int
2023-05-28 14:33:41 +02:00
chrchr-github ac41b45a5f
Fix #11729 danglingLifetime of static variable (#5080) 2023-05-28 14:33:12 +02:00
chrchr-github 163fb79de1
Fix #11732 FP autoVariables when reassigning argv (#5084) 2023-05-28 13:51:41 +02:00
chrchr-github 647432580f
Fix #11720 FN functionConst when using base class members (#5068)
* Fix #11720 FN functionConst when using base class members

* Format

* Add const

* Add const

* Improve const check for arguments, comments, tests

* Add test for #11573

* Add test for #11501

* Fix merge

* Add tests

* Use ASSERT_EQUALS

* Redundant check
2023-05-28 01:11:59 +02:00
chrchr-github 17789778c9
Fix #11547 FN stlcstrParam with std::string_view (#5093)
* Fix #11547 FN stlcstrParam with std::string_view

* Add suppression

* Use emplace()
2023-05-28 01:11:11 +02:00
Daniel Marjamäki 6b9fac41f4
Fixed #11734 (stylistic warnings from addons are not filtered when style is not enabled) (#5091) 2023-05-27 10:24:00 +02:00
Anton Lindqvist 96c6276ce7
Suppress unused struct members from types expanded from macros (#5087) 2023-05-26 17:48:49 +02:00
chrchr-github 10b55cc0cf
Fix #11654 FN functionConst if only non-const member usage is call to itself (#5092)
* Fix #11654 FN functionConst if only non-const member usage is call to itself

* Format

* Add const
2023-05-26 17:24:13 +02:00
Anton Lindqvist 3d6c453058
Fix uninitvar false positive in designed initializers (#5079)
Stop interpreting struct fields in designed initializers as usage of local
variables which can happen if they share the same name.

```
$ cat test.c
struct a { int b; };
int main() {
  char *b;
  extern int foo(struct a *);
  return foo(&(struct a){.b = 0});
}
$ cppcheck --quiet test.c
test.c:5:27: error: Uninitialized variable: b [legacyUninitvar]
  return foo(&(struct a){.b = 0});
```
2023-05-26 11:59:10 +02:00
chrchr-github fb850a844b
Use path to executable when trying to load library (#5082)
* Use path to executable when trying to load library

* Fix function call, add support for more OS, add test

* Format

* Handle MacOS

* Amend

* Argument as fallback

* Use Path::getCurrentExecutablePath()

* Move to cmdlineparser.cpp

* Debug output

* Use argv[0] in Cygwin

* Revert "Debug output"

This reverts commit 5a68d71f1d27549c7b4a46363f3cd5cd912018e7.

* Use native python in Cygwin
2023-05-26 06:55:36 +02:00
chrchr-github bc03bed075
#11733 FP unusedFunction with templates and --cppcheck-build-dir (#5085)
* #11733 FP unusedFunction with templates and --cppcheck-build-dir

* Add test
2023-05-26 06:13:48 +02:00
chrchr-github beea1a2345
Fix #11689 FP constStatement with nested typedefs (#5090)
* Fix #11689 FP constStatement with nested typedefs

* Add test
2023-05-26 06:12:40 +02:00
Daniel Marjamäki 107eea236f
Improved handling of alignas. alignas will not be removed from now on so we don't loose this information. (#5081) 2023-05-24 10:33:53 +02:00
chrchr-github 94b6c87049
Fix #11728 FP unreadVariable with brace-init (#5075) 2023-05-23 20:21:02 +02:00
chrchr-github 6d2662b8a2
Fix #4400 FN (error) Memory leak - assignment to reference of a pointer (#5048)
* Fix #4400 false negative: (error) Memory leak - assignment to reference of a pointer

* Comment

* Run tests as C++

* Add TODOs

* Bail out for local references
2023-05-23 06:29:20 +02:00
chrchr-github 33f728df14
Fix #11725 Hang in simplifyTypedef() with extra parentheses (#5078)
* Fix  #11725 Hang in simplifyTypedef() with extra parentheses

* Amend test
2023-05-23 06:26:22 +02:00
chrchr-github 00733893e0
Fix #11726 "this->" confuses non void return check (#5073) 2023-05-22 20:23:09 +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 8eabf5c211
Fix #8433 FN unused variable not detected when there is lambda (#5060)
* Fix #8433 FN unused variable not detected when there is lambda

* Format

* Fix tests

* Check lambda return

* Add test

* Undo, add test

* simpleMatch()

* Rename test
2023-05-22 07:39:57 +02:00
chrchr-github e621f721fc
Use library to get deallocation function (#5061)
* Use library to get deallocation function

* Add suppressions

* Amend

* Remove suppression

* More getDeallocFuncInfo()

* Fix suppressions

* Fix suppression
2023-05-21 14:01:14 +02:00
chrchr-github d30f8e18f7
Partial fix for #11626 FN functionConst with non-dereferenceable pointer access (#5070) 2023-05-21 14:00:24 +02:00
chrchr-github ba57e15cb2
Fix #11717 Warn when C++ code is scanned as C (prevent FPs) (#5064)
* Fix #11717 Warn when C++ code is scanned as C (prevent FPs)

* Don't throw for operators

* Detect reference variables

* Fix tests

* Fix compilation

* Fix test

* Fix another test

* Use strAt()
2023-05-21 13:59:49 +02:00
Daniel Marjamäki f72db74817
Fixed #11013 (FP overlappingWriteUnion with anonymous struct in union) (#5067) 2023-05-20 10:34:42 +02:00
chrchr-github e6576dd949
Fix #11708 internal error: converting '1f' to integer failed (#5066)
* Fix #11708 "internal error: converting '1f' to integer failed - not an integer" with width in printf format string

* Format
2023-05-18 23:26:56 +02:00
chrchr-github 518b6a27ab
Fix #11719 Handle lambdas in global scope (#5065)
* Fix #11719 Handle lambdas in global scope

* Capture list
2023-05-17 14:37:56 +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
Daniel Marjamäki d475591665
Tokenizer: simplification of typedefs in _Generic arguments (#5059) 2023-05-14 15:14:52 +02:00
Daniel Marjamäki 793d6aef01
Tokenizer: do not report unknownMacro for alignas (#5058) 2023-05-14 15:14:41 +02:00
chrchr-github cf4d59a835
Partial fix for #9602 False positives with function pointers (#5042)
* Partial fix for #9602 False positives with function pointers

* Add test for #9222
2023-05-14 12:16:17 +02:00
chrchr-github 096d3a78b0
Fix #10596 FN uninitdata with value initialization (#5056)
* Assign values to pointers with C++11 init

* Handle assigning empty init list

* Fix #10596 FN uninitdata with value initialization

* Fix test
2023-05-13 22:07:09 +02:00
chrchr-github 6a8c70c1b9
Fix #10976 false negative: autoVariables [inconclusive] (regression) (#5044)
* Fix #10976 false negative: autoVariables [inconclusive] (regression)

* Use link()

* Use linkAt()

* Skip over [][]
2023-05-13 14:11:01 +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
Daniel Marjamäki 2b74a2084e
Fixed #11716 (simplifyTypedef: function with const should be handled better) (#5054) 2023-05-12 20:39:08 +02:00
chrchr-github 2a0143c8e1
Fix #10358 Bad ValueFlow depending on initialization (#5052) 2023-05-12 07:19:44 +02:00
chrchr-github f5b1537ed1
Fix internalASTError with decltype() (#5047) 2023-05-11 14:35:23 +02:00
Daniel Marjamäki d5951fa2b9
Tokenizer: Add attribute for exported symbols (#5043) 2023-05-09 20:15:00 +02:00
Daniel Marjamäki d24a1342a6
Fixed #11711 (Tokenizer: varId not set properly in function call) (#5041) 2023-05-08 12:11:30 +02:00
Daniel Marjamäki e8233ceb67 runformat 2023-05-08 10:30:20 +02:00
Paul Fultz II 543b4adc8a
Fix 11682: False positive: constParameterReference with overloaded method (#5038)
* Fix 11682: False positive: constParameterReference with overloaded method

* Format
2023-05-05 11:27:15 +02:00
chrchr-github 1db510b9fd
Add test for #10796 (#5036) 2023-05-04 22:23:36 +02:00
chrchr-github a31c996a70
Add tests for #11075, #11382 (#5035) 2023-05-04 20:35:56 +02:00
Oliver Stöneberg a77ab9759c
Suppressions: some cleanups (#4980)
* Suppressions: merged `isSuppressedLocal()` into `isSuppressed()`

* avoid some unnecessary copies when adding suppressions

* TestSuppressions: improved readability of multiple line string literals

* supressions.h: got rid of unnecessary copy and assignment operators for `Suppressions::Suppression` - fixes `performance-move-const-arg` clang-tidy warning

* TestSuppressions: cleaned up a variable construction
2023-05-04 18:15:18 +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
Oliver Stöneberg e6ae312a0b
moved more code into `HAVE_RULES` (#4956)
* moved more code into `HAVE_RULES`

* properly enable all internal and rules code in selfcheck

* updated TODOs in selfcheck

* testrunner.vcxproj.filters: updated

* added missing `Debug-PCRE` and `Release-PCRE` configurations for `testrunner` Visual Studio project

* cppcheck.cpp: fixed `useStlAlgorithm` selfcheck warning
2023-05-04 10:54:19 +02:00
Oliver Stöneberg 5833fc3c19
testrunner: even more `SettingsBuilder` usage and `const` cleanups (#5030)
* moved some of the test-only `Library::loadxmldata()` calls into `test`

* testrunner: reduced need for backup/restore of settings
2023-05-04 10:31:05 +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
Oliver Stöneberg b5ce2c708b
SingleExecutor: process markup files after code when scanning projects (#4972)
* SingleExecutor: added TODOs

* test `SingleExecutor` with files and project

* SingleExecutor: process markup files after code when scanning project

* TestSingleExecutor: generate scoped files before calling executor

* CI-unixish.yml: added `--output-on-failure` to CTest call

* helpers.cpp: improved error reporting in `~ScopedFile()`

* use unique filenames in executor tests to avoid collisions

* fixed `functionStatic` selfcheck warnings
2023-05-03 17:32:28 +02:00
chrchr-github f04d47ac61
Fix remaining example from #11131 (#5029) 2023-05-03 16:24:56 +02:00
Daniel Marjamäki 46b9d4ec61
Fixed #11700 (Markup support is broken, unused function false positives) (#5025) 2023-05-03 11:19:13 +02:00
chrchr-github ec2a2ad41f
Partial fix for #11131 FN variableScope with const member functions (#5027) 2023-05-03 10:02:16 +02:00
chrchr-github 7e0ddd3669
Set function pointer for ::f (#5028) 2023-05-02 22:53:21 +02:00
Oliver Stöneberg 25183ff484
testrunner: more `SettingsBuilder` usage and `const` cleanups (#5026) 2023-05-02 15:54:19 +02:00
Oliver Stöneberg 2935c855c3
reduced usage of mutable `Settings` objects in tests (#4798) 2023-05-02 11:48:24 +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
Oliver Stöneberg 5a2c31a41c
CmdLineParser: pass suppressions separately from settings (#5023) 2023-04-30 20:56:54 +02:00
chrchr-github 269850a62d
Fix autoNoType with multiple auto variables (#5012) 2023-04-30 20:36:27 +02:00
Oliver Stöneberg 8cf6a22ea3
cleaned up includes based on `include-what-you-use` (#5021) 2023-04-30 07:33:19 +02:00
chrchr-github 51cba8162b
Fix #11489 Crash in TemplateSimplifier (#5020)
* Add test for #11489

* Fix #11489 Crash in TemplateSimplifier
2023-04-30 07:33:04 +02:00
chrchr-github 043f4fa621
Fix #11693 performance regression (hang) in 2.11dev (#5022) 2023-04-29 15:17:55 +02:00
Oliver Stöneberg b3016f01a1
fixed some CLion inspection warnings (#4688)
* fixed some CLion "Unused global declaration" warnings

* fixed some CLion "Not implemented function" warnings

* fixed some CLion "Unused struct" warnings

* added TODO

* removed unused parameter reported by CLion

* fixed some CLion "Unused macro" warnings

* fixed some CLion "Condition is always true" warnings and a CLion "The value is never used" warning
2023-04-28 16:02:41 +02:00
Oliver Stöneberg 6eae4e71f6
make sure executors are only used in the intended context / `TestSuppressions` cleanups (#4963)
* added asserts to make sure executors are only used in the intended context

* TestSuppressions: specify proper job counts in `checkSuppression*()`

* TestSuppressions: enabled all asserts in `runChecks()`

* TestSuppressions: removed unnecessary setting from `checkSuppression()`

* TestSuppressions: small cleanup in the way tests are called

* TestSuppressions: use `SingleExecutor`
2023-04-28 12:41:53 +02:00
chrchr-github 2b92351b49
Fix #11679 FP knownArgument with known return value (#5007)
* Fix #11679 FP knownArgument with known return value

* Add test for #11051
2023-04-28 08:27:48 +02:00
chrchr-github 5b4c95f229
Fix varid assigned to function (#4991) (#5013) 2023-04-28 08:27:07 +02:00
chrchr-github 9c184462ad
Fix #10720 Hang/Crash with big variadic template (#5018)
* Fix #10720 Hang/Crash with big variadic template

* Fix CI
2023-04-28 08:26:35 +02:00
chrchr-github 77717f73fd
Fix #11418 Crash in TemplateSimplifier::expandTemplate() (#5019) 2023-04-28 08:25:52 +02:00
chrchr-github 023e79b6c2
Fix #11459 uninitvar false positive (#5011)
* Fix #11459 uninitvar false positive

* Format
2023-04-25 21:01:44 +02:00
chrchr-github 9ea223b367
Fix #11309 debug: Scope::checkVariable found variable 'v' with varid 0 (#5006)
* Fix #11309 debug: Scope::checkVariable found variable 'v' with varid 0

* Format
2023-04-24 20:27:10 +02:00
Paul Fultz II 6820b70dd1
Fix 11636: FP nullPointer with uninstantiated template (#5004)
* Fix 11636: FP nullPointer with uninstantiated template

* Format
2023-04-23 14:40:03 +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
chrchr-github c5310fe8a2
Fix #8592 SymbolDatabase: better handling of 'using namespace' (#4974) 2023-04-22 10:23:12 +02:00
Oliver Stöneberg db955a13a9
moved test-only `Preprocessor::getcode()` out of `lib` (#4993) 2023-04-22 10:22:00 +02:00
chrchr-github 5c7914aaa6
Fix FN constParameterReference with std::array (#4999) 2023-04-21 20:33:06 +02:00
chrchr-github bda9f707cc
Fix typedef in enum class (#4998) 2023-04-21 18:58:44 +02:00
chrchr-github 6e5375f7b7
Add tests for #8075, #11608, #11635 (#4995)
* Add tests for #6925, #11042, #11494

* Format

* Add tests for # 6561, #6619, #7475,

* Add tests for #8075, #11608, #11635
2023-04-21 16:09:52 +02:00
chrchr-github 5a4e43760e
Handle auto * const (#4994)
* Handle auto as first token

* Set varid when initialized by function

* Fix TODO from #11444

* Fix function parsing

* Add parentheses

* Format

* Handle auto * const

* Fix test on different platforms

* simpleMatch

* simpleMatch
2023-04-21 14:19:28 +02:00
Oliver Stöneberg ad464c4feb
Preprocessor: relaxed dependency on `Suppressions` (#4983)
* Preprocessor: cleaned up `missingInclude()`

* Preprocessor: relaxed dependency on `Suppressions` / adjusted `TestPreProcessor::inline_suppression_for_missing_include()` which was not testing production behavior

* test/cli/test-other.py: added test for `missingInclude` and `missingIncludeSystem` inline suppressions

* fixed `constParameterReference` selfcheck warning
2023-04-21 10:14:34 +02:00
chrchr-github a4e224b65c
Handle auto as first token, set varid (#4991)
* Handle auto as first token

* Set varid when initialized by function

* Fix TODO from #11444

* Fix function parsing

* Add parentheses

* Format
2023-04-21 10:13:25 +02:00
chrchr-github e17af6d2d8
Report unknown macro (#4990) 2023-04-20 17:55:16 +02:00
chrchr-github 67a8ff0b27
Add tests for # 6561, #6619, #7475 (#4988)
* Add tests for #6925, #11042, #11494

* Format

* Add tests for # 6561, #6619, #7475,
2023-04-20 12:58:50 +02:00
chrchr-github bf3be95046
Fix #11453, #11490 internalAstError with templates (#4986)
* Fix #11490 internalAstError with unknown template in index expression

* Comment

* Fix #11490
2023-04-19 21:20:57 +02:00
chrchr-github 938ad990f5
Add tests for #6925, #11042, #11494 (#4987)
* Add tests for #6925, #11042, #11494

* Format
2023-04-19 21:19:45 +02:00
chrchr-github 31e714cded
Fix incorrect function assignment (#4977) 2023-04-19 06:53:47 +02:00
chrchr-github 35a46dfd00
Fix FN unusedStructMember with member functions, inheritance (#4978)
* Fix #551 Detect unused Private member variables

* Fix FN unusedStructMember when there are member functions

* Unused member

* Warn for unused private variables in base class

* Warn for private inheritance, add test
2023-04-18 22:30:08 +02:00
chrchr-github e70a888833
Fix constPointer FP #11674, TODOs (#4976)
* Fix constPointer TODOs

* Fix #11674 FP constParameterPointer when function signature is fixed

* Format
2023-04-18 20:36:14 +02:00
chrchr-github 29e2a7ed34
Fix #11640 internalAstError with typedef matching member function [regression] (#4981) 2023-04-18 18:38:16 +02:00
Paul Fultz II 6031bed5a2
Fix 11669: Assert failure in infer.cpp (#4982)
* Fix 11669: Assert failure in infer.cpp

* Format
2023-04-18 18:35:25 +02:00
tsteven4 4183336dc1
fix skipping of cpp attributes. (#4971)
* fix skipping of cpp attributes.

* fix simplifyCPPAttribute loop.

When the first token was the start of a c++ attribute on a function,
so that tok->previous() was nullptr at the bottom of the loop,
an extra token would be skipped.  This could result in the corresponding
function being omitted from the symbol table.

* fix alignas test failure, enhance cpp attr test.

* uncrustify.

* fix redundantNextPrevious

* delete redundant code.

* add some tokenizer tests for simplifyCPPAttribute.

* enhance noreturn symbol test.

The order of a noreturn attribute and another attribute used to
matter.  Test both orders.
2023-04-17 20:36:25 +02:00
chrchr-github c3002f1230
Fix #551 Detect unused Private member variables (#4973) 2023-04-17 20:34:39 +02:00
Oliver Stöneberg 9ad26f51e8
removed `CppCheck` dependency from `CppCheckExecutor::parseFromArgs()` (#4967)
* made `CppCheck::getErrorMessages()` static

* removed `CppCheck` dependency from `CppCheckExecutor::parseFromArgs()`
2023-04-16 13:54:21 +02:00
chrchr-github 87755e3bae
Fix autoNoType with function returning container, rvalue reference (#4926) 2023-04-12 22:10:10 +02:00
chrchr-github a0b59ff56a
Fix FN constVariableReference (#4949) 2023-04-11 14:00:40 +02:00
Paul Fultz II ac14fd218b
ValueFlow: Infer possible symbolic values (#4947) 2023-04-10 19:27:29 +02:00
chrchr-github 63151f3291
Fix crash in constPointer() (#4945) 2023-04-09 16:38:09 +02:00
Oliver Stöneberg f5e51eace7
do not use string-to-integer conversions without error handling (#4906) 2023-04-08 22:29:09 +02:00
Oliver Stöneberg cfca3a69a2
optimized template string substitutions a bit (#4840) 2023-04-08 22:19:52 +02:00
Oliver Stöneberg 1f2b49142e
extracted single job execution into `SingleExecutor` / improved testing / do not unconditionally apply colors to output (#4882)
* added `Settings::useSingleJob()` and use it instead of checking `jobs` or `jointSuppressionReport`

* extracted single job execution into `SingleExecutor`

* moved `reportStatus()` from `CppCheckExecutor` to Èxecutor

* TestSingleExecutor: improved tests

* added testing of markup extension handling in executors

* cleaned up includes based on `include-what-you-use`

* testsingleexecutor.cpp: suppress `performance-unnecessary-value-param` clang-tidy warnings

* ProcessExecutor: send color via pipe instead of applying it beforehand

* do not unconditionally apply colors to output / disable all colors in tests / adjusted tests for changed output behavior

* fixed precision loss in `Executor::reportStatus()`

* fixed `naming-varname` selfcheck warnings
2023-04-08 18:06:38 +02:00
Oliver Stöneberg 5be8eee943
iwyu.yml: use a distro which has the latest `include-what-you-use` / enabled Qt mappings / cleaned up includes (#4885) 2023-04-08 16:08:47 +02:00
Daniel Marjamäki 89a95ddc8f --performance-valueflow-max-if-count: review comments 2023-04-08 13:07:28 +02:00
Paul Fultz II 93b4de36cd
Update constVariable IDs for references and pointers (#4904) 2023-04-07 20:14:53 +02:00
Daniel Marjamäki f52c00c3a7 fixed CI. I remove dump files in cppcheck build dir after analysis. 2023-04-07 19:02:34 +02:00
chrchr-github 5524bb4e58
Fix #11634 Crash in TypedefSimplifier (#4938)
* Fix #11634 Crash in TypedefSimplifier

* Call function

* Format
2023-04-07 11:09:13 +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
chrchr-github 8043930a0f
Fix FN uninitMemberVar with std::array (#4935) 2023-04-06 18:45:12 +02:00
chrchr-github 1b00a0f06a
Fix #9279 Missing --check-library warning when memory leaks check assumes function is noreturn (#4937)
* Fix #9279 Missing --check-library warning when memory leaks check assumes function is noreturn

* Format

* Fix check, add tests

* Format
2023-04-06 18:44:03 +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
chrchr-github 0f47948bf4
Fix #11577 FN unusedStructMember when casting address (regression) (#4816) 2023-04-04 21:57:09 +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 d5e2ee411e
Fix 11578: FP accessMoved with range-based for loop (#4931)
* Fix 11578: FP accessMoved with range-based for loop

* Format
2023-04-03 19:44:47 +02:00
chrchr-github 86efca28a3
Fix crash in constPointer() (#4932)
* Fix crash in constPointer()

* Format
2023-04-03 19:44:08 +02:00
chrchr-github b2b0962067
Fix #11629 debug: Scope::checkVariable found variable 'np' with varid 0. (#4915) 2023-04-03 15:41:19 +02:00
chrchr-github a336048d14
Fix #11599 false negative: constParameter (#4902)
* Partial fix for #11599 false negative: constParameter

* Adjust test

* Update testother.cpp

* Update testother.cpp

* Fix #11599 false negative: constParameter

* Fix new warnings

* Format

* Add difference_type

* Remove isAliased()

* Undo

* Adjust test

* Add test

* Improve const check

* Tweak constness, add tests

* Add tests

* Use new helper function, fixtest

* Remove bailout, fix check for cast

* Prevent FP

* Fix constVariable check, add tests

* Format

* Format

* Add test for #11632
2023-04-02 20:36:23 +02:00
Paul Fultz II 634f5e254f
Fix 11512: FN containerOutOfBounds when empty vector is returned (#4928) 2023-04-02 11:58:04 +02:00
Oliver Stöneberg eb0998dc2c
testclass.cpp: fixed compilation (#4927) 2023-04-01 19:58:58 +02:00
chrchr-github 7503aca0e2
Fix #11621 FP functionConst when assigning init list (#4895)
* Fix #11621 FP functionConst when assigning init list

* Add comment

* Merge
2023-04-01 18:54:26 +02:00
ericLemanissier cf280f84d4
qt: fix Q_UNUSED macro defintion (#4925) 2023-04-01 16:33:50 +02:00
Oliver Stöneberg 5ec0ad6bed
use `ccache` for sanitizer builds / do not use precompiled headers with `ccache` (#4910)
* added CMake option `DISABLE_DMAKE` to disable `run-dmake` dependencies

* tools/CMakeLists.txt: added TODO

* use `ccache` for sanitizer builds

* aligned selfcheck between sanitizer workflows and disabled some currently unnecessary steps

* CI-unixish.yml: do not use precompiled headers with `ccache`
2023-04-01 09:40:10 +02:00
chrchr-github 01a22159b8
Fix autoNoType with std::begin() / function returning smart ptr (#4919)
* Fix autoNoType with std::begin()

* Suppress warning for const lambda

* Fix autoNoType with function returning smart ptr

* Handle more complex expression

* Fix scope with auto and smart ptr

* Handle smart pointers and iterators first
2023-04-01 09:38:40 +02:00
chrchr-github 89ec148199
Partial fix for #11638 Library::getFunctionName: SIGSEGV (#4920)
* Partial fix for #11638 Library::getFunctionName: SIGSEGV

* Fix test

* simpleMatch()
2023-03-30 07:25:26 +02:00
chrchr-github 4d72e0f5b5
Fix #11625 FP constVariable when returning by reference (#4921) 2023-03-30 07:24:36 +02:00
chrchr-github 3836367d95
Fix FN passedByValue with array access, range-based for (#4922)
* Fix FN passedByValue with array access, range-based for

* Format

* Fix/suppress new warnings
2023-03-30 07:24:23 +02:00
chrchr-github fc24f760cc
Fix #11627 Infinite loop in ReverseTraversal (#4916) 2023-03-30 07:22:41 +02:00
chrchr-github 13e12da08f
Fix #11639 findGarbageCode(): SIGSEGV (#4917) 2023-03-28 11:24:52 +02:00
chrchr-github 7bf6b359b1
Fix #11616 false negative: functionConst (#4887) 2023-03-27 17:54:19 +02:00
chrchr-github 5791561a45
Partial fix for #11543 checkLibraryFunction warning for smartpointer in container (#4900) 2023-03-27 17:50:33 +02:00
Daniel Marjamäki c79d859f8b Tokenizer::simplifyTypedef: new faster simplification.
It performs a more "lightweight" simplification of global typedefs that are not shadowed.

If a "heavy" simplification is needed that will be executed afterwards.
2023-03-26 17:16:45 +02:00
Oliver Stöneberg 03214c6c08
testnullpointer.cpp: restored TODO assert in `nullpointerStdStream` (#4914) 2023-03-26 16:18:44 +02:00
Oliver Stöneberg f002429a6b
testrunner: fail if `TODO_ASSERT_*` succeeds (#4911)
* testrunner: fail if TODO succeeds

* testnullpointer.cpp: removed TODO from assert in `nullpointerStdStream`
2023-03-26 15:13:07 +02:00
orbitcowboy 38f9c81dd2 Added regression test to #10602: FN nullptr 2023-03-24 20:29:33 +01: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
Paul Fultz II d4b030694b
Move some checks for variable changed from constVariable check to isVariableChanged (#4905) 2023-03-21 18:16:40 +01:00
chrchr-github 0d02c0a1a7
Fix #11624 FP uninitvar with array passed to function (#4903) 2023-03-20 19:54:31 +01:00
chrchr-github 6316479782
Fix FP unusedStructMember with std::map (#4899) 2023-03-20 19:40:57 +01:00
chrchr-github 3d965b5b81
Fix #11618 FP functionConst with call to static function (#4898) 2023-03-20 19:29:49 +01:00
chrchr-github 19eef2c584
Partial fix for #11599 false negative: constParameter (#4901) 2023-03-19 17:43:23 +01:00
chrchr-github 3b61ecd973
Fix FP missingOverride (#4894) 2023-03-18 16:39:45 +01:00
chrchr-github 716fcc5e96
Fix crash in valueFlowForwardLifetime() (#4891) 2023-03-18 14:53:49 +01:00
chrchr-github 319baf8d0f
No WRONG_DATA for function pointer with unknown return type (#4893) 2023-03-18 14:52:29 +01:00
orbitcowboy b2263d9475 #8499 Added regression test: (style) Condition 'i==0||i==1' is always true (for loop index) 2023-03-17 19:06:17 +01:00
Paul Fultz II 8324caf8b9
Fix 11557: FP derefInvalidIteratorRedundantCheck in and/or condition (#4892) 2023-03-16 15:00:27 +01:00
Daniel Marjamäki a4d2178f3c Fix ctuuninitvar false positive for struct that is partly initialized 2023-03-13 20:55:11 +01:00
chrchr-github 322a1a5e8c
Partial fix for #11378 internalAstError regressions (iscpp11init) (#4889) 2023-03-13 16:30:27 +01:00
chrchr-github a6c5bb28c1
Fix crash in LoopAnalyzer (#4888) 2023-03-13 15:44:34 +01:00
Paul Fultz II 61e8b84578
Fix 11610: false negative: knownConditionTrueFalse with address of variable (#4883) 2023-03-12 19:57:11 +01:00
chrchr-github a75392307f
Partial fix for #11604: no DacaWrongData for function pointer (#4867) 2023-03-12 15:49:37 +01:00
chrchr-github 980c92d19d
Partial fix for #11378 internalAstError regressions (iscpp11init) (#4884) 2023-03-12 15:39:02 +01:00
Oliver Stöneberg e2f38fdaf3
removed `experimental` and `safe` from `Certainty` (#4819) 2023-03-12 14:15:29 +01:00
chrchr-github 9ed21fb917
Fix #11513 FN functionConst with comparison as argument (#4738) 2023-03-12 11:39:18 +01:00
chrchr-github 809430631f
Partial fix for #11611 FP constStatement with typedef and unknown macro (#4881) 2023-03-12 11:13:58 +01:00
chrchr-github 7881b99547
Fix #10259 debug: SymbolDatabase couldn't resolve all user defined types (#4879) 2023-03-10 19:04:46 +01:00
Oliver Stöneberg 901b2ab838
Preprocessor: provide suppressions separately from settings (#4878) 2023-03-09 20:15:53 +01:00
chrchr-github a5b0fd38fd
Fix FP functionConst with ternary (#4874) 2023-03-09 20:07:44 +01:00
chrchr-github 49c5a5aabd
Fix #11602 "debug: Executable scope 'x' with unknown function" (#4869) 2023-03-09 20:04:55 +01:00
Oliver Stöneberg 30131837b5
refs #11603 - deprecated `--enable=information` implicitly enabling `missingInclude` (#4865) 2023-03-09 20:04:20 +01:00
chrchr-github c76b05ad75
Fix #11607 FP constVariable with auto and std::map (#4877) 2023-03-09 20:01:50 +01:00
chrchr-github 6e1cc11eff
Fix #11606 internalAstError with empty initializer list (#4875) 2023-03-09 20:01:06 +01:00
Mateusz Michalak 2d5cabed4b
Add std::*begin and std::*end cfg (#4796) 2023-03-09 17:06:53 +01:00
Paul Fultz II 9351eddbca
Fix 11605: FN useStlAlgo with multiple conditions (#4873) 2023-03-09 17:06:27 +01:00
Daniel Marjamäki 3658965912 runformat 2023-03-07 17:57:51 +01:00
chrchr-github f2238e717b
Fix crash in isTemporary() (#4866) 2023-03-07 12:44:54 +01:00
Oliver Stöneberg 20db3ff368
SymbolDatabase: made `mTokenizer` and `mSettings` references (#4857) 2023-03-07 12:22:06 +01:00
Oliver Stöneberg d17e804235
made `CmdLineParser::mSettings` a reference (#4855) 2023-03-07 12:11:21 +01:00
Daniel Marjamäki e8e00d8fdf Unused Var: Fix FP when initialization is made in macro 2023-03-05 15:31:53 +01:00
Oliver Stöneberg a00b6e1f8a
simplified `ThreadExecutor` class by moving some code out of it / fixed some thread safety issues (#4849) 2023-03-04 12:05:17 +01:00
chrchr-github 9291421840
Fix #11595 FN useStlAlgorithm with complex condition (#4848) 2023-03-04 11:58:12 +01:00
chrchr-github b4c90f8b2a
Fix #11597 FP uninitvar with nested enum (#4847) 2023-03-04 11:57:12 +01:00
Daniel Marjamäki 350a1f2dfc AST: do not produce AST for function pointer declaration 'void *(*var[2])(int)' 2023-03-04 11:09:55 +01:00
Daniel Marjamäki f4e0ae3b84 Tokenizer: Improved removing of function pointer arguments to avoid false positives 2023-03-04 11:09:55 +01:00
Oliver Stöneberg 7fd4118d60
Fix #10039 (integrate `--check-config` include findings with normal analysis) / also fixes #11283 (#3229) 2023-03-04 09:02:35 +01:00
Oliver Stöneberg 50eb0641b9
iwyu.yml: added `clang-include-cleaner` job / cleaned up includes based on `include-what-you-use` (#4844) 2023-03-04 08:53:19 +01:00
Oliver Stöneberg 0ec2d84f1a
optimized suppression lookups a bit when no suppressions exist (#4839) 2023-03-03 18:37:09 +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 b70e1d5461
avoid some unchecked pointer dereferences (#4811) 2023-03-02 22:05:41 +01:00
chrchr-github 215124461e
Fix #11499 FN functionConst with operator usage (#4722) 2023-03-02 21:51:58 +01:00
Oliver Stöneberg 381361629e
Preprocessor: removed unreachable `ConfigurationNotChecked` finding (#4790) 2023-03-02 21:50:57 +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 8f5f06add7
some `Tokenizer` construction and related other cleanups (#4799) 2023-03-02 21:48:14 +01:00
chrchr-github 491299048b
Amend fix for #11449 Function call not recognized (#4838) 2023-03-02 21:45:15 +01:00
chrchr-github 51c5a79150
Fix #11586 FP ctuArrayIndex with unknown typedef (#4831) 2023-03-02 21:19:53 +01:00
chrchr-github 7f62d8ff98
Fix #11594 internalAstError with immediately instantiated enum (#4841) 2023-03-02 21:17:39 +01:00
Oliver Stöneberg 3ec4da0f8a
improved library loading in tests (#4806) 2023-03-02 21:10:51 +01:00
chrchr-github 072e822020
Set ValueType for free function returning iterator (#4837) 2023-03-02 21:01:20 +01:00
Oliver Stöneberg 514e605598
CI-unixish.yml: fixed and enabled all `build` steps for macos (#4832) 2023-03-02 20:54:30 +01:00
Oliver Stöneberg b53bb36798
disallow move/copy of `ScopedFile` (#4723) 2023-03-02 20:44:29 +01:00
Daniel Marjamäki cfba046408 Fixed #11593 (function pointer => false negatives (ast? valueflow?)) 2023-03-02 20:08:22 +01:00
chrchr-github 17e776861e
Get type from auto with index operator (#4826) 2023-02-28 15:05:45 +01:00
Daniel Marjamäki 80050b11dd SymbolDatabase: Fix handling of function pointer arguments 2023-02-27 15:10:25 +01:00
Daniel Marjamäki 65fc31cba9 Tokenizer: tweaked simplification of function pointers. Argument types are kept. 2023-02-26 18:03:24 +01:00
chrchr-github a0cc35e3fa
Remove simplifyQtSignalsSlots(), update qt.cfg (#4807) 2023-02-25 15:58:57 +01:00
chrchr-github 29b651f264
Partial fix for #11543 checkLibraryFunction warning for smartpointer in container (#4781) 2023-02-25 15:47:02 +01:00
Daniel Marjamäki af44659e06 runformat 2023-02-25 10:23:45 +01:00
Oliver Stöneberg 634881db61
testrunner: moved exception handling to `TestFixture::run()` and made it unconditional (#4810) 2023-02-24 21:46:07 +01:00
chrchr-github 92b42255da
Fix #11559 FN functionConst (#4795) 2023-02-24 21:44:57 +01:00
Oliver Stöneberg da09a92b0a
test/cfg: enabled `information` and `--inconclusive` in all cases / some cleanups (#4784) 2023-02-24 21:37:56 +01:00
chrchr-github d65cc696b0
Get type from auto with scope (#4822) 2023-02-24 21:05:26 +01:00
chrchr-github a030970160
Fix #11531 FP constParameter with const/non-const overload / #8700 FP functionConst (#4802) 2023-02-24 07:05:18 +01:00
chrchr-github d1e1f951df
Don't show checkLibraryNoReturn for functions with visible declaration (#11523, #11190) (#4809) 2023-02-24 06:49:28 +01:00
chrchr-github 103ff907b6
Fix #11572 Broken AST with brace-init and bitwise and (#4812) 2023-02-24 06:31:20 +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 50c8a0dbe1
Fix #11553 pop_back on empty container is UB (#4789) 2023-02-24 01:10:19 +01:00
chrchr-github 96887c8130
Fix #11561 FN nullPointer with unnamed parameter (#4805) 2023-02-23 22:56:03 +01:00
Oliver Stöneberg edc9cfba94
sped up `TestIO` a bit by only processing code as C++ if necessary (#4815) 2023-02-23 22:53:39 +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
chrchr-github fb88883813
Fix #11576 FP comparePointers / FN cstyleCast when taking address (#4817)
* Fix FN cstyleCast when taking address

* Fix #11576 FP comparePointers with member variable

* Use getParentLifetime()

* Fix test case number
2023-02-23 17:27:47 +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
chrchr-github 1c11d3039d
Fix FP returnTempReference (#4793)
* Fix FP returnTempReference

* Fix mismatch between token and variable ValueType

* Format, clang-tidy

* Add test

* Format
2023-02-17 07:17:37 +01:00
chrchr-github 33a03f2c35
Don't throw internalAstError for parameter pack in template argument list (#4773) 2023-02-15 19:43:18 +01:00
chrchr-github 4f8329b2df
Fix #11545 FP unreadVariable with std::span (#4792) 2023-02-14 06:11:24 +01:00