Commit Graph

1410 Commits

Author SHA1 Message Date
Paul Fultz II d6e3182441
Fix 11721: False positive: constParameterReference with overloaded template function (#5151) 2023-06-17 11:31:47 +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 055489df5a
Fix #11742 Can't reduce scope as variable references itself (#5112) 2023-06-02 23:33:17 +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 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 78182d4773
Fix FN constVariablePointer (#5076)
* Fix FN constVariablePointer

* Fix FP

* Add const

* Fix tests

* Add const
2023-05-22 19:53:51 +02:00
Daniel Marjamäki f72db74817
Fixed #11013 (FP overlappingWriteUnion with anonymous struct in union) (#5067) 2023-05-20 10:34:42 +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 100d17df4f
Fix #11681 FN constParameterPointer with std::vector (#5000) 2023-05-04 11:10:58 +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
chrchr-github f04d47ac61
Fix remaining example from #11131 (#5029) 2023-05-03 16:24:56 +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
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 5c7914aaa6
Fix FN constParameterReference with std::array (#4999) 2023-04-21 20:33:06 +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 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 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
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 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 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
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 19eef2c584
Partial fix for #11599 false negative: constParameter (#4901) 2023-03-19 17:43:23 +01:00
Oliver Stöneberg e2f38fdaf3
removed `experimental` and `safe` from `Certainty` (#4819) 2023-03-12 14:15:29 +01:00
Oliver Stöneberg 901b2ab838
Preprocessor: provide suppressions separately from settings (#4878) 2023-03-09 20:15:53 +01:00
chrchr-github c76b05ad75
Fix #11607 FP constVariable with auto and std::map (#4877) 2023-03-09 20:01:50 +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 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 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
Oliver Stöneberg 3ec4da0f8a
improved library loading in tests (#4806) 2023-03-02 21:10:51 +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
Oliver Stöneberg 132a5a31cf
improved setting of platform in tests / also improved platform tests (#4787)
* fixture.h: added TODO

* TestPlatform: improved tests for built-in platforms

* TestPlatform: changed tests to TODO asserts

* testfilelister.cpp: added TODO

* fixture.h: added `PLATFORM` macro to load platform / use `PLATFORM` in tests

* platform.h: corrected capitalization in `Platform::platformString(PlatformType)` and bail on unknown type

* fixture.h: fixed `readability-redundant-string-cstr` clang-tidy warning

* testplatform.cpp: fixed `functionConst` selfcheck warnings
2023-02-11 10:44:56 +01:00
chrchr-github 271ccbc8f3
Fix FP constVariable with reference to std::array (#4777) 2023-02-08 08:25:43 +01:00
Oliver Stöneberg 7c7ccdf7c0
Check: disallow more than one instance per check (#4749) 2023-01-29 17:23:03 +01:00
Daniel Marjamäki 464fbe8d53 Update copyright year 2023-01-28 10:16:34 +01:00
Oliver Stöneberg 1d3955bd92
renamed some files in the `test` folder (#4705) 2023-01-27 08:18:32 +01:00
chrchr-github dee2ad8756
Fix #10337 FP selfAssignment (#4682) 2023-01-18 16:59:56 +01:00
chrchr-github a2fea3d9b4
Fix #11083 FP knownConditionTrueFalse with reassigned pointer (#4717) 2023-01-18 16:57:22 +01:00
chrchr-github a79dff15ab
Fix #11492 FP uninitvar with try/catch (#4711) 2023-01-14 20:14:38 +01:00
chrchr-github 7bbdc95f25
Fix #11473 FP constVariable / #11448 FP constParameter / #11188 FP danglingTempReference (#4680)
* Fix #11473 FP constVariable with range-based for / #11448 FP constParameter with unused non-const range loop variable

* Fix ValueType / #11188 FP danglingTempReference with auto

* Fix ValueType in range-based for

* Update symboldatabase.cpp
2023-01-11 22:04:06 +01:00
chrchr-github 7506b4ab52
Fix #11441 FP variableScope when lambda is used (#4660) 2022-12-20 14:50:31 +01:00
chrchr-github 3f5054035d
Fix #11432 FP passedByValue for overriden function (#4632) 2022-12-12 21:52:58 +01:00
chrchr-github d5d7446433
Add cfg for std::scoped_lock, handle template arguments in checkMisusedScopedObject() (#4615) 2022-12-07 09:10:48 +01:00
gerboengels 3fdba645a6
Improve fix for #11383 FP selfAssignment: lambda capture (#4584) 2022-11-18 19:44:32 +01:00
chrchr-github 701d381895
Fix #11383 FP selfAssignment: lambda capture / #11380 FP operatorEqRetRefThis (#4581)
* Fix  #11383 FP selfAssignment: lambda capture /  #11380
FP operatorEqRetRefThis

* Format
2022-11-13 21:20:44 +01:00
chrchr-github d717e62ec3
Fix #11371 Detect assignment to temporary (#4571)
* Fix #11371 Detect assignment to temporary

* Use AST

* Warn if type definition is not seen
2022-11-01 11:46:42 +01:00
chrchr-github cf8051b7e2
Fix #11368 FP "Same value in both branches of ternary operator" on plus and minus zero (#4569)
Fix #11368 FP "Same value in both branches of ternary operator" on plus and minus zero
2022-10-31 15:18:25 +01:00
chrchr-github 7b9c99003b
Improve unreachableCodeError: handle library functions (#4560)
* Update templatesimplifier.cpp

* Add tests

* Improve unreachableCodeError message

* Update templatesimplifier.cpp

* Add tests

* Improve unreachableCodeError message

* Revert "Update templatesimplifier.cpp"

This reverts commit 3fd152ed4063772a5f162bd985c3d91bcc65eb55.

* Revert "Add tests"

This reverts commit e760ab51e66a0a2c3a0250caf4cf3b745db44d10.

* Improve unreachableCodeError: handle library functions

* Fix merge
2022-10-20 07:00:36 +02:00
chrchr-github 9c7b4c9540
Improve unreachableCodeError message (#4559)
* Update templatesimplifier.cpp

* Add tests

* Improve unreachableCodeError message

* Update templatesimplifier.cpp

* Add tests

* Improve unreachableCodeError message

* Revert "Update templatesimplifier.cpp"

This reverts commit 3fd152ed4063772a5f162bd985c3d91bcc65eb55.

* Revert "Add tests"

This reverts commit e760ab51e66a0a2c3a0250caf4cf3b745db44d10.
2022-10-19 19:19:31 +02:00
Oliver Stöneberg fa7e08a29f
optimized `CheckOther::checkDuplicateBranch()` a bit (#4542) 2022-10-09 20:48:54 +02:00
chrchr-github 4d13266e99
Fix #10083 FN unusedScopedObject: temporary lock 'std::lock_guard<std::mutex>(m)' (#4522)
* Fix #10083 FN unusedScopedObject: temporary lock 'std::lock_guard<std::mutex>(m)'

* Format

* Fix cppcheck-cfg.rng

* Format
2022-09-30 07:25:33 +02:00
chrchr-github 32c7b919ba
Add tests for #1201, #2654, #6379 (#4518)
* Add test for #6541, avoid duplicate warning

* Add test for #5475

* Fix test

* Merge

* Add test for #8666

* Fix #11239 checkLibraryCheckType with asm goto() (invalid varid)

* Format

* Add tests for #1201, #2654

* Fix test

* Add test for #6379
2022-09-29 07:05:29 +02:00
chrchr-github 2808fc615e
Fix #10057 "statement without effect" / #4779 FN unusedScopedObject does not work for classes in different namespace (#4500)
* Partial fix for #10057 unused variable without assignment not detected

* Add test for #9672

* Fix #4779 FN unusedScopedObject does not work for classes in different namespace

* Merge

* Fix #10057 "statement without effect" (unused variable without assignment) not detected

* Format
2022-09-24 12:49:37 +02:00
Paul Fultz II de7d02293f
Fix 11308: FP accessMoved with virtual function (#4478)
* Fix 11308: FP accessMoved with virtual function

* Format
2022-09-18 08:30:06 +02:00
chrchr-github cb6f04a16c
Fix #11315 FP zerodivcond from enum definition / #11310 FP unassignedVariable with static variable (#4476)
* Fix #11315 FP zerodivcond from enum definition

* Simplify Boolean expression

* Fix #11310 FP unassignedVariable with static variable
2022-09-17 18:50:07 +02:00
Oliver Stöneberg b3ec225480
iwyu.yml: use `debian:unstable` to always get latest include-what-you-use / cleaned up includes (#4466)
* iwyu.yml: use debian:unstable to always get latest include-what-you-use

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

* mitigated include-what-you-use false positives
2022-09-16 07:15:49 +02:00
Paul Fultz II 43caa32abf
Fix 9755: false negative: access of moved variable in conditional code (#4459)
* Fix 9755: false negative: access of moved variable in conditional code

* Format
2022-09-11 12:32:01 +02:00
Oliver Stöneberg 1b4141cbe5
added more missing `sstream` includes (#4384) 2022-08-19 18:23:15 +02:00
chrchr-github 2fee7a6e3f
Add test for #9744, #11140 (#4375)
* Add test for #10603

* Add test for #10559

* Add test for #10212

* Format

* Add test for #9744

* Format

* Add test for #11140
2022-08-18 23:37:41 +02:00
chrchr-github 6a0c254d1f
Fix #9931 FP zerodiv (daca@home) (#4379)
* Fix #9931 FP zerodiv (daca@home)

* Format

* Parentheses

* clang-tidy
2022-08-18 20:38:36 +02:00
chrchr-github 4a64e20592
unusedScopedObject: Don't warn for void statements (#4370)
* Fix unusedScopedObject FPs

* Simplify

* Simplify

* Fix test

* Don't warn for void statements

* Format
2022-08-17 19:45:46 +02:00
chrchr-github 1a95515e47
Fix unusedScopedObject FPs (#4364) 2022-08-17 09:11:23 +02:00
Oliver Stöneberg 4bf5dcd29f
cleaned up includes based on include-what-you-use (#4358)
* cleaned up includes based on include-what-you-use

* testlibrary.cpp: no need for `empyString` optimization
2022-08-14 12:44:19 +02:00
chrchr-github afef71f6b6
Partial fix for #10057 unused variable without assignment not detected (#4348)
* Partial fix for #10057 unused variable without assignment not detected

* Add test for #9672
2022-08-13 08:29:06 +02:00
Paul Fultz II bfd9470600
Fix 11158: FP zerodiv in loop (#4356)
* Fix 11158: FP zerodiv in loop

* Format

* Add another test

* Format

* Fix FP

* Format
2022-08-13 08:27:20 +02:00
chrchr-github c340b6ae6c
Fix #11191 FP moduloofone with pow() (#4312) 2022-07-28 22:11:23 +02:00
chrchr-github 109a031ec7
Fix #11195 Add redundantContinue check (#4283) 2022-07-16 16:02:58 +02:00
chrchr-github b31e40f578
Add tests for #4336, #4739, #8319, #6655 (#4275)
* Add tests for #4336, #4739

* Add test for #8319

* Add test for #6655
2022-07-13 21:08:30 +02:00
PKEuS f3565e1056
Improvement: Support member variables in CheckOther::checkIncompleteArrayFill() (#4205)
Merged from LCppC.
2022-07-12 19:43:48 +02:00
chrchr-github f5c4a21eae
Fix #10704 FN redundantCopyLocalConst (#4115) 2022-07-10 11:33:24 +02:00
chrchr-github 242afc389d
Fix #11148 Regression: Parameter \'ptr\' can be declared as pointer to const (#4233) 2022-06-25 21:42:55 +02:00
chrchr-github 63e567eb50
Remove simplifyKnownVariables() (#4232)
* Remove simplifyKnownVariables()

* Add some test cases back

* Remove unused functions

* Format
2022-06-25 08:38:17 +02:00
chrchr-github f1212e66f7
Fix FP constVariable with 2D array. (#4228)
Test case #8717 was actually a FP as well.
2022-06-22 21:22:04 +02:00
PKEuS 9eb16e1002
Replaced check for pipe() buffer size by ordinary CheckBufferOverrun, provide required Library configuration option (#4183)
Merged from LCppC.
2022-06-19 12:01:55 +02:00
Paul Fultz II de51ebbcf4
Fix 9135: Access of moved variable not detected in loop (#4215)
* Fix 9135: Access of moved variable not detected in loop

* Format

* Fix issue with pushing back on container

* Format

* Fix null pointer

* Remove yeild for now
2022-06-16 17:40:09 +02:00
chrchr-github 6f5a5fd947
Add some tests (#4211)
* Add test for #10152

* Add test for #9773

* Fix test

* Add test for #7529

* Add test for #6371

* Add test for #6475

* Format

* Format

* Fix test

* Remove duplicate test

* Add valueflow test

* Rebuild
2022-06-14 09:54:45 +02:00
chrchr-github ecb24e28bc
Fix #10191 FP redundantCopyLocalConst - referenced variable changes (#4202) 2022-06-11 16:58:33 +02:00
chrchr-github 8579feb3aa
Fix #10545 FP redundantCopyLocalConst with modified object [inconclusive] (#4197)
* Fix  #10545 FP redundantCopyLocalConst with modified object [inconclusive]

* Comment
2022-06-11 11:01:23 +02:00
chrchr-github e6f2929fac
Fix #11085 FN constVariable with range-based for (#4118) 2022-06-03 19:24:59 +02:00
chrchr-github cd7362e0e7
Fix FN with default init (#4162)
* Fix #11099 FP: variableScope when using range constructor to vector

* Format

* Fix FN with default init
2022-06-01 23:18:59 +02:00
chrchr-github 2452a2c01d
Fix #11099 FP: variableScope when using range constructor to vector (#4161)
* Fix #11099 FP: variableScope when using range constructor to vector

* Format
2022-06-01 21:15:41 +02:00
chrchr-github 7fbb9c7c13
Fix #10980 FN constVariable with range-based for loop (#4144)
* Fix #10980 FN constVariable with range-based for loop

* Format

* nullptr check

* Restrict scopes

* Add const

* Undo

* Add more const
2022-05-29 17:06:33 +02:00
chrchr-github e1c51940a2
Fix #11095 FP constParameter with decremented pointer (#4131) 2022-05-28 08:32:58 +02:00
chrchr-github 2ceaf308de
Fix #11084: ValueType for pointer typedef, don't warn for typedef'd pointers, improve error message (#4123)
* Fix ValueType for pointer typedef

* Add test

* Don't warn for typedef'd pointers, improve error message

* Fix tests

* Add TODO

* Fix test

* Set isSimplifiedTypedef() for more tokens, add test

* Add test
2022-05-24 10:09:48 +02:00
chrchr-github 22a4fdb6c4
Fix crash in checkPassByReference() (#4122) 2022-05-21 16:02:35 +02:00
chrchr-github 52f507d1fb
Fix #8004 unintentional semicolon in expression '.. ; +dostuff();' (#4109)
* Fix #8004 unintentional semicolon in expression '.. ; +dostuff();'

* Improve error message

* Don't remove single unary + in front of variables
2022-05-13 06:54:02 +02:00
chrchr-github 54f832a2fe
Fix #10569 FN: duplicateExpression with multiple strings compared (#4087) 2022-05-09 21:05:35 +02:00
chrchr-github aebc080c0f
Fix #11041 FN constVariable with array of pointers [regression] (#4080)
* Fix #11041 FN constVariable with array of pointers [regression]

* Use std::vector for deterministic order of results, use helper variables
2022-05-05 06:54:03 +02:00
chrchr-github 9a379925cd
FIx FN shadowVariable in static function (#4079)
* FIx FN shadowVariable in static function

* Use functionOf
2022-05-04 17:56:16 +02:00
chrchr-github e2069dd1b9
Fix #10650 FN knownConditionTrueFalse with const int value (#4078) 2022-05-04 14:25:00 +02:00
chrchr-github 1e40a2e73e
Fix #5210 C-style pointer casting not detected for casts to ** (#4075) 2022-05-03 20:15:42 +02:00
chrchr-github e9a0d7979e
Fix #11014 FN redundantPointerOp / remove simplifyMulAndParens() (#4062) 2022-05-01 15:46:07 +02:00
chrchr-github e7afb3045b
Fix FP redundantPointerOp with macro (#4061)
* Fix #10991 FN: Redundant pointer operation

* Fix FP redundantPointerOp

* Check for LValue

* Fix FP redundantPointerOp with macro

* Format
2022-04-29 13:23:50 +02:00