Commit Graph

11427 Commits

Author SHA1 Message Date
chrchr-github 4c85ac0d7b
Fix FP unused struct member (inner struct in C code) ()
* Fix  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 ()
* 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,… ()
* 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 () 2022-03-11 21:44:13 +01:00
Binho 8b3647edd7 Fix false positive in memory leak 2022-03-10 08:29:05 +01:00
chrchr-github 2616046461
Partial fix for FP: unusedStructMember () 2022-03-09 20:25:58 +01:00
chrchr-github 557263acde
Partial fix for FP: unusedStructMember (II) ()
* Preliminary

* Fix member search, add tests
2022-03-09 18:22:30 +01:00
chrchr-github 850ad0fed9
: Add error message for unused casts, log unhandled errors ()
* : 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 varid 0 with lambda () 2022-03-08 20:10:51 +01:00
chrchr-github fbdfb60809
Warn about buffer overruns when allocating memory with new ()
* 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 ()
* Add test for 

* Format
2022-03-07 15:32:14 +01:00
chrchr-github 461d797094
Add test for () 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 C++11 default values not for all class fields and missing constructor () 2022-03-07 08:39:19 +01:00
chrchr-github 7f682d544e
Partial fix for FN buffer access out of bounds: std::vector ()
* Fix  FN: stlOutOfBounds (off by one)

* Format

* Simplify

* Partial fix for  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 FP unreadVariable within a macro (regression) ()
* Fix  FP unreadVariable within a macro (regression)

* Format

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

* Format

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

* Format
2022-03-03 17:08:23 +01:00
chrchr-github 78dd29ada3
Fix FP noConstructor with function pointer member () 2022-03-03 13:56:24 +01:00
chrchr-github 8a7992c6ac
Suppress operatorEqVarError for known non-copyable types ()
* 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 FN unreadVariable for pointer assignment when destructor exists (regression) ()
* Fix  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() () 2022-03-02 11:10:29 +01:00
Oliver Stöneberg 4a63af02ed
enabled functionConst and functionStatic in selfcheck ()
* 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 () 2022-03-02 07:46:23 +01:00
chrchr-github 01de8256ea
Fix cppcheckError with enum class and typedefs ()
* Fix  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 ()
* Fix  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 ()
* 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 CheckClass::isMemberVar found used member variable with varid 0 ()
* Fix  CheckClass::isMemberVar found used member variable with varid 0

* Restore call to simpleMatch()
2022-02-28 18:28:23 +01:00
chrchr-github 05a6d09c5f
Fix FP uninitMemberVar from copy constructor [inconclusive] () 2022-02-27 19:15:19 +01:00
chrchr-github ddb0a8bb0b
Fix missing varId with using namespace ()
* Fix  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 Internal error. Token::Match called with varid 0 ()
* Fix  Internal error. Token::Match called with varid 0

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

* Format

* Fix cppcheck warning

* Add valueflow tests

* Format

* Fix some bugs

* Format
2022-02-25 05:53:51 +01:00
chrchr-github f53793c413
Fix FP cstyleCast with function pointer and calling convention () 2022-02-23 09:12:14 +01:00
Oliver Stöneberg 51371f7929
added CMake option USE_THREADS to be able to use threads instead of fork() / cleanups () 2022-02-23 09:04:35 +01:00
chrchr-github 172aafdeb8
Fix FN: redundant assignment in loop () 2022-02-22 09:51:44 +01:00
Paul Fultz II 1ac16413ea
Another fix for 10800: Hang / memory exhaustion on numerical code ()
* Another fix for 10800: Hang / memory exhaustion on numerical code

* Format
2022-02-22 07:21:26 +01:00
Paul Fultz II 72d0f3e444
Fix 10808: cppcheckError AST cyclic dependency with decltype ()
* Fix 10808: cppcheckError AST cyclic dependency with decltype

* Format
2022-02-22 06:30:17 +01:00
chrchr-github 734e3ac6da
Fix cppcheckError with for loop () 2022-02-21 18:14:20 +01:00
chrchr-github bedde0a1df
Fix bug hunting; crash for small C-code () 2022-02-21 18:09:46 +01:00
chrchr-github d77fa64051
Fix Function::addArguments found argument 'x' with varid 0 () 2022-02-21 18:06:26 +01:00
chrchr-github 5574e41b86
Fix CheckClass::isMemberVar found used member variable with varid 0 () 2022-02-20 18:17:47 +01:00
chrchr-github 18e00bb4fd
Fix Crash in checkPassByReference() / Stack overflow with decltype / Crash on invalid code ()
* Fix  Crash in checkPassByReference()

