Paul Fultz II
3e09503561
Fix 11087: false negative: usage of reference to member of temporary object not detected ( #4217 )
...
* Fix 11087: false negative: usage of reference to member of temporary object not detected
* Format
* Add another test case
* Fix FP with pointer
* Format
2022-06-16 19:26:36 +02:00
Paul Fultz II
9cecc8468e
Fix 10570: Improve check; condition then pointer dereference, different pointers ( #4216 )
...
* Try to use after assign in loop
* Update valueflow forward to handle init tokens
* Fix tests
* Make test TODO
* Format
* Add tests
* Format
* Fix ubsan error
* Use simpleMatch
2022-06-16 19:26:23 +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
Daniel Marjamäki
dbb12cb333
Tokenizer: Remove some functions from simplifyTokenList2
2022-06-16 14:06:07 +02:00
chrchr-github
176eefcbf3
Fix #10655 FN bitwiseOnBoolean with unseen function ( #4214 )
2022-06-14 23:08:17 +02:00
chrchr-github
de9b65c737
Add tests for #9194 , #10415 , #4759 , #9876 , #10006 ( #4213 )
...
* 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
* Add tests for #9194 , #10415 , #4759 , #9876 , #10006
2022-06-14 13:05:07 +02:00
chrchr-github
6d22d6a8ae
Fix FP unusedVar with side effects in destructor ( #4212 )
2022-06-14 09:55:22 +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
Daniel Marjamäki
343d04feb4
Tokenizer: Remove simplifyCharAt from simplifyTokenList2
2022-06-12 15:14:48 +02:00
Daniel Marjamäki
8255e32540
cppcheck build dir: do not produce invalid dump file if code is unchanged and checking is skipped.
2022-06-12 11:08:28 +02:00
Paul Fultz II
d4fb5652c0
Fix 10619: Valueflow: Library function in subfunction does not propagate all values ( #4209 )
2022-06-12 07:17:28 +02:00
Paul Fultz II
bd63534a1c
Fix 10740: valueflow; conditional value. incremented value is oob. ( #4208 )
2022-06-12 07:16:28 +02:00
chrchr-github
ecb24e28bc
Fix #10191 FP redundantCopyLocalConst - referenced variable changes ( #4202 )
2022-06-11 16:58:33 +02:00
PKEuS
cb382ac52c
C++20 support: Support consteval and constinit ( #4203 )
...
Backported from LCppC.
2022-06-11 15:28:20 +02:00
Paul Fultz II
8945c151f5
Fix 11124: FP knownConditionTrueFalse with fruit ( #4196 )
...
* Update valueType
* Allow comparisons
* Fix compare op
* Add test
* Format
* Fix FP
* Format
2022-06-11 11:02:04 +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
Paul Fultz II
653a1ea83e
Fix 11100: FP knownConditionTrueFalse with getter/setter member functions ( #4198 )
...
* Fix 11100: FP knownConditionTrueFalse with getter/setter member functions
* Format
2022-06-11 11:00:40 +02:00
PKEuS
82af702c6f
LCppC backport: Restored Check: Detect negative VLA and allocation (new[]) sizes ( #4187 )
2022-06-11 09:55:38 +02:00
PKEuS
99ce89c003
Improvement: Set varId for variables with global scope operator :: Refactorization: Moved internal class from tokenize.h to tokenize.cpp ( #4184 )
...
Merged from LCppC.
2022-06-11 08:11:16 +02:00
Paul Fultz II
c9b85010f9
Fix 11096: FP knownConditionTrueFalse in do while loop ( #4192 )
...
* Check for loop
* Improve handling of exit values
* Add more checks to test
* Simplify
* Remove unnecessary test
* Fix typo
* Format
* Use simpleMatch
2022-06-10 20:42:02 +02:00
chrchr-github
829ca9ab7f
Fix #10935 FP: compareBoolExpressionWithInt with enum and template parameter ( #4193 )
2022-06-10 20:40:37 +02:00
chrchr-github
51c8630bb3
Fix #10618 FP knownConditionTrueFalse with virtual function ( #4194 )
...
* Fix #10618 FP knownConditionTrueFalse with virtual function
* Remove redundant check
2022-06-10 20:17:57 +02:00
Daniel Marjamäki
375880988c
Tokenizer: remove removeRedundantAssignment from simplifyTokenList2
2022-06-10 12:35:05 +02:00
chrchr-github
90392faa2b
Fix crash on nullptr deref ( #4189 )
2022-06-09 18:25:17 +02:00
Daniel Marjamäki
a76ba698c2
Tokenizer: remove simplifyCompoundAssignment from simplifyTokenList2
2022-06-09 07:38:27 +02:00
Daniel Marjamäki
c0f3d5b2fb
Tokenizer: remove simplifyAssignmentInFunctionCall used in simplifyTokenList2
2022-06-08 19:08:18 +02:00
PKEuS
898a3a25a1
ValueType: Added additional unit test ( #4185 )
...
Removed unnecessary library export
Backported from LCppC.
2022-06-08 15:27:56 +02:00
PKEuS
44097b59ff
Implemented error handling in cppcheck::Platform::loadFromXmlDocument(), enabled related unit test ( #8409 ) ( #4181 )
2022-06-08 12:35:23 +02:00
Daniel Marjamäki
86a8d88729
Tokenizer: Remove simplification of math functions from simplifyTokenList2
2022-06-08 09:58:11 +02:00
Daniel Marjamäki
e43d2b8a80
runformat
2022-06-08 09:21:01 +02:00
chrchr-github
bb3f490edd
Fix #11090 Infinite recursion in findTypeInBase() ( #4178 )
2022-06-08 09:20:16 +02:00
Oliver Stöneberg
9367be804e
fixed `modernize-use-equals-delete` warnings in headers ( #4177 )
2022-06-07 21:25:23 +02:00
chrchr-github
69834d537b
Fix #9997 False negative: variable is not used ( #4104 )
2022-06-07 21:20:33 +02:00
chrchr-github
1d677c57a8
Fix #11126 FN: noExplicitConstructor with single default parameter ( #4174 )
2022-06-07 21:15:13 +02:00
chrchr-github
b80d06b69e
Don't warn for 'x | MACRO' when MACRO is 0 ( #4176 )
2022-06-07 21:13:31 +02:00
chrchr-github
52453947c8
Don't warn for 'x | 0' in macro ( #4172 )
...
* Fix #11082 FN badBitmaskCheck for binary or with 0
* Add test for #10703
* Don't warn for 'x | 0' in macro
* Add test for #10876
2022-06-06 11:17:36 +02:00
orbitcowboy
326d340d76
Added a regression test; A real-world test case like this was found by daca@home: ftp://ftp.de.debian.org/debian/pool/main/o/ogdi-dfsg/ogdi-dfsg_4.1.0+ds.orig.tar.gz head ogdi-ogdi_4_1_0/ogdi/c-api/ecsinfo.c:637:26: error: Invalid strcspn() argument nr 2. A nul-terminated string is required. [invalidFunctionArgStr].
2022-06-04 19:33:56 +02:00
chrchr-github
f962436826
Fix #11082 FN badBitmaskCheck for binary or with 0 ( #4170 )
...
* Fix #11082 FN badBitmaskCheck for binary or with 0
* Add test for #10703
2022-06-04 17:25:10 +02:00
orbitcowboy
433ce58fe6
Fixed FP found with daca@home: ftp://ftp.de.debian.org/debian/pool/main/libs/libslirp/libslirp_4.7.0.orig.tar.bz2; head libslirp-v4.7.0/src/tftp.c:336:20: error: Invalid strcasecmp() argument nr 1. A nul-terminated string is required. [invalidFunctionArgStr]
2022-06-04 12:00:54 +02:00
orbitcowboy
1c1c72058f
Fixed FP found with daca@home: ftp://ftp.de.debian.org/debian/pool/main/libs/libslirp/libslirp_4.7.0.orig.tar.bz2; head libslirp-v4.7.0/src/tftp.c:336:20: error: Invalid strcasecmp() argument nr 1. A nul-terminated string is required. [invalidFunctionArgStr]
2022-06-04 07:46:28 +02:00
chrchr-github
e6f2929fac
Fix #11085 FN constVariable with range-based for ( #4118 )
2022-06-03 19:24:59 +02:00
orbitcowboy
a74bb485b0
Fixed TODO_ASSERT
2022-06-03 18:59:09 +02:00
orbitcowboy
6680bf9790
Fixed TODO_ASSERT
2022-06-03 18:35:11 +02:00
chrchr-github
111f4e17da
Fix #11117 FP nullPointerArithmetic when adding 0 ( #4167 )
2022-06-03 13:11:54 +02:00
orbitcowboy
1a4bd0a7b3
Fixed FP, found with daca@home: ftp://ftp.de.debian.org/debian/pool/main/k/knot/knot_3.1.8.orig.tar.xz; knot-3.1.8/tests/knot/test_confio.c:301:18: error: Invalid strcmp() argument nr 2. A nul-terminated string is required. [invalidFunctionArgStr]
2022-06-03 13:10:45 +02:00
orbitcowboy
345411a68c
Fixed FP found with daca@home: ftp://ftp.de.debian.org/debian/pool/main/i/imx-usb-loader/imx-usb-loader_0~git20200517.30b43d69.orig.tar.gz; imx_usb_loader/imx_loader_config.c:130:16: error: Invalid strncat() argument nr 2. A nul-terminated string is required. [invalidFunctionArgStr]
2022-06-03 10:20:19 +02:00
orbitcowboy
a59e510cdc
Fixed FP - invalidFunctionArgStr, found with daca@home: ftp://ftp.de.debian.org/debian/pool/main/i/ion/ion_3.2.1+dfsg.orig.tar.gz; ion-open-source/arch-rtems/pmqlsi.c:146:18: error: Invalid mq_send() argument nr 2. A nul-terminated string is required. [invalidFunctionArgStr]
2022-06-03 10:06:32 +02:00
orbitcowboy
8382ea7692
std.cfg: Improved configuration of strpbrk() and added regression tests. These cases were found in the wild (daca@home: ftp://ftp.de.debian.org/debian/pool/main/i/ion/ion_3.2.1+dfsg.orig.tar.gz, ion-open-source/contrib/dtnperf/dtnperf/src/utils.c:71:32: error: Invalid strpbrk() argument nr 2. A nul-terminated string is required. [invalidFunctionArgStr]).
2022-06-03 08:36:25 +02:00
orbitcowboy
4e9565b4e6
Fixed FP invalidFunctionArgStr, found a daca@home: ftp://ftp.de.debian.org/debian/pool/main/h/haskell-hs-bibutils/haskell-hs-bibutils_6.10.0.0.orig.tar.gz
2022-06-02 23:39:04 +02:00
Paul Fultz II
72342de0da
Fix 11114: FP knownConditionTrueFalse across functions ( #4163 )
...
* Fix 11114: FP knownConditionTrueFalse across functions
* Format
2022-06-02 23:24:11 +02:00
Oliver Stöneberg
133b9c2790
some `test/CMakeLists.txt` cleanups ( #4067 )
...
* test/CMakeLists.txt: removed unnecessary `CTest` include - gets rid of additional CTest/CDash targets
* test/CMakeLists.txt: adjusted CMake version - `CMAKE_MATCH_<n>` requires 3.9`
* test/CMakeLists.txt: sorted `add_cfg()` calls
* test/CMakeLists.txt: extract test fixtures based on `REGISTER_TEST` macro
* test/CmakeLists.txt: added TODO
2022-06-02 22:26:01 +02:00
orbitcowboy
67795cdfcf
Fixed FPs from Ticket 11119 - invalidFunctionArgStr with null-terminated strings ( #4164 )
...
* Fixed first FP from #11119 - invalidFunctionArgStr with null-terminated strings
* Fixed second test case from #11119 .
* Fixed another FP, found on daca@home ftp://ftp.de.debian.org/debian/pool/main/g/glhack/glhack_1.2.orig.tar.gz.
* Format
2022-06-02 19:30:29 +02:00
orbitcowboy
58460edaf8
Fixed crash due to missing null pointer check.
2022-06-02 11:32:55 +02:00
orbitcowboy
0eae0023a3
posix.cfg: Added missing '<strz/>'-flags
2022-06-02 09:41:10 +02:00
orbitcowboy
63a8eac4d3
std.cfg: Added missing '<strz/>'-flags
2022-06-02 09:23:22 +02:00
orbitcowboy
886b5d1039
Improved invalidFunctionArgStr checking and detect more cases where a NON-null-terminated string is used to call functions, configured with <strz/>.
2022-06-02 01:09:09 +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
423e67bd6a
Fix FP memleak ( #4145 )
2022-05-30 06:55:15 +02:00
Paul Fultz II
d7c914bd3e
Handle subfunction values in valueflow conditions ( #4128 )
2022-05-29 19:57:10 +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
16a4449901
Fix crash with statement expression ( #4142 )
2022-05-28 00:11:23 +02:00
chrchr-github
16af6561c2
Fix FP memleak with unknown ptr typedef ( #4141 )
...
* Fix #11019 FN memleak with redundant pointer op
* Style
* Fix #7705 FN: Memory leak not detected on struct member
* Fix FP memleak with function call, fix cppcheckError
* Fix FP memleak with array
* Fix FPs memleak with array and ptr to ptr
* Fix FP memleak with unknown ptr typedef
* Format
2022-05-27 23:52:56 +02:00
chrchr-github
d5d6da0dd4
Fix #11094 FP unreadVariable with unique_ptr and unknown type ( #4140 )
2022-05-27 17:17:50 +02:00
orbitcowboy
558e00272d
windows.cfg: Improved configuration of _mbscmp() and _mbscmp_l().
2022-05-27 12:28:30 +02:00
Rikard Falkeborn
068e5bad27
Fix #9966 : FP memleak with multiple assignments in if-statement ( #4138 )
...
Similar to how we do for assignments outside if-statements, bail out
since we do not track multiple variables.
2022-05-27 07:57:43 +02:00
chrchr-github
19dd59eae6
Fix FPs memleak with array and ptr to ptr ( #4139 )
...
* Fix #11019 FN memleak with redundant pointer op
* Style
* Fix #7705 FN: Memory leak not detected on struct member
* Fix FP memleak with function call, fix cppcheckError
* Fix FP memleak with array
* Fix FPs memleak with array and ptr to ptr
2022-05-26 15:27:36 +02:00
chrchr-github
86763b7b0a
Fix FP memleak with array ( #4133 )
...
* Fix #11019 FN memleak with redundant pointer op
* Style
* Fix #7705 FN: Memory leak not detected on struct member
* Fix FP memleak with function call, fix cppcheckError
* Fix FP memleak with array
2022-05-26 00:03:30 +02:00
chrchr-github
2b611709e2
Add test for #11066 ( #4136 )
2022-05-25 23:28:54 +02:00
chrchr-github
1ed280fe63
Fix FP memleak with function call, fix cppcheckError ( #4130 )
...
* Fix #11019 FN memleak with redundant pointer op
* Style
* Fix #7705 FN: Memory leak not detected on struct member
* Fix FP memleak with function call, fix cppcheckError
2022-05-24 14:02:06 +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
orbitcowboy
c30333425b
Added a regression test for ticket #8892 - FN: knownConditionTrueFalse
2022-05-24 09:21:21 +02:00
Paul Fultz II
5999b35130
Fix 10944: FN: knownConditionTrueFalse ( #4124 )
...
* Fix 10944: FN: knownConditionTrueFalse
* Use or
* Format
2022-05-23 23:22:08 +02:00
chrchr-github
1ced94be43
Fix #11019 FN memleak with redundant pointer op / #7705 FN: Memory leak not detected on struct member ( #4126 )
...
* Fix #11019 FN memleak with redundant pointer op
* Style
* Fix #7705 FN: Memory leak not detected on struct member
2022-05-23 23:21:36 +02:00
Paul Fultz II
e2c35abde5
Fix 11050: False positive: unreadVariable for class variable when another function uses the same variable name ( #4121 )
2022-05-22 09:20:32 +02:00
chrchr-github
22a4fdb6c4
Fix crash in checkPassByReference() ( #4122 )
2022-05-21 16:02:35 +02:00
Daniel Marjamäki
1f6554e2e8
Update copyright year
2022-05-21 12:18:27 +02:00
chrchr-github
2a7f00cf9a
Fix #8545 FN Condition '...' is always true ' uint16_t i; ( i <= 0xFFFF)' ( #4114 )
2022-05-21 08:33:42 +02:00
Paul Fultz II
feaef46436
Fix 11076: Assert failure / crash with loop over init list ( #4119 )
2022-05-21 08:25:09 +02:00
Paul Fultz II
a62fb986a5
Fix 11090: Infinite recursion in findTypeInBase() ( #4120 )
2022-05-21 08:24:29 +02:00
chrchr-github
2b723eafcb
Fix ValueType for references in range-based for loop ( #4116 )
...
* Fix ValueType for references in range-based for loop
* Format
2022-05-20 08:48:01 +02:00
chrchr-github
112b1573c5
Fix #11078 FN constructing string from nullptr / #11079 FN unread variables ( #4112 )
...
* Fix #11078 FN constructing string from nullptr / #11079 FN unread variables
* Format
2022-05-18 13:52:44 +02:00
Paul Fultz II
90e6c10c12
Fix 11072: FP arrayIndexOutOfBounds, nullPointer with nested loops ( #4113 )
...
* Fix 11072: FP arrayIndexOutOfBounds, nullPointer with nested loops
* Format
* Remove print statement
2022-05-18 08:29:30 +02:00
orbitcowboy
06216b06fc
Fixed failing CI.
2022-05-15 08:53:21 +02:00
orbitcowboy
4f410ffb79
library: Improved argument <valid>-interface to defined values that are explicitly excluded. ( #4111 )
...
* library: Improved <valid>-interface to defined values that are explicitly excluded.
* std.cfg: Improved configuration of remainder[fl]().
* Fixed failing self check
* Fixed failing self check
* std.cfg: Added support for std::remquo().
2022-05-14 16:05:18 +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
Paul Fultz II
fbba72ab5a
Fix 11057: FP danglingTemporaryLifetime with reference member ( #4103 )
...
* Fix 11057: FP danglingTemporaryLifetime with reference member
* Add test
* Format
* Use ast for number of arguments
* Get number of arguments using ast
* Skip aggregate constructor when there are too many arguments
* Format
2022-05-13 06:51:07 +02:00
Paul Fultz II
5f9bee9b91
Fix 11056: FP uninitvar with known condition in loop ( #4107 )
...
* Fix 11056: FP uninitvar with known condition in loop
* Format
2022-05-12 06:37:48 +02:00
Paul Fultz II
6d3208ecb0
Fix 11062: false positive: knownEmptyContainer (regression) ( #4106 )
...
* Fix 11062: false positive: knownEmptyContainer (regression)
* Format
2022-05-12 06:24:16 +02:00
Paul Fultz II
5d8da2b83c
Fix 11035: FP arrayIndexOutOfBoundsCond with array and vector ( #4105 )
...
* Fix 11035: FP arrayIndexOutOfBoundsCond with array and vector
* Format
* Move comment
2022-05-12 06:21:33 +02:00
chrchr-github
e7e8b1baf9
Fix #9861 FN: "static" not suggested for non-const method ( #4101 )
...
* Fix #9861 FN: "static" not suggested for non-const method
* Format
* Make functions static
* static
2022-05-11 20:01:22 +02:00
chrchr-github
63a1698335
Fix #11059 FP multiCondition when variable is assigned in if/else ( #4102 )
2022-05-11 20:01:13 +02:00
orbitcowboy
d0b7fe887a
Added a regression test for #4103 - Comparing Boolean variables (> or <)
2022-05-11 11:30:02 +02:00
chrchr-github
942dbad11c
Fix #7197 not getting expected warning in relational comparison of booleans ( #4095 )
...
* Fix #7197 not getting expected warning in relational comparison of booleans
* return nullptr
2022-05-11 08:09:32 +02:00
orbitcowboy
e9641e6de5
std.cfg: Attempt to fix failing CI
2022-05-10 23:09:10 +02:00
Daniel Marjamäki
72ba85a2fc
AST: Fix AST for array size calculation in cast (char (*)[...])
2022-05-10 22:47:57 +02:00
Daniel Marjamäki
4257f9d46a
Tokenizer: fix for __attribute__ before function that returns a reference
2022-05-10 20:59:24 +02:00
chrchr-github
a70d11adb6
Fix #11052 inline static global struct declaration interferes with checks ( #4098 )
2022-05-10 20:43:11 +02:00
orbitcowboy
f23111d610
std.cfg: Improved configuration of some <thread.h> (since C11) functions.
2022-05-10 19:21:41 +02:00