Commit Graph

25495 Commits

Author SHA1 Message Date
chrchr-github d3d40fd599
Fix #10868/#10869 FN: constStatement, handle unused character constants (#3898)
* Fix #10868 FN: constStatement, handle unused character constants

* simpleMatch

* Fix #10869 FN: constStatement

* Format
2022-03-14 14:14:32 +01:00
Oliver Stöneberg 0d336b868c
avoid some Clang compiler warnings (#3896) 2022-03-13 20:07:58 +01:00
Daniel Marjamäki a6c1653ed2 Fixed #10853 (False positive: misra-c2012-16.3: macro parameter "default") 2022-03-13 19:58:27 +01:00
chrchr-github 2eed660b32
Fix #8496 Clarify warnings for uninitMemberVar (#3760) 2022-03-13 17:33:31 +01:00
Daniel Marjamäki ee0d93e5da Fixed #10861 (False positive: CERT-API01: only warn about char/wchar arrays.) 2022-03-13 16:42:07 +01:00
Daniel Marjamäki df2c8f3a65 Fixed #10862 (Misplaced warning: misra-2.2: macros) 2022-03-13 13:15:38 +01:00
chrchr-github 190506db40
Fix #10737 Regression: unusedStructMember (#3894)
* Fix #10737 Regression: unusedStructMember

* Add test for #9161

* simpleMatch
2022-03-13 06:27:17 +01:00
chrchr-github c3506b5186
Fix #10691 regressions with static variables and multiple assignments (#3895)
* Fix regressions with static variables and multiple assignments

* Fix test

* Fix test cases
2022-03-13 06:26:21 +01:00
Oliver Stöneberg 757287b13c
removed unnecessary varid0 inline suppressions (#3893) 2022-03-12 18:02:40 +01:00
chrchr-github 3df170c191
Fix #10865 FN: constStatementError, streamline error messages (#3892) 2022-03-12 14:52:18 +01:00
chrchr-github d1f740a289
Partial fix for #9384 varid 0 with lambda (II) (#3889)
* Partial fix for #9384 varid 0 with lamba

* Format

* Undo

* Undo

* Partial fix for #9384 varid 0 with lambda (II)
2022-03-12 06:17:37 +01:00
chrchr-github 4c85ac0d7b
Fix #10852 FP unused struct member (inner struct in C code) (#3890)
* Fix #10852 FP unused struct member (inner struct in C code)

* Redundant findType() call, add test
2022-03-12 06:16:29 +01:00
Paul Fultz II ff902369e0
Fix 10851: False positive: known variable value below for loop (#3891)
* Fix 10851: False positive: known variable value below for loop

* Format

* Add test for 10863

* Format
2022-03-12 06:15:35 +01:00
chrchr-github 705931266c
constStatementError: don't warn for casts with possible side effects,… (#3885)
* constStatementError: don't warn for casts with possible side effects, handle bool constants

* Recursive call, add tests

* Restore test

* Don't warn for C++ casts to void

* Don't warn for cast to void*
2022-03-11 21:45:51 +01:00
chrchr-github ffd9f9a93f
Fix FP missingOverride with unnamed parameters (#3887) 2022-03-11 21:44:13 +01:00
Oliver Stöneberg e208fc67c1
small selfcheck improvements (#3888)
* CI-unixish.yml: added missing cppcheck-lib library to GUI selfcheck

* CI-unixish.yml: split triage from tools selfcheck since it requires the qt library

* replaced Q_NULLPTR with nullptr

* fixed passedByValue selfcheck warning
2022-03-11 21:42:46 +01:00
Binho 8b3647edd7 Fix false positive in memory leak 2022-03-10 08:29:05 +01:00
Daniel Marjamäki 7290ec0db6 cppcheckdata: remove debug output 2022-03-09 21:38:44 +01:00
chrchr-github 2616046461
Partial fix for #10848 FP: unusedStructMember (#3880) 2022-03-09 20:25:58 +01:00
chrchr-github 557263acde
Partial fix for #10848 FP: unusedStructMember (II) (#3881)
* Preliminary

* Fix member search, add tests
2022-03-09 18:22:30 +01:00
chrchr-github 850ad0fed9
#8451: Add error message for unused casts, log unhandled errors (#3883)
* #8451: Add error message for unused casts, log unhandled errors

* Fix TODO

* Fix TODO
2022-03-09 18:21:47 +01:00
chrchr-github c9f47dec8b
Partial fix for #9384 varid 0 with lambda (#3875) 2022-03-08 20:10:51 +01:00
chrchr-github fbdfb60809
Warn about buffer overruns when allocating memory with new (#3879)
* Warn about buffer overruns when allocating memory with new

* Format

* Avoid FP
2022-03-07 19:43:40 +01:00
chrchr-github 25360d5e4c
Add test for #7686 (#3878)
* Add test for #7686

* Format
2022-03-07 15:32:14 +01:00
chrchr-github 461d797094
Add test for #10835 (#3877) 2022-03-07 10:44:46 +01:00
orbitcowboy 1d2beb0431 Added a regression test for ticket 6928 - Improve check: unused variables, goto 2022-03-07 10:12:57 +01:00
chrchr-github 3a5931b417
Fix #5499 C++11 default values not for all class fields and missing constructor (#3876) 2022-03-07 08:39:19 +01:00
chrchr-github 7f682d544e
Partial fix for #6615 FN buffer access out of bounds: std::vector (#3873)
* Fix #10779 FN: stlOutOfBounds (off by one)

* Format

* Simplify

* Partial fix for #6615 FN buffer access out of bounds: std::vector

* Undo

* Format

* Fix test case
2022-03-06 07:41:09 +01:00
chrchr-github 0b0a8cad39
Fix #10846 FP unreadVariable within a macro (regression) (#3874)
* Fix #10846 FP unreadVariable within a macro (regression)

* Format

* Format
2022-03-05 08:14:57 +01:00
chrchr-github 27baa20f38
Fix #10779 FN: stlOutOfBounds (off by one) (#3872)
* Fix #10779 FN: stlOutOfBounds (off by one)

* Format

* Simplify
2022-03-04 17:13:13 +01:00
chrchr-github 2dd6c75b35
Fix #10838 Crash/nullptr deref in getEndOfExprScope() (#3870)
* Fix #10838 Crash/nullptr deref in getEndOfExprScope()

* Format
2022-03-03 17:08:23 +01:00
chrchr-github 78dd29ada3
Fix #10770 FP noConstructor with function pointer member (#3751) 2022-03-03 13:56:24 +01:00
chrchr-github 8a7992c6ac
Suppress operatorEqVarError for known non-copyable types (#3869)
* Fix FP operatorEqVarError with class hierarchy

* Suppress operatorEqVarError for std::mutex

* Add test, non-copyable Qt types

* Update cppcheck-cfg.rng
2022-03-03 09:41:26 +01:00
Daniel Marjamäki 915ae4b845 ValueFlow: Fix crash 2022-03-02 21:12:37 +01:00
chrchr-github 9c50136571
Fix #10824 FN unreadVariable for pointer assignment when destructor exists (regression) (#3864)
* Fix #10824 FN unreadVariable for pointer assignment when destructor exists (regression)

* unused variable

* Issue warning for missing cfg

* Format
2022-03-02 11:11:44 +01:00
Oliver Stöneberg de728f472c
removed ThreadExecutor::addFileContent() (#3865) 2022-03-02 11:10:29 +01:00
Oliver Stöneberg 4a63af02ed
enabled functionConst and functionStatic in selfcheck (#3862)
* fixed functionConst findings and enabled it in selfcheck

* fixed functionStatic findings and enabled it in selfcheck

* .travis_suppressions: adjusted comment

* testimportproject.cpp: added missing asserts
2022-03-02 07:46:47 +01:00
chrchr-github 8e8e6b1170
Fix FP operatorEqVarError with class hierarchy (#3868) 2022-03-02 07:46:23 +01:00
chrchr-github 01de8256ea
Fix #10798 cppcheckError with enum class and typedefs (#3867)
* Fix #10798 cppcheckError with enum class and typedefs

* Format

* Format

* Leave enum class scope

* Remove comment
2022-03-02 07:46:15 +01:00
chrchr-github 43fb3dd047
Fix regression: wrong varid with using namespace (#3866)
* Fix #10059 missing varId with using namespace

* Undo

* Fix test

* Limit namespace candidates, duplicateBranch

* rvalue ref

* Undo

* Undo

* Undo

* Format

* Fix condition

* Fix regression: wrong varid with using namespace
2022-03-02 07:46:04 +01:00
Paul Fultz II 0b310b9d07
Fix 10702: FP knownConditionTrueFalse - Member variable modified (#3857)
* Fix 10702: FP knownConditionTrueFalse - Member variable modified

* Format

* Make parameter const

* Fix FP

* Fix FP

* Update

* Format
2022-02-28 18:54:55 +01:00
chrchr-github 6a8bd981b5
Fix #10825 CheckClass::isMemberVar found used member variable with varid 0 (#3863)
* Fix #10825 CheckClass::isMemberVar found used member variable with varid 0

* Restore call to simpleMatch()
2022-02-28 18:28:23 +01:00
José Martins b1e92fc399
Misra false positive fixes for rules 8.7 and 5.9 (#3844)
* Fix misra 8.7 false positives on single function usage

When there is a single usage of a function, we should first check if the
file it is used in, is the same one it was defined in. When this is not the
case, there is no violatior to be reported.

* Fix misra rule 5.9 false positives for exception

The exception for rule 5.9 described in the guidelines allows for
multiple definitions of internal linkage obejcts when these regard a
static inlined function defined in the same header file.

* Fix neglecting of inline keyword flag upon simplifications

When the inline keyword is being "simplified" and the inline flag is
degated to the next token. However, this information might be lost if the next
token itself is simplified/deleted in a futher pass. Therefore, we must
propagated the flag to all the next named tokens, so we can make sure the
function name token itself is tagged with this property.

* add tests for misra addon rules 8.7 and 5.9
2022-02-27 19:17:48 +01:00
chrchr-github 05a6d09c5f
Fix #10360 FP uninitMemberVar from copy constructor [inconclusive] (#3748) 2022-02-27 19:15:19 +01:00
chrchr-github ddb0a8bb0b
Fix #10059 missing varId with using namespace (#3860)
* Fix #10059 missing varId with using namespace

* Undo

* Fix test

* Limit namespace candidates, duplicateBranch

* rvalue ref

* Undo

* Undo

* Undo

* Format

* Fix condition
2022-02-27 09:03:24 +01:00
chrchr-github d79d6e60db
Fix #10828 Internal error. Token::Match called with varid 0 (#3859)
* Fix #10828 Internal error. Token::Match called with varid 0

* Fix test
2022-02-26 23:48:29 +01:00
chrchr-github 441b437cea
Fix #10826 FN: unusedStructMember (#3858) 2022-02-26 18:53:00 +01:00
Paul Fultz II dbc80787e1
Fix 10821: FN: containerOutOfBounds (#3856)
* Fix 10821: FN: containerOutOfBounds

* Format

* Fix cppcheck warning

* Add valueflow tests

* Format

* Fix some bugs

* Format
2022-02-25 05:53:51 +01:00
Daniel Marjamäki 03deb4d31e addons: interface with premiumaddon if it exists 2022-02-24 16:08:59 +01:00
Paul Fultz II 45de9a7d08
Refactor: Use getEndOfExprScope instead of getEndOfVarScope (#3855) 2022-02-24 06:50:34 +01:00