* Format

* Fix  Stack overflow with decltype

* Fix  Crash on invalid code in TemplateSimplifier::templateParameters
2022-02-18 12:59:21 +01:00
chrchr-github 6635e6cc07
Fix cppcheckError with for loop () 2022-02-17 22:12:19 +01:00
chrchr-github 2f46e57311
Add leak-ignore for fopen_s(), test cases ()
* Add leak-ignore for fopen_s(), test cases

* Format
2022-02-17 16:22:30 +01:00
chrchr-github a1adbff683
Fix FN Memory leak not detected when variable is 'used' by allocation function in condition () 2022-02-16 21:31:24 +01:00
chrchr-github b07814f329
Fix FN missed class members in copy operator of derived class () 2022-02-16 21:30:19 +01:00
chrchr-github 6488cb6e76
Add test for () 2022-02-16 16:43:06 +01:00
Daniel Marjamäki c968aeaf73 Import project: do not crash when importing compile database generated by IAR workbench 2022-02-16 08:35:47 +01:00
chrchr-github 9582032906
Fix FP uninitMemberVar - ctor calls function with smart pointer argument () 2022-02-16 07:02:26 +01:00
chrchr-github 52f549fa87
Fix crash on garbage code () 2022-02-15 20:19:03 +01:00
chrchr-github 907218254e
Fix previous commit ()
* Fix  unsafeClassCanLeak missing for array of pointers

*  Fix previous commit

* Format

* Format
2022-02-15 20:03:02 +01:00
chrchr-github e7e2439347
Fix unsafeClassCanLeak missing for array of pointers () 2022-02-15 14:28:19 +01:00
chrchr-github a5674182bb
Add test for () 2022-02-15 12:52:10 +01:00
orbitcowboy d131235a53 test windows.cfg: Added regression test for _wtoi_l and _atoi_l. 2022-02-15 11:37:10 +01:00
Daniel Marjamäki f2420509c9 Revert "constPointer: Fix false positives when pointer is not read"
This reverts commit 6427b4888b.

If variable/parameter is unused it is better to warn about that.
2022-02-13 08:40:45 +01:00
Daniel Marjamäki 6427b4888b constPointer: Fix false positives when pointer is not read 2022-02-12 22:23:25 +01:00
chrchr-github 0a99e3b6fc
Partial fix for FN redundant assignment/unreadVariable () 2022-02-12 15:32:08 +01:00
Daniel Marjamäki 30cec97cc8 Tokenizer: Support C++20 default bit-field member initializer 2022-02-12 12:19:08 +01:00
chrchr-github edc5106237
Fix FN missingOverride - subclass in namespace () 2022-02-12 08:19:07 +01:00
chrchr-github c5ab936088
Fix FN shadowVariable in range-based for loop () 2022-02-12 08:10:53 +01:00
Rikard Falkeborn d4cd249c21
10671 fix const iterator function const take two ()
* Revert "Revert "Fix : functionConst FN with begin/end and const_iterator ()""

This reverts commit 9f6a36c1a8.

* Fix crash by adding missing null check
2022-02-11 21:23:23 +01:00
chrchr-github 5f3ddabd56
Fix FP constParameter with std::map () 2022-02-11 19:40:11 +01:00
Paul Fultz II 78228599da
Fix 10800: Hang / memory exhaustion on numerical code ()
* Fix 10800: Hang / memory exhaustion on numerical code

* Format

* Add another test

* Format
2022-02-11 06:52:28 +01:00
Oliver Stöneberg f32583e097
removed OVERRIDE and FINAL defines and use the keywords directly () 2022-02-10 23:02:24 +01:00
Julien Marrec 2535bf984b
Allow passing std::string_view by value () 2022-02-10 21:01:12 +01:00
chrchr-github cd7532df21
Fix FN C-style pointer casting with built-in or typedef types /… () 2022-02-10 20:48:51 +01:00
Paul Fultz II 5d25050b06
Fix 10788: False positive: zerodivcond when using an assert () 2022-02-10 20:22:14 +01:00
chrchr-github ddd84f9b98
Add tests/TODO for , ()
* Add tests/TODO for , 

* Comment
2022-02-10 20:05:14 +01:00
orbitcowboy 65c0ef8eb0 Added a regression test for ticket . 2022-02-10 14:13:50 +01:00
chrchr-github 24e9859158
Fix FP stlcstrParam due to incorrect overload resolution ()
* Fix  FP stlcstrParam due to incorrect overload resolution

* Variable shadowing
2022-02-10 11:17:06 +01:00
Paul Fultz II a50452517d
Fix 10794: Crash in MultiValueFlowAnalyzer::getProgramState() ()
* Fix 10794: Crash in MultiValueFlowAnalyzer::getProgramState()

* Format
2022-02-10 07:43:27 +01:00
orbitcowboy 09da69b1c7 posix.cfg: Added support for 'llseek()', which is obsolescent since glibc version 2.28 2022-02-09 08:34:35 +01:00
chrchr-github 2c7948102a
Fix FP AssignmentAddressToInteger with enum class () 2022-02-08 16:12:35 +01:00
chrchr-github e64ea20089
Fix FP variableScope for if with init-statement () 2022-02-08 16:12:09 +01:00
chrchr-github 966dbb1990
Windows.cfg: add UNREFERENCED_PARAMETER() macro () 2022-02-08 11:50:28 +01:00
Paul Fultz II 20a5224d7e
Fix 10784: False positive: returnDanglingLifetime using std::tie with variadic template parameters () 2022-02-08 09:03:51 +01:00
Paul Fultz II 260d155bb6
Fix 10785: False positive: constParameter when using member pointer () 2022-02-07 18:45:32 +01:00
orbitcowboy c983151b9c posix.cfg: Added support for lseek64(). 2022-02-07 14:15:48 +01:00
orbitcowboy bd1d8ea7b8 posix.cfg: Improved configuration of lseek(). 2022-02-07 13:58:38 +01:00
orbitcowboy 2dea968ec5 windows.cfg: Improved configuration of _fseeki64() 2022-02-07 09:12:31 +01:00
orbitcowboy a7b7b46d76 posix.cfg: Improved configuration of fseeko()/fseeko64(). 2022-02-07 09:03:39 +01:00
orbitcowboy 2f17147900 std.cfg: Improved configuration for fseek(). The 3rd argument is not allowed to be of Boolean type. 2022-02-07 09:02:24 +01:00
Paul Fultz II 569332a50a
Fix 10786: False positive: arrayIndexOutOfBoundsCond () 2022-02-06 20:14:13 +01:00
Paul Fultz II a639c59780
Fix 10787: False positive: knownConditionTrueFalse with a conditional exit () 2022-02-06 20:13:44 +01:00
orbitcowboy fa776051e9 Fixed Ticket 1001 - std.cfg: Invalid parameters for fseek() 2022-02-06 16:05:14 +01:00
Oliver Stöneberg 974dd5d49f
only use bundled tinyxml2 in CMake when configured to do so () 2022-02-06 13:02:52 +01:00
Daniel Marjamäki 3989408738 Update copyright year 2022-02-05 11:45:17 +01:00
chrchr-github 7f28edbe26
Fix Crash in CheckMemoryLeakInClass () 2022-02-04 19:32:23 +01:00
orbitcowboy 31ea13eb0c test std.cfg: Fixed wrong npos constant. 2022-02-04 12:39:43 +01:00
orbitcowboy 7062b0a973 std.cfg: Improved configuration of std::[w]string::substr(). Do not allow negative length arguments. 2022-02-04 12:30:37 +01:00
chrchr-github 17b538210d
Fix FP eraseDereference when returning iterator from loop () 2022-02-03 21:13:48 +01:00
Daniel Marjamäki 9f6a36c1a8 Revert "Fix : functionConst FN with begin/end and const_iterator ()"
This reverts commit 2cacb13f85.
2022-02-03 11:04:02 +01:00
chrchr-github a20465eaea
Fix FP knownConditionTrueFalse with static variable and direct initialization / partial fix for () 2022-02-02 22:30:49 +01:00
chrchr-github 511520d623
Fix FP constParameter with const/nonconst overload () 2022-02-02 19:38:32 +01:00
Rikard Falkeborn 2cacb13f85
Fix : functionConst FN with begin/end and const_iterator ()
Check if the iterator is assigned to a const_iterator or
const_revese_iterator, in which case it is possible the function can be
const. Unfortunately, it is not possible to remove the hard coding of
cbegin, cend, crbegin and crend due to the need to handle auto, as in
the following code snippet:

    void cbegin_auto(void)
    {
        for (auto it = m_str.cbegin(); it != m_str.cend(); ++it) {;}
    }
2022-02-02 19:37:06 +01:00
chrchr-github dad64bfcc8
Fix FP shadowFunction with default destructor implementation / Tests for , , , , () 2022-02-02 19:30:49 +01:00
chrchr-github 69ee464dff
Fix test for () 2022-02-02 19:29:01 +01:00
chrchr-github 8cf5c8fbf2
Fix FP unusedStructMember with static object () 2022-02-02 19:28:16 +01:00