orbitcowboy
d782cd629a
posix.cfg: Added overlapping data check for bcopy().
2021-07-11 16:38:25 +02:00
Daniel Marjamäki
d9dacc97e4
virtual call in constructor; warn when function is explicitly virtual
2021-07-11 11:03:31 +02:00
Daniel Marjamäki
42388f8da8
Remove TestSamples
2021-07-10 21:04:38 +02:00
Paul Fultz II
afac0e8ad3
Fix colors in output of TestSamples ( #3332 )
2021-07-10 20:14:38 +02:00
orbitcowboy
10fb1851c5
Added more overlapping data configurations
2021-07-10 18:41:36 +02:00
orbitcowboy
7ad64891ea
Added tests for overlapping data.
2021-07-10 18:28:26 +02:00
Daniel Marjamäki
9841e0ed96
new check; file can not be opened for read and write access at the same time on different streams (misra rule 22.3)
2021-07-10 13:59:47 +02:00
orbitcowboy
b68c5dee07
windows.cfg: Added support for _mbscpy().
2021-07-10 09:27:22 +02:00
orbitcowboy
c38a43c353
std.cfg: Added overlappingWriteFunction check to wcscpy().
2021-07-10 09:20:51 +02:00
Daniel Marjamäki
a8fb0309fd
missingReturn; Improved handling of noreturn function
2021-07-10 08:59:01 +02:00
Daniel Marjamäki
53955b48d2
missingReturn; Fixed false negative for goto-label
2021-07-10 08:49:48 +02:00
Daniel Marjamäki
8f1cb2304f
missingReturn; Add missing ASSERT_EQUALS in test
2021-07-10 08:45:04 +02:00
Daniel Marjamäki
c6f7a78ebb
missingReturn; Fixed false positives
2021-07-10 08:37:10 +02:00
Paul Fultz II
9fc5b9472d
Fix 10353: FP knownConditionTrueFalse with conditional assignment ( #3333 )
2021-07-10 07:35:16 +02:00
orbitcowboy
652e2765bc
std.cfg: Added support for wcsncpy regarding data-overlapping
2021-07-09 16:32:54 +02:00
Daniel Marjamäki
86f1acc223
overlapping data; use the size value given by size-arg
2021-07-09 13:43:29 +02:00
Daniel Marjamäki
ce58748690
library: add attribute strlen-arg for <not-overlapping-data>
2021-07-09 13:25:01 +02:00
orbitcowboy
58811808d5
std.cfg: Improved configuration of 'strncpy', which is vulnerable for overlapping write issues.
2021-07-09 09:48:24 +02:00
Paul Fultz II
2300a773e1
Fix 10336: AST cyclic dependency on valid C++ code ( #3331 )
2021-07-09 07:22:24 +02:00
Paul Fultz II
8dc1fa7a59
Add colors to CLI reporting ( #3304 )
2021-07-08 21:21:35 +02:00
Daniel Marjamäki
56924643be
Fixed #10347 (ValueFlow: No known value set for sizeof(a[0]))
2021-07-08 18:18:44 +02:00
orbitcowboy
3e7b6f262d
std.cfg: Added not-overlapping-data configuration to wmemcpy()
2021-07-08 17:12:53 +02:00
Daniel Marjamäki
7cb66d56f3
missingReturn; fixed false positive with trailing return type
2021-07-08 13:50:26 +02:00
Daniel Marjamäki
ef0af26d9f
missingReturn; Fixed FP when function is declared in macro
2021-07-08 13:14:11 +02:00
Daniel Marjamäki
00a9671f46
misra: implement 8.1
2021-07-07 13:34:55 +02:00
Paul Fultz II
3b9c399f72
Fix 10338: Hang/Crash in valueflow ( #3328 )
2021-07-07 08:20:32 +02:00
orbitcowboy
7d7241b076
#9772 : FP uninitvar: in cppcheck 2.1; Added a regression to test
2021-07-06 14:24:07 +02:00
Maksim Derbasov
6b8d0be431
New check: [perf] Copy elision optimization can't be applied for `return std::move(local)` ( #3281 )
2021-07-06 08:07:46 +02:00
Daniel Marjamäki
6234b5438e
New check: Writing overlapping data, detect undefined behavior
2021-07-05 22:07:41 +02:00
Daniel Marjamäki
6cb8f87798
missing return; fixed false positive for 'return {};'
2021-07-04 19:59:22 +02:00
Daniel Marjamäki
4fd33ef2b5
test/cli: fixed missing returns in test cases
2021-07-04 18:25:19 +02:00
Daniel Marjamäki
036c71d967
Fixed #5462 (non-void function does not return a value)
2021-07-04 11:27:57 +02:00
Daniel Marjamäki
c489626167
updated copyright year
2021-07-04 08:09:11 +02:00
Paul Fultz II
fb9d659e25
Fix 10326: Regression: ValueFlow; Wrong Uninit value after do while ( #3312 )
2021-07-03 09:12:26 +02:00
Armin Müller
fc90598077
Typos found by running "codespell" ( #3324 )
2021-07-02 17:41:51 +02:00
Robert Reif
68898e2be0
fix #10335 (Type alias remains unknown with using) ( #3323 )
...
Co-authored-by: Robert Reif <reif@FX6840>
2021-07-02 06:19:26 +02:00
Daniel Marjamäki
1a5449cbeb
Fixed #10327 (ValueFlow; Wrong Uninit value in called function)
2021-07-01 22:08:00 +02:00
Daniel Marjamäki
869eac5670
astyle formatting
2021-07-01 21:09:32 +02:00
chrchr-github
7a51fc8232
Add regression test for #8942 ( #3321 )
2021-07-01 21:09:06 +02:00
chrchr-github
9be88a06fe
Add regression test for #9176 ( #3319 )
2021-07-01 13:58:00 +02:00
Daniel Marjamäki
e1cff1d1ef
Fixed #10334 (AST: hang with c++ initializer and emplace_back)
2021-06-30 21:40:45 +02:00
Daniel Marjamäki
e50f7a3e09
astyle formatting
2021-06-30 20:27:35 +02:00
chrchr-github
5b1420ff64
Add regression test for #10215 ( #3317 )
2021-06-29 19:42:47 +02:00
Daniel Marjamäki
1783fd1bba
duplicateBreak; Allow extra return that clarifies for tool(s) that function does not continue
2021-06-29 11:17:12 +02:00
Daniel Marjamäki
05df31c12a
Fixed unit tests
2021-06-27 09:04:47 +02:00
Daniel Marjamäki
2a2e071a85
Tokenizer::simplifyAttribute; Set function attribute for function pointer
2021-06-26 14:23:39 +02:00
Paul Fultz II
66956ed959
Fix 10323: Wrong known value. x!=0 does not mean that x==1 ( #3308 )
2021-06-26 09:16:45 +02:00
Paul Fultz II
508188df2b
Fix 10297: Regression; ValueFlow known value, sign conversion ( #3307 )
2021-06-26 09:16:04 +02:00
Daniel Marjamäki
9769afe434
knownConditionTrueFalse; avoid several warnings when nonzero expression is compared to see if it is positive or negative
2021-06-25 16:25:25 +02:00
Daniel Marjamäki
2f7f43e1f2
astyle formatting
2021-06-24 23:19:59 +02:00
chrchr-github
39f9bc7422
Fix #10304 : std::distance() returns std::ptrdiff_t ( #3297 )
2021-06-24 23:19:29 +02:00
Paul Fultz II
b13e44fce5
Fix 10309 and 10034: internalAstError with init lists ( #3303 )
2021-06-24 08:25:13 +02:00
Paul Fultz II
6e74fc64b9
Fix 10317: Regression: internalAstError on valid C++ code ( #3302 )
2021-06-24 08:22:03 +02:00
Paul Fultz II
dd178c3ad9
Fix 10314: Possible nullPointerRedundantCheck false positive ( #3298 )
2021-06-19 13:59:48 +02:00
Paul Fultz II
5922d5178b
Fix 10321: Two flags confuse null pointer check ( #3300 )
2021-06-19 13:58:57 +02:00
Paul Fultz II
eb7b225fc1
Fix 10119: ValueFlow; object member is not uninitialized. happens when there is static member also. ( #3299 )
2021-06-19 13:58:18 +02:00
Daniel Marjamäki
a7707a457d
astyle formatting
2021-06-14 07:39:41 +02:00
shane
a5664c3e49
allow token iteration in range for
2021-06-14 07:39:01 +02:00
Daniel Marjamäki
03445c01c1
Fix false positives when class might inherit from VCL TObject class
2021-06-13 18:56:04 +02:00
Daniel Marjamäki
7dbca470f7
Suppressions; Fixed problem with cppcheck build dir is used
2021-06-12 18:19:00 +02:00
Daniel Marjamäki
118ad67645
testrunner: return value in non-void functions
2021-06-12 16:43:48 +02:00
Daniel Marjamäki
83d406806f
CI; Fixed problems in windows paths
2021-06-12 12:45:31 +02:00
Daniel Marjamäki
4a4808e0ff
ImportProject; Try to use relative paths
2021-06-12 11:10:35 +02:00
Paul Fultz II
f55a4563f9
Fix 10308: danglingTemporaryLifetime confused by function parameter ( #3292 )
2021-06-09 09:21:03 +02:00
Paul Fultz II
f3a33ea330
Fix 10294: ValueFlow: Wrong <Uninit> value below loop ( #3291 )
2021-06-09 09:20:43 +02:00
Daniel Marjamäki
3c3435dd10
Fix bug in Tokenizer::simplifyVarDecl
2021-06-06 08:13:40 +02:00
Paul Fultz II
668b88d7c0
Fix 10284: False positive; valueFlowBeforeCondition does not seem to care about increment ( #3287 )
2021-06-04 21:40:57 +02:00
Paul Fultz II
a14922ed85
Fix 10238: FP knownConditionTrueFalse std::string from const char* assumed non-empty ( #3288 )
2021-06-04 17:22:05 +02:00
Paul Fultz II
537fb5bcd9
Fix 10264: FP invalidContainer when address of container is passed inside struct ( #3286 )
2021-06-04 17:20:47 +02:00
Paul Fultz II
b23c5aa742
Fix 10023: ValueFlow; Wrong result of post-increment in reverse analysis ( #3289 )
2021-06-04 17:20:21 +02:00
Paul Fultz II
486e440c4a
Fix 10298: ValueFlow: Wrong known value, 'x == -1' implicit unsigned cast for rhs ( #3277 )
2021-06-04 17:17:41 +02:00
Paul Fultz II
95c872b1ec
Fix todo test for returning a dangling reference ( #3284 )
2021-06-04 17:15:39 +02:00
orbitcowboy
f626035963
std.cfg: Added support for more interfaces
2021-06-03 08:07:53 +02:00
orbitcowboy
39912b5096
std.cfg: Added support for more interfaces
2021-06-03 07:55:26 +02:00
orbitcowboy
601ca6b3c5
Merge branch 'main' of https://github.com/danmar/cppcheck into main
2021-06-03 07:33:47 +02:00
orbitcowboy
4c81a59c0b
std.cfg: Added support for more interfaces
2021-06-03 07:33:23 +02:00
Paul Fultz II
3e78e76fe8
Fix issue 10076: ValueFlow: False positive after address of var is taken 'T t = {{{&var}}};' ( #3283 )
2021-06-03 07:31:46 +02:00
Paul Fultz II
548ec10824
Fix issue 10306: FP knownConditionTrueFalse with modulo result converted to bool ( #3282 )
2021-06-03 07:26:36 +02:00
dummyunit
9652ca39a3
Improve support for labels in simplifyAddBraces step ( #3278 )
...
Previously only a single regular label before a compound statement was
allowed in simplifyAddBracesPair() after if/switch/do/while/for.
This patch adds support for:
* case-labels;
* labels before a single statement;
* labels before try/catch blocks;
* multiple consecutive labels.
Additionally the code for skipping a case label was extracted into a
separate function from simplifyLabelsCaseDefault() and reused in
simplifyAddBracesPair().
2021-06-02 07:00:37 +02:00
Maksim Derbasov
06c4542ac2
New check for rethrow without current handled exception ( #3270 )
2021-05-31 10:39:24 +02:00
Daniel Marjamäki
a994bd5ba5
Uninitialized variables; Add todo test case
2021-05-28 18:09:43 +02:00
Paul Fultz II
5f0fe1dfe7
Fix another FP with range for macro ( #3276 )
2021-05-26 04:52:55 +02:00
Daniel Marjamäki
a4653a057a
Uninitialized variables; Fixed FP for range for loop
2021-05-25 20:37:22 +02:00
Daniel Marjamäki
7d84b8f1bc
Uninitialized variables; Fix FP when assigning struct members
2021-05-25 16:13:32 +02:00
Daniel Marjamäki
8d97cce81b
Uninitialized variables; Added true positive test
2021-05-25 07:31:01 +02:00
Daniel Marjamäki
4cccc710ef
Uninitialized variables; Fixed FP when bitmask is used on address
2021-05-24 20:55:13 +02:00
Robert Reif
c7be967769
fix #10295 (false negatives by inconsistent 'void' in argument list (declaration vs definition)) ( #3274 )
...
Co-authored-by: Robert Reif <reif@FX6840>
2021-05-24 19:32:15 +02:00
Daniel Marjamäki
d3bb84cd0e
Uninitialized variables; Added TP tests for ignored operators
2021-05-24 17:53:16 +02:00
Daniel Marjamäki
b7803ea6fb
Uninitialized variables; Fixed false positives for reference cast and dereferencing address of uninitialized variable
2021-05-24 17:50:28 +02:00
Daniel Marjamäki
4ad90bf6f1
Uninitialized variables; Fixed FP in inner for loop
2021-05-24 17:02:19 +02:00
Daniel Marjamäki
fa72ec20b2
Uninitialized variables; avoid false positives when passing uninitialized variable to unknown function
2021-05-24 15:54:09 +02:00
Daniel Marjamäki
a2e709a652
Uninitialized variables; Try to remove heuristics for assignment with overloaded <<. That is non-standard behavior for the << operator. Let's see how much FPs we get.
2021-05-24 13:17:50 +02:00
Daniel Marjamäki
3a498de306
extracttests; do not extract TestBufferOverrunterminateStrncpy tests
2021-05-24 13:17:29 +02:00
orbitcowboy
df6b0bcd87
#10026 : Added a regression test for 'false negative: duplicateExpression'
2021-05-24 08:54:45 +02:00
Paul Fultz II
ab50a75d8a
Fix 10289: ValueFlow; Wrong known value 'size_t - uint16_t > 0' ( #3273 )
2021-05-24 08:28:21 +02:00
Daniel Marjamäki
8ad0905e3b
Uninitialized variables; Fixed FP in valueflow-based checking
2021-05-23 18:43:34 +02:00
Daniel Marjamäki
f968761382
Uninitialized variables; Remove TODO comment in test, test is working as it should now.
2021-05-23 14:57:43 +02:00
Daniel Marjamäki
d64aea90fa
astyle formatting
2021-05-23 14:36:45 +02:00
Daniel Marjamäki
8828619855
Fixed #10293 (Uninitialized variables; False positive for array in union)
2021-05-23 12:06:23 +02:00
Daniel Marjamäki
85723f8605
Uninitialized variables; Different heuristic needed for const pointer function parameter
2021-05-23 11:45:47 +02:00
dummyunit
247b2d8c83
Support array types in template simplifier ( #3267 )
2021-05-23 10:40:09 +02:00
Paul Fultz II
47a4144b47
Fix 10288: ValueFlow; False positives because of wrong known value when there is sign cast ( #3268 )
2021-05-23 10:20:29 +02:00
Paul Fultz II
e2d9aaf23b
Fix 10286: false positive: uninitvar ( #3271 )
...
* Fix 10286: false positive: uninitvar
* Remove header
2021-05-23 07:58:19 +02:00
Paul Fultz II
8541e0503e
Fix 10290: false negative: container out of bounds ( #3269 )
2021-05-22 23:33:13 +02:00
Daniel Marjamäki
5f6b56ada2
buffer overrun; Fixed false negative for dynamically allocated float buffer
2021-05-22 15:39:20 +02:00
Daniel Marjamäki
87554bed7a
Redundant pointer op; Fixed false positives when macro is used
2021-05-22 14:18:29 +02:00
Daniel Marjamäki
9a9f14bd8a
Buffer overflow; Fixed FPs when array size is 1
2021-05-22 12:13:39 +02:00
Daniel Marjamäki
1cb48ad418
Uninitialized variables; Fixed false positive in sizeof()
2021-05-22 11:04:42 +02:00
Daniel Marjamäki
f5f3a8d4d7
Fix syntax errors in test cases
2021-05-22 09:44:18 +02:00
Paul Fultz II
c63aa2f2cc
Fix 10263: FP containerOutOfBounds when container is accessed via pointer ( #3265 )
2021-05-22 08:36:51 +02:00
Maksim Derbasov
f0d1822a83
Better handling functions with try block for throwInNoexceptFunction ( #3264 )
2021-05-22 08:36:28 +02:00
Paul Fultz II
1e3ab460a3
Fix 10254: false positive: arrayIndexOutOfBounds in inline function ( #3266 )
2021-05-22 08:20:09 +02:00
Daniel Marjamäki
22ae4543a6
Fixed 'make checkcfg'
2021-05-22 07:39:27 +02:00
Daniel Marjamäki
68c46e146d
Uninitialized variables; Fixed FP when returning malloc pointer
2021-05-21 17:10:49 +02:00
Daniel Marjamäki
2d3d7db730
Uninitialized variables; fix syntax errors in test cases
2021-05-21 15:30:52 +02:00
Daniel Marjamäki
1e6a574cff
Uninitialized variables; Passing address of uninitialized variable to function
2021-05-21 15:27:13 +02:00
Daniel Marjamäki
8adfcc848c
Uninitialized variables; check RHS expression
2021-05-21 14:31:25 +02:00
Daniel Marjamäki
cc74c8e1da
Uninitialized variables; Moved test case. ValueFlow can detect issue.
2021-05-21 10:42:58 +02:00
Paul Fultz II
5409fa8afd
Fix disabled valueFlowUninit tests ( #3262 )
2021-05-21 07:28:34 +02:00
Daniel Marjamäki
4746d4b819
Uninitialized variables; Improved checking of loops
2021-05-20 22:56:14 +02:00
Daniel Marjamäki
8e650e4243
Uninitialized variable; Fixed FP after unconditional scope with conditional initialization
2021-05-20 18:38:59 +02:00
Daniel Marjamäki
f1fff5e904
Fixed #10279 (ValueFlow/TokenList: function pointer dereference and call)
2021-05-20 13:54:17 +02:00
orbitcowboy
ef757e5cf9
#6952 : uninitvar - Added regression test cases
2021-05-20 09:14:17 +02:00
Robert Reif
3af3d7fc06
fix #10281 (Tokenizer; Wrong simplification for 'namespace ef = : 🅰️ 🅱️ :c::d::ef') ( #3263 )
2021-05-20 08:27:07 +02:00
Daniel Marjamäki
ca5fab8219
Uninitialized variables; Fixed false positive in range for loop
2021-05-19 21:12:11 +02:00
Daniel Marjamäki
abe810d718
Uninitialized variables; Fix false positive in switch inside loop
2021-05-19 13:07:04 +02:00
Daniel Marjamäki
e35c46bcb9
Uninitialized variables; Fixed false positive for overloaded & 'ar & a & b & c'
2021-05-18 21:03:43 +02:00
Daniel Marjamäki
216918756b
Fixed #10276 (FP: (style) Variable '((uint8_t*)(uint16_t)0x1000)[0]' is assigned a value that is never used.)
2021-05-18 20:35:00 +02:00
Daniel Marjamäki
0aebc32ae0
Uninitialized variables; Fixed false positive for 'cin >> x[0]'
2021-05-18 20:13:27 +02:00
Paul Fultz II
4b11bb4ad3
10278: ValueFlow: Wrong known value, sign conversion ( #3260 )
2021-05-18 07:28:45 +02:00
Daniel Marjamäki
bde8b4316e
Uninitialized variables; Fixed FP in range based for loop
2021-05-17 13:31:16 +02:00
Daniel Marjamäki
4322311482
Uninitialized variables; Fixed struct member access FP
2021-05-17 11:50:31 +02:00
Daniel Marjamäki
b115e4a932
Uninitialized variables; Fixed false positive in member assignment
2021-05-17 10:31:02 +02:00
Daniel Marjamäki
16ce0f1dbf
Uninitialized variables; Clarify warnings, bailout for binary & to avoid FPs
2021-05-17 09:22:19 +02:00
Daniel Marjamäki
224492b0b5
Uninitalialized variables; Avoid FP for void cast
2021-05-17 05:59:28 +02:00
keinflue
e93f8f140e
Regression tests for PR #3258 ( #3259 )
2021-05-17 05:35:16 +02:00
Daniel Marjamäki
6a0a2456b5
make checkcfg; temporarily disable suppressions
2021-05-16 22:48:22 +02:00
Daniel Marjamäki
e034fa8a6e
UninitVar: Rewrite CheckUninitVar::isVariableUsage(), use AST primarily
2021-05-16 22:27:04 +02:00
Daniel Marjamäki
2c155a7a78
Uninitialized variables; use AST
2021-05-16 11:58:51 +02:00
Daniel Marjamäki
e73057eb44
Fixed #10275 (ValueFlow: condition 'x>=0 && x < 10')
2021-05-16 10:34:22 +02:00
Daniel Marjamäki
2c10e0747a
extracttests: ensure error comment is written on proper line
2021-05-16 08:40:04 +02:00
Daniel Marjamäki
a07ea7e9e9
testbufferoverrun: refactor TODO test cases. Use TODO_ASSERT_EQUALS.
2021-05-15 21:08:07 +02:00
Daniel Marjamäki
a2ff7752b4
testbufferoverrun; refactor TODO test cases
2021-05-15 20:42:57 +02:00
Daniel Marjamäki
a40b85ccc6
testbufferoverrun: refactor TODO test case for strcat
2021-05-15 20:37:16 +02:00
Daniel Marjamäki
b8314289c6
testbufferoverrun; fixed TODO test cases for pointer arithmetic overflows
2021-05-15 20:32:46 +02:00
Daniel Marjamäki
680a1ee1b9
testbufferoverrun; remove TODO strncat/strcat test cases
2021-05-15 20:12:36 +02:00
Daniel Marjamäki
26e9525683
testbufferoverrun; test case cleanup, ensure there is not uninitialized reads etc
2021-05-15 15:35:14 +02:00
Daniel Marjamäki
e66427c395
testnullpointer; fix extracttests syntax error
2021-05-15 14:59:00 +02:00
Daniel Marjamäki
3c885df74d
testunusedvar: Remove test cases that have undefined behavior
2021-05-15 14:55:35 +02:00
orbitcowboy
e072c2d786
uninitvar: Added a regression test for #7736
2021-05-15 14:16:46 +02:00
Daniel Marjamäki
899b88754f
uninitialized variables; fix false positive in loop
2021-05-15 11:16:47 +02:00
Paul Fultz II
eb96e4980e
Fix issue 10268: ValueFlow; Wrong value in for loop ( #3257 )
2021-05-15 08:39:20 +02:00
Daniel Marjamäki
11c0cc3a6e
extracttests; Fix syntax error in new unit test
2021-05-14 22:29:15 +02:00
Daniel Marjamäki
105bb78775
CI; fix test/cfg/openmp.c
2021-05-14 22:16:54 +02:00
Daniel Marjamäki
809c70b9c3
uninitialized variables; fix FP in for loop
2021-05-14 21:36:51 +02:00
Daniel Marjamäki
404b82fc21
unused var; fix todo test cases, redundant assignment of array in loop
2021-05-14 19:07:30 +02:00
Daniel Marjamäki
56410c3d00
testunusedvar: fix mismatching allocation/deallocation in test
2021-05-14 14:01:39 +02:00
Daniel Marjamäki
c29997b117
uninitvar: fixed TODO assertion
2021-05-14 11:54:18 +02:00
Daniel Marjamäki
56bc5536aa
testunusedvar: move UB testcase to testuninitvar
2021-05-14 11:24:39 +02:00
Daniel Marjamäki
ffac1d1b00
testunusedvar.cpp: remove test cases that has undefined behavior
2021-05-14 11:06:44 +02:00
Daniel Marjamäki
45eb9f82a0
Fix CI; Cppcheck find some more unusedAllocatedMemory violations in test/cfg/..
2021-05-13 23:08:58 +02:00
Daniel Marjamäki
fd31f0846e
unused var; remove test case that has undefined behavior
2021-05-13 21:53:06 +02:00
Daniel Marjamäki
1def0d797b
extracttests: disable TestUnusedVar::localvar2 tests they do not make sense externally
2021-05-13 21:31:44 +02:00
Daniel Marjamäki
d549770b5b
updated extracttests.py. fix syntax errors in test cases.
2021-05-13 20:21:02 +02:00
Daniel Marjamäki
22ab9ccd7f
Fixed #10273 (False negative; Uninitialized variable in for loop)
2021-05-11 20:35:15 +02:00
Daniel Marjamäki
75311fba0f
Fixed #10218 (FP uninitvar with input from stringstream in for loop)
2021-05-10 19:48:07 +02:00
Daniel Marjamäki
db7be3e91b
Fixed #9810 (Improve check: uninitialized struct member not detected)
2021-05-10 19:24:03 +02:00
Daniel Marjamäki
c37b8ea55c
Fixed #8299 (false negative: uninitialized struct member)
2021-05-10 18:38:44 +02:00
Rikard Falkeborn
b013f1b3d0
Fix test case for #10186 ( #3253 )
2021-05-10 08:01:30 +02:00
Daniel Marjamäki
040069ab4d
Fixed Cppcheck self-check warnings
2021-05-09 23:27:53 +02:00
Daniel Marjamäki
2e2d766e2b
Fixed #6766 (Improve check; struct member is assigned value that is never used)
2021-05-09 20:09:10 +02:00
Daniel Marjamäki
3b37c14b3c
Parser; Partial C++20 support, explicit(bool)
2021-05-09 18:47:02 +02:00
Daniel Marjamäki
895a96f9dd
Tokenizer::findGarbageCode: detect wrong struct declaration
2021-05-08 15:28:21 +02:00
Daniel Marjamäki
a197e94573
Fixed #10266 (False positive; parameter can be const)
2021-05-08 13:40:52 +02:00
keinflue
0a84ad874c
Fix case ranges with single quotes and escape sequences ( #3248 )
2021-05-08 11:24:07 +02:00
keinflue
bfa26b5a72
Fix FP leakNoVarFunctionCall with passthrough returns ( #3249 )
2021-05-08 10:26:10 +02:00
Daniel Marjamäki
be95e2bf21
Fixed #10271 (AST; Token::astOperand2() cyclic dependency in static_assert)
2021-05-07 13:19:28 +02:00
Daniel Marjamäki
b8de69489d
Fixed #10079 (AST: switch does not have two operands)
2021-05-04 20:15:57 +02:00
Daniel Marjamäki
2f984b201a
AST; Fix wrong AST for initializer list
2021-05-04 19:02:29 +02:00
Daniel Marjamäki
08184f4681
Fixed #10070 (FP warning: Logical disjunction always evaluates to true)
2021-05-04 13:47:09 +02:00
dummyunit
661ebd3a96
Fix AST for brace initialization after decltype() ( #3245 )
...
Currently sub-expressions like decltype(x){} break AST creation for
subsequent tokens in the whole expression. In some cases this triggers
validation checks in validateAst() and analysis on the file stops.
For example, code like this:
int x = decltype(0){} ? 0 : 1;
currently produces internalAstError.
To fix the issue iscpp11init_impl() was changed to recognize { preceded
by decltype(expr) as a start of C++11 brace initialization expression.
2021-05-03 21:40:49 +02:00
Daniel Marjamäki
70ab30e3c6
AST; Fixed problem with initializer list and cleanup of compileScope
2021-05-03 20:22:08 +02:00
Daniel Marjamäki
7fefdf2bf7
astyle formatting
2021-05-03 16:34:55 +02:00
keinflue
f47fd20e14
Add test cases and improvements for PR #3240 . ( #3242 )
2021-05-03 10:45:37 +02:00
keinflue
6b8029633f
Fix build warnings and checkcfg errors with musl and libc++. ( #3244 )
...
* Fix musl include warning.
* Fix test/cfg errors with musl/libc++.
* Use correct C++ include for PR #3244
Co-authored-by: keinflue <>
2021-05-03 09:39:33 +02:00
dummyunit
ac505afe69
Fixed #9729 (AST broken: lambda with noexcept keyword) ( #3243 )
...
The previous fix for the issue (43b58dbc9e
) didn't seem to actually fix
it because it added a check for noexcept without a condition, but when
AST is created noexcept always has a condition due to simplification
from "noexcept" to "noexcept(true)" in Tokenizer::simplifyKeyword().
The issue from the ticket couldn't be reproduced neither on 43b58dbc9e
nor on the previous commit, so it is hard to tell whether the fix was
effective or not.
The issue appeared again after a refactoring of AST code in ac67049661
.
Test added with the original fix was unable to catch that because it
used testAst() helper function which skips most simplification steps.
To fix the issue we now check for noexcept with a condition and add a
proper regression test that:
1. Uses tokenizeAndStringify() to ensure that all simplifications are
performed before AST is created.
2. Parses the code snippet from the ticket, as having "if (cond)" is
crucial to reproducing the original issue (internalAstError).
Also fix AST creation for lambdas that have both constexpr and mutable
keywords.
2021-05-02 21:34:28 +02:00
Daniel Marjamäki
f7d0bf7a59
Refactoring; Reuse simplecpp::characterLiteralToLL
2021-05-02 13:44:37 +02:00
dummyunit
da27159d7c
Fixed #9728 (Support function level try blocks)
2021-05-02 09:05:12 +02:00
Daniel Marjamäki
6f60c6d965
Revert "Refactoring; Reuse function in simplecpp"
...
This reverts commit dbe9eb2a27
.
2021-05-01 19:54:14 +02:00
Daniel Marjamäki
dbe9eb2a27
Refactoring; Reuse function in simplecpp
2021-05-01 18:13:40 +02:00
keinflue
6541f52e61
Fix false positive invalidFunctionArg for zero arguments to calloc. ( #3238 )
2021-05-01 12:39:01 +02:00
Daniel Marjamäki
9b717b8835
Refactoring __attribute__ simplification
2021-05-01 11:39:26 +02:00
Daniel Marjamäki
07c1f28035
astyle formatting
2021-05-01 07:35:03 +02:00
DGarry82
d3035c246f
Attribute lists support ( #3239 )
2021-05-01 07:33:55 +02:00
Paul Fultz II
31e3e4d87b
Fix issue 10086: false positive: (style) constVariable: Variable 'x' can be declared with const ( #3219 )
2021-04-30 17:47:08 +02:00
Daniel Marjamäki
d2d2124238
Revert "Clang import; This experimental feature didn't "take off" much. After a lot of work we are still far fram the goal. I remove it now but don't rule out completely that it could ever be added again."
...
This reverts commit 207361b174
.
2021-04-30 16:47:02 +02:00
Robert Reif
e1e822275d
fix daca2 paraview crash from uninstantiated recursive template ( #3237 )
2021-04-29 11:09:51 +02:00
keinflue
d2184ac6a8
Fix UB on right-shift. ( #3235 )
2021-04-28 11:57:28 +02:00
Daniel Marjamäki
bd97b8eb8a
SymbolDatabase; Add variables when structured binding is used
2021-04-26 18:21:07 +02:00
Daniel Marjamäki
8aa9e448f5
Parser; Set varid for structured binding variables
2021-04-26 18:04:27 +02:00
Daniel Marjamäki
b798b99777
Parser; do not remove alignof and alignas in the same way
2021-04-26 11:44:08 +02:00
dummyunit
b18e6f1e10
Fix varId assignment for uses of variables declared in the if condition ( #3231 )
...
Variables declared in the if condition (or in C++17 init-statement) are
visible not only in the if body but also in the else body. But logic in
Tokenizer::setVarIdPass1() handled such variables as if they were
declared in the if body.
As the result they were removed from variablesMap by the time the else
block was parsed and their uses in the else block were either given an
incorrect varId from variables in some outer scope or not given a varId
at all.
This then resulted in false positive unreadVariable errors for variables
declared in the if condition (or init-statement) and used only in the
else block.
Simplification from "else if ..." to "else { if ... }" was moved before
setVarId() to simplify detection for ends of blocks in if-else chains.
2021-04-26 07:38:03 +02:00
Daniel Marjamäki
28a7bb63ec
Parser; simplify (break out) init expression from if/switch/range-for
2021-04-25 14:37:27 +02:00
Daniel Marjamäki
4f43dbf954
Parser; fixed ast and auto type deduction for c++17 braced init lists
2021-04-25 10:38:33 +02:00
Daniel Marjamäki
c9dc92c266
Parser; C++20 for loop with initialization expression
2021-04-24 11:47:51 +02:00
IOBYTE
bd7551411a
fix #10258 (coredump due to (?) template simplification) ( #3228 )
2021-04-22 22:23:01 +02:00
Daniel Marjamäki
26c0945309
Handle c++20 spaceship operator
2021-04-22 19:15:22 +02:00
Daniel Marjamäki
bccc0607d1
astyle formatting
...
[ci skip]
2021-04-22 19:08:24 +02:00
dummyunit
229832e72e
Read error locations in the correct order from XML ( #3226 )
...
When ErrorMessage::callStack elements are serialized to XML they are
saved in the reverse order. But when they read back from XML they are
added at the end of the list. Thus the round trip via XML reverses the
order of ErrorMessage::callStack.
From the user point of view it looks like the usage of the
--cppcheck-build-dir option sometimes (when the file wasn't reanalyzed,
but that is hard to spot) results in incorrect location info for some
diagnostic messages.
Moreover, when the first location matches some suppression rule and the
last doesn't match any (or vice versa), usage of --cppcheck-build-dir
results in some diagnostic messages appearing and disappearing seemingly
at random (again, depending on whether the file was reanalyzed or not).
2021-04-22 14:28:33 +02:00
Daniel Marjamäki
207361b174
Clang import; This experimental feature didn't "take off" much. After a lot of work we are still far fram the goal. I remove it now but don't rule out completely that it could ever be added again.
2021-04-21 18:59:48 +02:00
Daniel Marjamäki
bfb98dbf51
TemplateSimplifier: updated output of uninstantiated c++17 fold expressions
2021-04-21 13:13:11 +02:00
Daniel Marjamäki
04e9c13bc6
TemplateSimplifier; Better handling of c++17 fold expressions and c++20 concepts.
...
c++17 fold expressions are simplified to a __cppcheck_uninstantiated_fold__ if they are not instantiated.
c++20 concepts are skipped/removed by Cppcheck and these will be enforced by the compiler.
2021-04-20 15:40:25 +02:00
Paul Fultz II
db5f00a16a
Fix issue 10214: FP: danglingTempReference doesn't account for reference lifetime extension ( #3220 )
...
* Fix issue 10214: FP: danglingTempReference doesn't account for reference lifetime extension
2021-04-19 14:20:29 +02:00
IOBYTE
59f7b937f1
fix daca2 gdcm template simplifier crash ( #3221 )
...
This only fixes the crash. The templates that are instantiated are
correct but one template is left uninstantiated. Fixing the missing
instantiation is not easy and will be looked at later.
Co-authored-by: Robert Reif <reif@FX6840>
2021-04-19 09:17:49 +02:00
Paul Fultz II
c1bb1d771b
Fix issue 10012: False positive: mismatching container, not containers ( #3222 )
...
* Fix issue 10012: False positive: mismatching container, not containers
2021-04-19 09:17:02 +02:00
Paul Fultz II
691f681d86
Fix issue 10235: Regression: oppositeInnerCondition ( #3223 )
2021-04-19 09:15:03 +02:00
Ken-Patrick Lehrmann
5768c3a726
Check stat return value in addFiles2 ( #3214 )
2021-04-18 21:52:14 +02:00
Paul Fultz II
563c9dd9cc
Fix issue 10208: FP: knownConditionTrueFalse in for loop with function that assigns by ref ( #3198 )
2021-04-18 21:42:27 +02:00
Daniel Marjamäki
56773b82c4
Simple handling of coroutines
2021-04-18 19:42:22 +02:00
Daniel Marjamäki
fe87afb2f9
TestTokenizer: Align function pointer test case names
2021-04-18 12:33:04 +02:00
Paul Fultz II
a772d652d8
Fix issue 9932: FP: containerOutOfBounds ( #3217 )
...
* Fix issue 9932: FP: containerOutOfBounds
2021-04-18 10:43:38 +02:00
Daniel Marjamäki
9a9043a07e
Fixed #4349 (Support C++11 variadic templates)
2021-04-17 21:57:21 +02:00
IOBYTE
5568ac95e7
fix simplifyUsing debug warning for: using value_type = const ValueFlow::Value; ( #3211 )
2021-04-17 14:20:16 +02:00
Daniel Marjamäki
c98afa83fd
Tokenizer; Add test for c++14 lambda expression 'lambda=[value=1]{...}'
2021-04-16 15:18:02 +02:00
Daniel Marjamäki
11f828a669
Fixed #9415 (C++11: `alignas` not handled -> wrong code -> false negatives)
2021-04-15 20:26:53 +02:00
orbitcowboy
f62d9d5853
std.cfg: Fixed bufferAccessOutOfBounds false negative for strncmp().
2021-04-13 19:13:00 +02:00
orbitcowboy
03bdcc4c42
Attempt to make CI happy
2021-04-13 16:57:31 +02:00
orbitcowboy
e869452240
#10244 : Fixed false negative: bufferAccessOutOfBounds
2021-04-13 16:40:38 +02:00
orbitcowboy
44c8b315c6
Attempt to make CI happy
2021-04-13 14:44:59 +02:00
orbitcowboy
040e58f943
std.cfg: strxfrm(): Added minize values to arg1 and arg2 and a TODO test case
2021-04-13 14:07:45 +02:00
orbitcowboy
cf211610d3
wxwidgets.cfg: Fixed wrong configuration for wxLogApiError(). This function does return after appending data to wxLog(). Ensure that no duplicateBreak-warning is issued in case code resides afterwards.
2021-04-13 13:07:15 +02:00
Daniel Marjamäki
eacc9e552e
Function::returnsReference: handle type scope better
2021-04-10 14:31:50 +02:00
orbitcowboy
f7e6d216b2
Running astyle [ci skip]
2021-04-09 08:53:32 +02:00
orbitcowboy
b5719418ea
#8206 - Added a regression test
2021-04-09 08:53:01 +02:00
orbitcowboy
260eb4acac
Running astyle [ci skip]
2021-04-09 08:46:47 +02:00
Paul Fultz II
5cf2f7e633
Fix issue 10087: false positive: error: Reference to temporary returned. ( #3205 )
2021-04-09 07:44:20 +02:00
Paul Fultz II
255f273c46
Fix issue 10088: ValueFlow: Array size, wrong known value ( #3204 )
2021-04-09 07:43:54 +02:00
ericmalenfant
1e9687aa8b
Fix noCopyConstructor with multiple inheritance ( #3203 )
2021-04-09 07:41:59 +02:00
Paul Fultz II
f8dc9862da
Fix issue 10202: FP: constParameter ( #3202 )
2021-04-08 16:02:11 +02:00
Daniel Marjamäki
c8e661f61f
assignmentInCondition: Clarify error message
2021-04-07 19:46:00 +02:00
Daniel Marjamäki
72802554c9
Fixed #3593 (New Check: Check for assignment within conditional expression)
2021-04-07 17:21:34 +02:00
orbitcowboy
e60d79e2c9
wxwidgets.cfg: Added tests for commit ccb2cb26b2
2021-04-07 07:57:27 +02:00
Daniel Marjamäki
73e698b84d
Fixed #9214 (Tests are run on simplified token list)
2021-04-06 21:21:53 +02:00
Paul Fultz II
e0f9627201
Fix issue 10226: FP: redundant condition or invalid iterator ( #3195 )
2021-04-06 11:04:37 +02:00
Daniel Marjamäki
93f46f6e7b
Fix testrunner after file0 tweaks
2021-04-05 13:11:23 +02:00
Paul Fultz II
e65ea8575f
Fix issue 10207: FP: derefInvalidIteratorRedundantCheck with ternary operator ( #3197 )
2021-04-05 11:10:43 +02:00
Paul Fultz II
f605f71e49
Fix issue 10225: false positive: knownConditionTrueFalse ( #3196 )
2021-04-05 10:20:14 +02:00
Daniel Marjamäki
de2e836727
test/cfg/windows.cpp; Uncommented TODO, Cppcheck now writes a warning as it should about unused function return value
2021-04-05 05:20:42 +02:00
Daniel Marjamäki
cf8a423636
Unreachable code; better handling of throw in C code
2021-04-05 04:53:07 +02:00
Daniel Marjamäki
a21c81365d
one definition rule: Fixed false positive for 'class A::B ..'
2021-04-04 21:29:45 +02:00
Daniel Marjamäki
084bc74080
Fixed #8223 (false negative: Statements following return, break, continue, goto or throw will never be executed.)
2021-04-04 19:43:51 +02:00
Daniel Marjamäki
518fb01553
Fixed #8412 (ignoredReturnValue not issued when return value is changed but not really used (by logical not for example))
2021-04-04 18:26:07 +02:00
Daniel Marjamäki
44f914eaee
astyle formatting
...
ci skip
2021-04-04 18:20:32 +02:00
Oliver Stöneberg
6397e29f84
cleaned up includes based on include-what-you-use ( #3141 )
2021-04-03 21:30:50 +02:00
Oliver Stöneberg
052de79b6d
some test/CI related refactoring and cleanup ( #3163 )
2021-04-03 21:22:39 +02:00
Daniel Marjamäki
9ce0235e8e
std.cfg: Fixed configuration of mbstowcs
2021-04-03 10:42:24 +02:00
Paul Fultz II
182ae75290
Fix issue 10216: FP containerOutOfBounds with std::array initialized with = {} ( #3190 )
2021-03-31 22:07:54 +02:00
Paul Fultz II
5077663684
Fix issue 9979: false positive: containerOutOfBounds with conditional resize ( #3136 )
2021-03-30 14:02:28 +02:00
Paul Fultz II
9de976b243
Fix issue 10194: hang with followAllReferences() ( #3189 )
...
* Decrease depth faster when there is multiple returns
2021-03-30 11:22:56 +02:00
DGarry82
77716ee398
fix w64-mingw32-ld linking error ( #3184 )
...
* fix w64-mingw32-ld linking error
use shlwapi instead of Shlwapi.lib in mingw-w64 build environment
(prevents "/usr/bin/x86_64-w64-mingw32-ld: cannot find -lShlwapi" error)
* same MinGW shlwapi fix for {tests,tools}/CMakeLists.txt
Co-authored-by: Igor Rondarev <igor.rondarev@gmail.com>
2021-03-29 17:04:42 +02:00
Ken-Patrick Lehrmann
cddaa6d671
10221: Fix setVarId in template code ( #3187 )
...
The computation of the classname was not expecting templates. Simply
skipping the template part seems to fix the issue.
2021-03-29 12:16:02 +02:00
orbitcowboy
e23a967215
#4750 Added a regression test
2021-03-28 09:29:46 +02:00
orbitcowboy
185a5e1ee6
#7682 Added regression test
2021-03-26 10:54:08 +01:00
orbitcowboy
6fd916a90f
#3763 Added regression test
2021-03-26 10:01:44 +01:00
Lars Even Almaas
9786f1c34b
Suggested implementation for rule 8.2 ( #3169 )
2021-03-25 08:25:43 +01:00
Daniel Marjamäki
42437277dc
Update Copyright year
2021-03-21 20:58:32 +01:00
Daniel Marjamäki
51564504a8
astyle formatting
2021-03-20 18:54:46 +01:00
Tetrix
9b7f1f6280
simplifyCPPAttribute tokenizer strips alignas ( #3171 )
2021-03-20 10:38:47 +01:00
IOBYTE
1874b9cb0f
fix crash in CheckClass::getFileInfo ( #3172 )
...
* fix crash in CheckClass::getFileInfo
* fix another crash
* fix memory leak
Co-authored-by: Robert Reif <reif@FX6840>
2021-03-19 09:19:48 +01:00
IOBYTE
b1b7fbb63a
partial revert of b1eaa3021f
( #3174 )
...
It is necessary to use a fake NameAndToken in
mTypesUsedInTemplateInstantiation rather than a Token pointer so the
template simplifiers internal state is kept valid when tokens are
deleted. This prevents a use after free.
Co-authored-by: Robert Reif <reif@FX6840>
2021-03-18 09:15:21 +01:00
orbitcowboy
8fffb84aad
Running astyle [ci skip]
2021-03-16 09:44:58 +01:00
IOBYTE
c9f09fc73f
small template simplifier fixes ( #3168 )
...
* small template simplifier optimization
* don't look for template parameter name in default values
* fix cppcheck warning
* add test for TemplateSimplifier::getTemplateParametersInDeclaration()
Also removed TemplateSimplifier::getTemplateParametersInDeclaration()
return value since it wasn't used.
* added another test
Co-authored-by: Robert Reif <reif@FX6840>
2021-03-16 09:31:52 +01:00
Daniel Marjamäki
7d4582d8ef
Fixed #9832 (extract configurations; include guards not handled correctly '#if !defined(FILE1_H)')
2021-03-12 18:16:57 +01:00
Rikard Falkeborn
103e52f394
Fix tokenizing of x[i](0) ( Fixes #8875 ) ( #3167 )
...
Fix faulty removal of parenthesis when "]" is followed by parenthesis
with a number inside, for example when calling a function pointer in
an array or (perhaps more common) in c++, calling operator ( on an
element in an array.
Fixes #8875 where such wrong simplification lead to a FP with too many
bits shifted due to "<<" was interpreted like a shift operator rather
than a stream output.
2021-03-11 08:16:25 +01:00
Daniel Marjamäki
3502036b14
Usability: Fixed loading of platform file placed in same path as project file
2021-03-05 08:39:09 +01:00
IOBYTE
fe4964f22c
fix overloaded template instantiation ( #3160 )
2021-03-04 08:43:22 +01:00
Rikard Falkeborn
27316e04ed
Fix #10187 (memleak open with fd >= 0) ( #3156 )
2021-03-03 07:00:28 +01:00
Rikard Falkeborn
42a41e8b41
Fix #9139 (leak when variable has const qualifier) ( #3159 )
...
Also, in the tests, change socket/close to resource to get error
messages which say "resource leak" instead of "memory leak".
2021-03-03 06:58:38 +01:00
orbitcowboy
2a40ce6430
windows.cfg: Added support for more defines from WinBase.h and Winnt.h
2021-03-02 10:48:37 +01:00
Daniel Marjamäki
fef956f3f0
Testing; Moved test/cli tests from travis to github actions
2021-03-01 18:49:59 +01:00
Daniel Marjamäki
6b166eb5a7
test/cli/test-other-projects.py: Temporarily disable test (to make Travis happy)
2021-02-28 23:11:25 +01:00
IOBYTE
8c57e2bb14
fix template simplifier overloaded specialized instantiations ( #3154 )
2021-02-28 21:52:14 +01:00
Daniel Marjamäki
c9bc5a076f
Fixed #10014 (-U switch ignored when using --project=compile_commands.json and --force)
2021-02-28 21:43:51 +01:00
Daniel Marjamäki
199f9608cb
TestSuite: Fixed getLocationStr
2021-02-27 04:33:16 +01:00
Daniel Marjamäki
7106e1f48f
Moved TestTokenizer::simplifyCasts tests to TestSimplifyTokens
2021-02-27 04:19:54 +01:00
Daniel Marjamäki
81c7fa0348
Moved TestTokenizer::tokenize6 to TestSimplifyTokens
2021-02-27 04:07:33 +01:00
Rikard Falkeborn
c3eb37972d
Fix #10182 (FN memory leak with if-statement) ( #3151 )
...
Improve leak detections in if-statements. This is done by checking
for leaks every time a scope is left. This allows cppcheck to catch
more memory leaks, as well as improve some error messages which now
contain the line where the variable goes out of scope, instead of the
end of the function.
2021-02-26 12:58:52 +01:00
Daniel Marjamäki
1adea5c3b0
Move simplifyKnownVariables tests to TestSimplifyTokens
2021-02-25 21:32:56 +01:00
Rikard Falkeborn
951ca2c8b9
Fix #10186 (FP memleak with cast and assignment) ( #3148 )
2021-02-25 10:55:34 +01:00
Daniel Marjamäki
e03851f51c
Fix compilation error
2021-02-24 22:31:46 +01:00
Daniel Marjamäki
15bc7ad5cb
Fix compilation error
2021-02-24 22:20:11 +01:00
PKEuS
3998836b03
Refactorization: Improved string handling in test suite
...
Merged from LCppC.
2021-02-24 22:05:23 +01:00
PKEuS
141d2ac215
Refactorization: Improved internal implementation of severity and certainty levels
...
Backported from LCppC.
2021-02-24 22:00:06 +01:00
PKEuS
c25b4f1ad6
Fixed false negatives incompleteArrayFill on user defined types (estimate size to determine if it is larger than one byte)
...
Merged from LCppC.
2021-02-24 21:48:26 +01:00
Daniel Marjamäki
2baeeeb02f
astyle formatting
2021-02-24 21:48:26 +01:00
IOBYTE
fc1cfba5e0
fix simplifyUsing hang parsing class initializer list using {} ( #3146 )
...
Co-authored-by: Robert Reif <reif@FX6840>
2021-02-23 20:35:20 +01:00
IOBYTE
a07f93f819
fix simplifyUsing crash and hang ( #3145 )
2021-02-23 09:48:15 +01:00
shaneasd
02ac2b08a0
Fix some warnings ( #3096 )
2021-02-23 08:19:05 +01:00
Daniel Marjamäki
99ff242dde
astyle formatting
...
[ci skip]
2021-02-20 13:33:57 +01:00
PKEuS
29a6031cea
Fixed more false negatives (and recently introduced false positives) literalWithCharPtrCompare by using ValueType
...
Merged from LCppC.
2021-02-20 13:29:59 +01:00
Lukasz Czajczyk
0a06a083af
Additional macros ( #3106 )
2021-02-20 13:19:06 +01:00
PKEuS
4b01d5bdc6
Re-enabled a bunch of disabled unit tests, some as TODO tests
...
Merged from LCppC.
2021-02-20 13:02:14 +01:00
PKEuS
2bd6a6c252
Test suite:
...
- Enabled test in testgarbage.cpp that succeeds
- Optimizations in TestIO
Merged from LCppC.
2021-02-20 13:00:30 +01:00
PKEuS
cf1937294a
Refactorization: Removed unnecessary \n and spaces in strings
...
Merged from LCppC.
2021-02-20 12:58:42 +01:00
PKEuS
25678a9faf
Refactorized CheckStl::string_c_str(), fixing some false negatives by supporting member functions and overloads
...
Merged from LCppC.
2021-02-20 12:52:39 +01:00
PKEuS
423d7dbc3c
Fixed false negatives literalWithCharPtrCompare when address-of operator (C only) or arrays are used, adapted TODO unit tests
...
Enabled working unit test in testunusedvar.cpp
Merged from LCppC.
2021-02-20 12:42:48 +01:00
Robert Reif
3c6fae37e4
minor simplifyUsing optimizations
...
The using type aliases are a C++ 11 feature so only check for them in C++ 11 or later.
Don't try to simplify a type alias when it can't be parsed.
2021-02-19 22:48:31 +01:00
PKEuS
aa2f143ea6
Fixed false positive: Parameter can be declared with const in constructors did handle noexcept
...
Merged from LCppC.
2021-02-19 08:21:26 +01:00
Daniel Marjamäki
f836c7a546
Fix compile error
2021-02-18 18:50:30 +01:00
PKEuS
acafdb655c
Refactorization: Reduced stack usage of givenACodeSampleToTokenize
...
Merged from LCppC.
2021-02-18 16:28:04 +01:00
PKEuS
4678a9cb45
Refactorization: Include cleanup and added one more header to test/precompiled.h
...
Merged from LCppC
2021-02-18 16:16:40 +01:00
IOBYTE
8547ff8cc2
fix some hangs in daca from uninstantiated template classes derived f… ( #3133 )
...
* fix some hangs in daca from uninstantiated template classes derived from itself
* remove assertions
* fix another simplifyUsing hang
Co-authored-by: Robert Reif <reif@FX6840>
2021-02-17 18:12:49 +01:00
Paul Fultz II
0619b873d0
Fix issue 10178: FP: nullPointerRedundantCheck with ternary and null condition first ( #3134 )
2021-02-17 12:09:11 +01:00
IOBYTE
7ab84bef0c
fix daca crash in intel-compute-runtime ( #3132 )
2021-02-15 08:12:29 +01:00
Daniel Marjamäki
f08dde1140
Fixed #10013 (Tokenizer: Code with 'not' is not handled)
2021-02-13 20:32:49 +01:00
Oliver Stöneberg
3814163373
some MathLib adjustments for out-of-range numbers after std::stringstream removal ( #3100 )
2021-02-13 19:10:45 +01:00
IOBYTE
75e439e56d
fix crash in checkclass from unknown template valueType ( #3129 )
2021-02-13 13:41:12 +01:00
IOBYTE
1eafed9e75
fix hang in simplifyUsing ( #3128 )
...
Co-authored-by: Robert Reif <reif@FX6840>
2021-02-12 16:21:51 +01:00
IOBYTE
e57a674458
fix #10173 (syntax error from wrong simplifications for using type al… ( #3126 )
2021-02-12 09:47:16 +01:00
IOBYTE
b6e93bb575
fix #10172 (debug: Executable scope 'x' with unknown function.) ( #3121 )
2021-02-11 08:08:45 +01:00
Paul Fultz II
51f93400d1
Fix issue 10166: FP uninitvar with break from infinite loop ( #3124 )
2021-02-11 08:07:12 +01:00
Daniel Marjamäki
fbf63b932e
astyle formatting
...
[ci skip]
2021-02-10 11:42:00 +01:00
Paul Fultz II
8569a970b4
Fix issue 10147: False positive: Out of bounds access in expression 'v[0]' because 'v' is empty. ( #3123 )
2021-02-10 08:11:06 +01:00
Daniel Marjamäki
ef726aaece
New check: Detect one definition rule violations
2021-02-09 21:35:08 +01:00
Paul Fultz II
0e871c178f
Fix issue 10141: Errors with ref assignment (duplicateValueTenary and knownEmptyContainer) ( #3093 )
2021-02-09 15:27:46 +01:00
IOBYTE
d3d2e16137
fix hang from f48e195c31
( fix #10136 TODO test ( #3117 )) ( #3120 )
...
Co-authored-by: Robert Reif <reif@FX6840>
2021-02-09 14:19:01 +01:00
IOBYTE
f48e195c31
fix #10136 TODO test ( #3117 )
2021-02-07 21:46:35 +01:00
IOBYTE
1872725ca2
fix #10171 (debug: Executable scope 'x' with unknown function.) ( #3116 )
2021-02-07 09:04:57 +01:00
Daniel Marjamäki
7ab70654ba
Fixed #10170 (Preprocessor; Fail to extract some configurations)
2021-02-06 12:48:52 +01:00
IOBYTE
c70fcf8e2b
fix #10136 (debug: Executable scope 'x' with unknown function.) ( #3113 )
2021-02-05 15:50:32 +01:00
IOBYTE
da3eb2e411
fix #10169 (CheckClass::checkDuplInheritedMembersRecursive) ( #3114 )
...
Co-authored-by: Robert Reif <reif@FX6840>
2021-02-05 11:05:07 +01:00
Daniel Marjamäki
0338e99f84
CheckClass: Refactoring
2021-02-03 19:25:28 +01:00
Paul Fultz II
0ecac8e23b
Fix issue 10090: ValueFlow: Wrong lifetime, pointer member is not allocated on stack ( #3109 )
2021-02-03 10:22:31 +01:00
Paul Fultz II
cf8a5d9a22
Fix issue 10111: FP knownConditionTrueFalse ( #3110 )
2021-02-03 10:21:47 +01:00
Daniel Marjamäki
c0731703af
astyle formatting
...
[ci skip]
2021-02-02 15:01:28 +01:00
alonlib12
a22e476162
Fix CheckClass::operatorEqToSelf ( #3088 )
2021-02-02 15:00:46 +01:00
Paul Fultz II
913dbeb8d8
Fix FP when inserting a range into a container ( #3108 )
2021-02-02 14:57:48 +01:00
Daniel Marjamäki
986f658e39
Fixed #10161 (False negative; uninitialized member variable in base class without constructor)
2021-02-01 18:58:51 +01:00
Oliver Stöneberg
b472b4e65d
some Python cleanups based on PyCharm inspections ( #2999 )
...
* some Python cleanups based on PyCharm inspections
* test-helloworld.py: adjusted assert in test_addon_relative_path()
2021-01-31 14:27:11 +01:00
Ken-Patrick Lehrmann
4e35f19659
10153: Check that string.find() is compared with 0 before recommending starts_with() ( #3099 )
2021-01-31 12:05:38 +01:00
Daniel Marjamäki
6a24b4f7c8
Fixed #10149 (compile database; incomplete handling of directory and file)
2021-01-31 10:14:22 +01:00
IOBYTE
5810171336
fix daca crashes in Type::findDependency() ( #3101 )
2021-01-31 10:07:03 +01:00
Daniel Marjamäki
95e2eebd8a
Revert fix for #10149 , it caused an unexpected appveyor failure
2021-01-30 15:01:19 +01:00
Daniel Marjamäki
43e8430a80
Fixed #10149 (compile database; incomplete handling of directory and file)
2021-01-30 12:27:40 +01:00
Daniel Marjamäki
9e9bb9f804
Refactor test/cli/test-proj2.py
2021-01-30 10:43:08 +01:00
Daniel Marjamäki
49e6e83bc3
astyle formatting
...
[ci skip]
2021-01-29 10:27:32 +01:00
Paul Fultz II
a81427f97f
Fix issue 10022: Logical conjunction error between two completely unrelated members ( #3094 )
2021-01-29 10:26:57 +01:00
IOBYTE
6914f375e1
fix #10135 ("debug: Executable scope 'what' with unknown function." with custom std::exception) ( #3089 )
2021-01-28 12:38:36 +01:00
Paul Fultz II
e17d22eb87
Fix issue 10134: False positive: value is not known. Early return. ( #3086 )
2021-01-28 12:37:56 +01:00
Daniel Marjamäki
203d6ebe5a
Fixed #10100 (FP: shadowVariable clangimport)
2021-01-27 20:03:42 +01:00
Daniel Marjamäki
987c8a854e
astyle formatting
...
[ci skip]
2021-01-25 22:51:50 +01:00
Paul Fultz II
0f8f207719
Remove valueFlowFwdAnalysis and update valueFlowAfterAssign to handle expressions ( #3074 )
2021-01-25 17:24:36 +01:00
Ken-Patrick Lehrmann
00707455be
10110: Fix FP knownConditionTrueFalse ( #3053 )
2021-01-25 17:23:47 +01:00
Simon Martin
9d10f4f572
Ticket #10028 : Properly simplify auto variables' initialization. ( #3079 )
2021-01-23 17:56:58 +01:00
IOBYTE
a4953575f1
fix #10127 (debug: Executable scope 'x' with unknown function.) ( #3077 )
2021-01-23 17:55:25 +01:00
Paul Fultz II
c860de8565
Fix issue 8143: valueFlowCondition: before and inside while ( #3045 )
2021-01-23 17:52:01 +01:00
Paul Fultz II
d80f2fb46f
Reapply f1cc3ad
and fix performance regression ( #3076 )
2021-01-23 08:47:39 +01:00
Paul Fultz II
a6f4fbae54
Fix issue 2741: False negative: redundant assignment of x to itself (ref = x) ( #3071 )
2021-01-22 11:00:57 +01:00
Daniel Marjamäki
0fa89ff2ba
Revert 14365ffc7
and f1cc3ada8
, there was a performance regression
2021-01-22 10:51:46 +01:00
Paul Fultz II
f1cc3ada86
Refactor valueFlowTerminatingCondition to handle inner conditions and complex conditions ( #3060 )
2021-01-21 20:18:53 +01:00
Paul Fultz II
d05acf3c41
Fix issue 10120: FP: containerOutOfBounds, regression ( #3064 )
2021-01-21 19:50:57 +01:00
Paul Fultz II
8b26ecbcdd
Extend ProgramMemory to handle expressions ( #3069 )
2021-01-21 19:49:37 +01:00
IOBYTE
d39956414f
fix #10122 , #10124 and #10125 (debug: Executable scope 'x' with unknown function.) ( #3073 )
2021-01-21 19:47:51 +01:00
Oliver Stöneberg
95d1b41a5b
runtests.sh: fixed check for cppunit ( #3072 )
2021-01-21 10:59:34 +01:00
Oliver Stöneberg
f46a9e3543
fixed/excluded some shellcheck warnings and actually fail the build when something is found ( #3068 )
2021-01-20 18:43:49 +01:00
IOBYTE
952857195b
fix out of line member functions using global namespace ( #3063 )
2021-01-19 18:52:47 +01:00
IOBYTE
fde5994cc3
fix #10061 (debug: Executable scope 'x' with unknown function.) ( #3062 )
2021-01-18 19:01:04 +01:00
Paul Fultz II
25ada657da
Fix issue 9030: ValueFlow: Possible value after conditional assignment in for loop ( #3059 )
2021-01-18 10:12:07 +01:00
IOBYTE
664289792c
fix simplifyTypedef removing needed type qualification ( #3058 )
2021-01-18 10:08:55 +01:00
abhijit-sawant
b97387db66
Made missing comparison in loop check more generic ( #3048 )
2021-01-18 08:11:37 +01:00
Paul Fultz II
65395aeaa1
Add regression test for 7013: valueFlowAfterCondition: false positive below overspecified code ( #3055 )
2021-01-17 16:29:11 +01:00
IOBYTE
dd866f2898
fix using type alias with derived class ( #3050 )
2021-01-17 16:10:53 +01:00
Daniel Marjamäki
76f759fcc4
Fixed #9702 (False positive: Opposite inner condition when modifying member variable used by inner condition)
2021-01-15 20:51:47 +01:00
Daniel Marjamäki
55262f03ec
Fixed #9218 (False positive: Searching before insertion is not necessary (stlFindInsert))
2021-01-14 22:31:43 +01:00
Daniel Marjamäki
a5babf25a7
Fixed #10080 (syntax error: operator)
2021-01-14 20:56:11 +01:00
Paul Fultz II
b571e9fe0b
Fix issue 10106: FP: nullPointerRedundantCheck ( #3044 )
2021-01-13 12:36:26 +01:00
Paul Fultz II
b469da1069
Fix issue 8253: False negative: Comparison is always true (early return) ( #3043 )
2021-01-13 12:35:43 +01:00
Daniel Marjamäki
5f21d9d97b
Fixed #8975 (Syntax error for valid C code)
2021-01-12 21:28:07 +01:00
Armin Müller
0de0a954d2
Typos found by running "codespell" ( #3042 )
2021-01-12 20:48:25 +01:00
Paul Fultz II
fc4238829f
Fix issue 10092: false positive: (warning) The address of local variable 'data' might be accessed at non-zero index. ( #3041 )
2021-01-12 10:24:28 +01:00
Paul Fultz II
b1c56d33ac
Fix issue 9133: Invalid iterator; vector::push_back, functions ( #3008 )
2021-01-11 18:47:38 +01:00
Paul Fultz II
678ee00fe9
Infer variables from conditions in valueFlowSubfunction ( #3037 )
2021-01-11 08:00:13 +01:00
Paul Fultz II
a3617fe573
Fix issue 10102: False positive: knownConditionTrueFalse in for loop ( #3038 )
2021-01-11 07:56:16 +01:00
Rikard Falkeborn
f018163551
Improve handling of realloc in memory leak checker ( #3036 )
...
Mark realloced variables as realloced instead of freed. This allows
improved checking for code with error realloc handling.
If cppcheck finds an if-statement which checks the validity of the
allocated memory or resource, check if the memory/resource is
reallocated from another variable. If so, we can add checking of that
variable in the if-statement instead. This allows to check that variable
for memleaks and double frees.
This fixes #9292 and #9990 which both concern FPs with double frees
after correct error handling.
2021-01-11 07:55:05 +01:00
Daniel Marjamäki
f493ce16b3
astyle formatting
...
[ci skip]
2021-01-10 14:46:19 +01:00
Paul Fultz II
bc3f5554a4
Fix issue 8871: improve check: mismatching container size conditions ( #2988 )
2021-01-10 13:30:00 +01:00
Oliver Stöneberg
ac7647fcd8
some self-check suppression cleanups ( #3032 )
2021-01-09 20:32:38 +01:00
IOBYTE
2482873029
fix location of forward declaration of specialized template ( #3031 )
2021-01-09 20:00:35 +01:00
Paul Fultz II
c267d85640
Add generic valueflowBeforeCondition ( #3001 )
2021-01-08 22:55:04 +01:00
Daniel Marjamäki
4b5aedbbab
Fixed #10066 (FP: duplicateExpression clangimport)
2021-01-08 22:30:06 +01:00
Paul Fultz II
3b5c558414
Fix issue 10076: ValueFlow: False positive after address of var is taken 'T t = {{&var}};' ( #3027 )
2021-01-08 10:29:32 +01:00
Rikard Falkeborn
bedf3118ef
library: Refactor to use enum class ( #3026 )
2021-01-08 10:29:01 +01:00
IOBYTE
503a5dd441
fix #10081 (Hang: TemplateSimplifier::useDefaultArgumentValues) ( #3021 )
2021-01-06 23:06:50 +01:00
IOBYTE
cb02628c7c
fix #10075 (namespace alias changes variable name) ( #3020 )
2021-01-06 17:30:11 +01:00
IOBYTE
c085151eb0
fix exprengine.cpp:2833:18: debug: Executable scope 'executeAllFunctions' with unknown function. ( #3019 )
2021-01-06 17:29:23 +01:00
Daniel Marjamäki
9e4e06a524
Clang import; Testing that token index is set properly
2021-01-06 11:19:14 +01:00
Daniel Marjamäki
3a86262244
SymbolDatabase: Do not set definedType for global scope etc
2021-01-06 08:53:45 +01:00
IOBYTE
22b10f8987
fix token.cpp:745:19: debug: Executable scope 'getStrSize' with unknown function. ( #3015 )
2021-01-05 22:07:53 +01:00
Oliver Stöneberg
96704c9971
fixed and enabled some more clang-tidy warnings ( #3007 )
2021-01-05 17:51:32 +01:00
Paul Fultz II
e004731f1c
Fix issue 8650: ValueFlow: Track if pointer is created by '&' operator ( #3011 )
2021-01-05 16:56:38 +01:00
IOBYTE
8897ad3408
fix #10068 (typedef not replaced when namespace is involved) ( #3009 )
2021-01-05 16:53:56 +01:00
Paul Fultz II
f0b5668436
Fix issue 9890: ValueFlow: known value not found (variable is changed in path that returns) ( #3010 )
2021-01-05 16:49:08 +01:00
Paul Fultz II
a95c931da0
Fix issue 8501: false negative: (style) Opposite expression on both sides of ( #3012 )
2021-01-05 12:07:27 +01:00
Daniel Marjamäki
b3b7ecc7ea
Removed integerOverflowOptimization checking and merged functionality into invalidTestForOverflow
2021-01-05 11:38:19 +01:00
abhijit-sawant
a4a225203c
Fix #9938 (false positive: StlMissingComparison) ( #2989 )
2021-01-04 10:07:07 +01:00
Daniel Marjamäki
52491f1c53
Signed integer optimisations; Also warn about 'x+y<x'
2021-01-03 22:12:19 +01:00
Daniel Marjamäki
6375fb4f08
New check: Warn about nonportable code that can be optimised (signed integer overflow)
2021-01-03 21:03:07 +01:00
IOBYTE
23da5c9815
fix #9885 (SymbolDatabase: function lookup fails calling variadic method) ( #3002 )
...
Co-authored-by: Robert Reif <reif@FX6840>
2021-01-03 11:17:32 +01:00
Oliver Stöneberg
fbf5858f76
fixed and enabled several clang-tidy warnings ( #2816 )
2021-01-02 19:10:25 +01:00
Rikard Falkeborn
f816cc8d48
runtests: Add -Wno-deprecated-declarations to CXX flags ( #3004 )
...
This avoids warnings when checking syntax of qt.cpp.
2021-01-02 10:02:16 +01:00
Rikard Falkeborn
d19454b935
Refactoring: Convert ValueType to enum class ( #3005 )
2021-01-02 09:30:00 +01:00
Daniel Marjamäki
abb19875b3
Bug hunting; Fixed testrunner
2021-01-01 08:58:54 +01:00
Daniel Marjamäki
214f90c10a
Bug hunting; Fix false positive, unsigned array index can't be negative
2021-01-01 08:57:35 +01:00
miltolstoy
ee8d5b972a
checkunusedvar: handle array element change using pointer arithmetic ( #3000 )
2021-01-01 08:06:20 +01:00
Rikard Falkeborn
fb35756126
TestLeakAutoVar: Split recursiveCountLimit test to separate class ( #2995 )
...
This test is by far the slowest one to run. Split it to a separate class
to make it easy to select if it should be run during development.
2020-12-31 09:34:53 +01:00
IOBYTE
e7bdf5f71c
remove cleanupAfterSimplify from the template simplifier ( #2998 )
...
The template simplifier works well enough now so cleanupAfterSimplify is
no longer necessary. In fact cleanupAfterSimplify was introducing a bug
which improperly simplified C++ style casts.
Bugs should be exposed and fixed properly rather than just hiding them.
Co-authored-by: Robert Reif <reif@FX6840>
2020-12-31 09:33:23 +01:00
Daniel Marjamäki
a1756f3afc
Clang import; Function declaration
2020-12-30 17:00:05 +01:00
Daniel Marjamäki
f986b37a50
Clang import: Improved function pointer
2020-12-30 16:24:10 +01:00
IOBYTE
277da763aa
fix #10054 (debug: Executable scope 'x' with unknown function.) ( #2994 )
2020-12-30 08:09:34 +01:00
Daniel Marjamäki
0adf09c507
ClangImport; Fixed output for anonymous enum
2020-12-29 21:10:34 +01:00
Daniel Marjamäki
79a8f21183
ClangImport; Set Token::scope properly for empty enum body
2020-12-29 16:34:06 +01:00
Daniel Marjamäki
4bd5933691
Clang import: Do not write unreferenced enum declaration
2020-12-29 15:39:33 +01:00
Daniel Marjamäki
b94a6d595a
Fixed #9295 (ValueFlow: Does not handle noreturn function)
2020-12-28 20:00:35 +01:00
shaneasd
53734a3da1
Test for return address of reference ( #2991 )
2020-12-28 10:50:42 +01:00
Ken-Patrick Lehrmann
f1169bf2b4
10062: Fix FP due to assignment in reverseanalyzer ( #2983 )
...
reverseanalyzer has a special process for assignments, and would not see
a stop condition on a rhs of an assignment.
2020-12-27 10:14:46 +01:00
Georgy Komarov
1c12b4fd78
ExprEngine: Handling cases when for condition is always false ( #2984 )
2020-12-26 21:29:50 +01:00
Paul Fultz II
bd22070df5
Fix issue 10027: Segmentation fault in ValueFlowAnalyzer::analyze ( #2987 )
2020-12-26 21:26:39 +01:00
Daniel Marjamäki
d024eb3ee0
Fixed #10051 (AST: Wrong ast for function call with initializer list)
2020-12-26 18:33:54 +01:00
IOBYTE
765c1ace87
fix #10008 (false negative: knownEmptyContainer with alias in namespace and "using namespace") ( #2979 )
2020-12-26 13:45:17 +01:00
Daniel Marjamäki
f700d81e59
ImportProject: Fixed compile_commands.json problems
2020-12-25 14:47:01 +01:00
Daniel Marjamäki
cf57233f5d
ImportProject: Try to handle -D and -I in the same way
2020-12-25 11:51:24 +01:00
Daniel Marjamäki
bcf6039558
Fixed #10058 (False positive: redundant assignment, there is break)
2020-12-25 09:08:15 +01:00
Ken-Patrick Lehrmann
aad723bf3a
Fix false positive AssignmentIntegerToAddress ( #2971 )
2020-12-24 19:57:02 +01:00
Paul Fultz II
e12a733ee9
Fix issue 10053: False positive: Same value on both branches of ternary operator ( #2962 )
2020-12-23 13:37:28 +01:00
Georgy Komarov
259f562e73
ExprEngine: Add condition branches for the while loops ( #2970 )
2020-12-22 20:21:57 +01:00
Daniel Marjamäki
a9e7974963
ExprEngine: use 'real' instead of 'fpa' values in latest Z3 for floats
2020-12-22 18:05:21 +01:00
Daniel Marjamäki
315892d991
ExprEngine; add a 'stupid' handling of floating point promotions for integers
2020-12-22 17:15:11 +01:00
Daniel Marjamäki
1812951640
ExprEngine; Fix problem when float suffix is used
2020-12-22 15:17:36 +01:00
Daniel Marjamäki
347fccb207
ExprEngine; Avoid overspecified constraints
2020-12-22 11:10:01 +01:00
amai2012
f0da9098b9
Set language compatibility to C++14 in Visual Studio ( #2967 )
...
There is no C++11 flag
2020-12-22 10:24:25 +01:00
Georgy Komarov
0731df7d2d
ExprEngine: Add FP and String literals in determining that condition can ( #2969 )
2020-12-22 09:25:54 +01:00
Daniel Marjamäki
13ed2effa1
astyle formatting
...
[ci skip]
2020-12-22 08:09:51 +01:00
IOBYTE
2ecab32fbe
fix debug printing of valuetype name with namespaces ( #2968 )
2020-12-21 19:47:54 +01:00
Daniel Marjamäki
01ac4073c8
TestExprEngine: Fix for ubuntu 18.04. Replace '(/ 123.0 10.0)' with '12.3'
2020-12-21 15:29:05 +01:00
Daniel Marjamäki
c3e798968c
ExprEngine; Fix floating point comparison
2020-12-21 13:28:10 +01:00
abhijit-sawant
7d6fc23022
Checking in fix for issue 9957 - - False negative: duplInheritedMember ( #2964 )
2020-12-21 07:14:52 +01:00
Daniel Marjamäki
47bb487c95
Visual Studio; Try to fix compilation
2020-12-20 21:01:45 +01:00
Daniel Marjamäki
37a5ec8cd5
Summaries: Moved to its own files
2020-12-20 19:53:58 +01:00
Daniel Marjamäki
5701f6d368
ExprEngine: Added ifIntRangeAlwaysFalse and ifIntRangeAlwaysTrue tests
2020-12-20 19:04:46 +01:00
Daniel Marjamäki
229e39e7de
Revert "ExprEngine: Fixed float value"
...
This reverts commit 1f9edc6a66
.
2020-12-20 16:36:22 +01:00
Daniel Marjamäki
1f9edc6a66
ExprEngine: Fixed float value
2020-12-20 15:22:11 +01:00
Wolfgang Stöggl
079255d913
Fix gcc11 build errors ( #2963 )
2020-12-19 21:54:19 +01:00
Daniel Marjamäki
96caaedbd5
Generate basic function summaries
2020-12-19 19:02:42 +01:00
Paul Fultz II
a770342593
Fix crash in getInitListSize ( #2960 )
2020-12-19 12:23:19 +01:00
Daniel Marjamäki
1744cbaf66
astyle formatting
...
[ci skip]
2020-12-19 08:56:46 +01:00
miltolstoy
6366a577f9
feat(unused_var): analyze global variables inside function body ( #2944 )
2020-12-19 08:55:19 +01:00
Paul Fultz II
626dcd0eba
Fix issue 10037: False positive when passing variables to functions by address ( #2957 )
2020-12-19 08:29:37 +01:00
Paul Fultz II
2541b6034f
Fix issue 10049: False positive: generic reverse valueflow analysis ( #2959 )
2020-12-19 08:28:58 +01:00
Daniel Marjamäki
164c6b3441
Bug hunting; Detect array index out of bounds for multi dimensional arrays also
2020-12-18 21:32:23 +01:00
Daniel Marjamäki
1b0ca0811f
Bug hunting; option to set function analysis max time
2020-12-18 19:59:10 +01:00
IOBYTE
f2cf11682a
fix #10040 (symbolDatabaseWarning: debug: Executable scope 'x' with unknown function.) ( #2955 )
2020-12-18 07:46:01 +01:00
Paul Fultz II
b044f9ba96
Fix issue 9996: false negative: containerOutOfBounds with std::vector::front() and c++11 braced initializer ( #2958 )
2020-12-18 07:14:11 +01:00
Daniel Marjamäki
75f2ab20e8
Bug hunting; void* => might point at uninitialized data
2020-12-17 07:32:53 +01:00
Daniel Marjamäki
8619bfe957
Bug hunting; Remove old value from array when it is overwritten
2020-12-16 19:06:20 +01:00
Paul Fultz II
c9d2e55ea9
Fix issue 10035: FP: knownConditionTrueFalse when bool updated in for loop ( #2953 )
2020-12-16 17:25:21 +01:00
Daniel Marjamäki
82635417d2
Bug hunting; Fixed array init
2020-12-14 22:15:10 +01:00
Daniel Marjamäki
116119083b
Bug hunting; Better result from function that returns unknown pointer result
2020-12-14 17:53:28 +01:00
Paul Fultz II
da1375c9a3
Fix issue 10024: FP: nullPointerRedundantCheck when using a goto statement ( #2947 )
2020-12-14 11:13:47 +01:00
Daniel Marjamäki
bf951ea5e6
Bug hunting; Fix for '*x=y'
2020-12-13 19:54:57 +01:00
Daniel Marjamäki
be4de06a97
TestExprEngine: Temporary convert ASSERT_EQUALS to TODO_ASSERT_EQUALS
2020-12-13 16:11:01 +01:00
Georgy Komarov
36ab23f1f7
ExprEngine: Handle pointers to struct as function argument ( #2945 )
2020-12-13 16:02:35 +01:00
Daniel Marjamäki
81c3ac738d
CI: Fix testrunner
2020-12-13 15:51:20 +01:00
Daniel Marjamäki
b18dc0fdbb
Bug hunting: Handle not better
2020-12-13 13:00:04 +01:00
Daniel Marjamäki
be16b2c276
Bug hunting; better handling of early return
2020-12-13 09:13:26 +01:00
Daniel Marjamäki
2cf6217859
Travis: ExprEngine debug output was changed, corrected tests.
2020-12-12 21:29:28 +01:00
Daniel Marjamäki
d0f700305c
ExprEngine: Avoid analyzing unreachable execution paths
2020-12-12 15:22:49 +01:00
IOBYTE
7fc03c6030
fix #10032 (Syntax error if first function in a struct is a template function) ( #2940 )
...
Co-authored-by: Robert Reif <reif@FX6840>
2020-12-11 07:01:20 +01:00
Daniel Marjamäki
245284acde
Tokenizer; Fixed varid for base class member variable
2020-12-08 17:25:50 +01:00
Daniel Marjamäki
6d7ddde1b5
Bug hunting; Make bughuntingUninit check a bit less noisy about const parameters
2020-12-08 13:34:46 +01:00
Daniel Marjamäki
99cb65b4b2
Bug hunting; Clarify bughuntingUninit output for non-const parameters
2020-12-08 11:16:38 +01:00
IOBYTE
8161baf1e9
fix template debug output line numbers ( #2938 )
2020-12-08 10:35:13 +01:00
Daniel Marjamäki
02bb14003b
Bug hunting; better handling of struct member assignment in for loop
2020-12-07 19:58:19 +01:00
Daniel Marjamäki
39a9350f6e
Bug hunting: Better analysis of BailoutValue
2020-12-07 06:27:14 +01:00
IOBYTE
8d9f0b3528
fix #9394 ("debug: Executable scope 'x' with unknown function." with … ( #2935 )
2020-12-06 22:08:42 +01:00
Daniel Marjamäki
d12732adfb
Bug hunting; Diagnose array index out of bounds when struct member is accessed
2020-12-06 17:44:07 +01:00
Daniel Marjamäki
3bf758a04b
Bug hunting; Ensure there is warning after unknown variable expression
2020-12-06 10:13:10 +01:00
Daniel Marjamäki
7324722dab
Bug hunting; Detect array index out of bounds in loop better
2020-12-05 20:39:54 +01:00
Daniel Marjamäki
cb7eee2aa9
SymbolDatabase: Improved types for 'std::string + x'
2020-12-05 13:24:21 +01:00
Daniel Marjamäki
da4cd6a4f4
Bug hunting; Improved buffer overflow check
2020-12-05 11:47:57 +01:00
Daniel Marjamäki
396c353d3c
bug hunting: Add array index check
2020-12-05 11:46:07 +01:00
Daniel Marjamäki
c89512d8d6
Update copyright year
2020-12-05 09:28:33 +01:00
IOBYTE
ab16603666
fix #9685 (Handle 'extern "C++"') ( #2933 )
2020-12-05 09:26:11 +01:00
orbitcowboy
2c15c384d1
Fixed some typos, there are no functional changes intended
2020-12-05 08:00:31 +01:00
IOBYTE
9c51d4c12d
instantiate nested templates in the proper order ( #2930 )
2020-12-04 08:04:16 +01:00
Daniel Marjamäki
cbb388d458
Tokenizer: Avoid wrong simplification of template right angle bracket
2020-12-02 20:21:32 +01:00
Daniel Marjamäki
c69bfbf495
AST: Fixed ast for multidimensional array initialisation
2020-12-02 07:38:21 +01:00
Daniel Marjamäki
009ad11b3e
SymbolDatabase: set proper valuetype for string addition result ( #9161 )
2020-12-01 20:16:39 +01:00
IOBYTE
2bbc7abedc
fix overloaded function lookup for explicit instantiations ( #2929 )
2020-12-01 09:43:16 +01:00
Daniel Marjamäki
26b4c803f7
astyle formatting
2020-11-30 19:26:54 +01:00
Daniel Marjamäki
9aa69661b5
More robust Token::findClosingBracket
2020-11-30 19:26:28 +01:00
Oliver Stöneberg
c846c0fbdc
testclangimport.cpp: fixed potential nullptr dereference in parse() ( #2927 )
2020-11-30 18:46:48 +01:00
Daniel Marjamäki
8a1c16a560
Tokenizer: add daca debug messages when right angle brackets in templates are not handled well
2020-11-29 16:07:56 +01:00
Daniel Marjamäki
7112f69d7b
Fixed bug in fixAngleBrackets
2020-11-29 12:56:13 +01:00
Daniel Marjamäki
e2debac882
Fix testcases
2020-11-29 08:46:42 +01:00
Daniel Marjamäki
fd75837494
Tokenizer: Remove extra 'template' keywords
2020-11-28 21:57:06 +01:00
Daniel Marjamäki
5b89b179ec
Detect syntax error when script is checked
2020-11-28 14:41:05 +01:00
Daniel Marjamäki
af26697ceb
AST: Generate proper AST for 'f = []() -> foo&& {}'
2020-11-28 06:53:46 +01:00
Daniel Marjamäki
484b68c550
astyle formatting
2020-11-28 05:52:35 +01:00
miltolstoy
5d299016f1
feat: analyze function side effects ( #2901 )
2020-11-26 17:34:42 +01:00
orbitcowboy
0e8556e6ed
Activated basic runtime checks for 'Debug'-testrunner builds with MSVS as described here: https://docs.microsoft.com/de-de/cpp/build/reference/rtc-run-time-error-checks?view=msvc-160
2020-11-26 09:29:59 +01:00
Daniel Marjamäki
96392aa212
Clang import: better handling of templates
2020-11-24 22:02:59 +01:00
Daniel Marjamäki
788abfa8a4
Clang import: better handling of CXXMethodDecl in getSpelling
2020-11-24 19:20:30 +01:00
IOBYTE
1ea89bcad8
add support for template constructors ( #2911 )
2020-11-24 07:21:37 +01:00
Daniel Marjamäki
b4db52bf61
Fixed #9860 (wrong ast for placement new 'new ( uBAR ? uBAR : sizeof ( T ) ) T')
2020-11-23 22:03:50 +01:00
Daniel Marjamäki
4a2e082d85
Revert "GUI: restore default tab in ProjectFileDialog"
...
This reverts commit 39564c9e6c
.
2020-11-23 20:18:06 +01:00
Daniel Marjamäki
39564c9e6c
GUI: restore default tab in ProjectFileDialog
2020-11-23 19:27:14 +01:00
Daniel Marjamäki
208a4a4548
Check unused templates by default
2020-11-23 18:29:08 +01:00
Daniel Marjamäki
f6e7a66f42
TestConstructors: Unremove a test case
2020-11-22 18:17:40 +01:00
Daniel Marjamäki
2cd8ea83a7
Fixed #9860 (unused template not removed properly by default)
2020-11-22 16:43:36 +01:00
Wolfgang Stöggl
8ac55a8534
Add find_package(tinyxml2) to CMake builds ( #2691 )
...
So far, the cmake files of Cppcheck needed to be patched in order to
use installed tinyxml2 instead of the bundled version of tinyxml2.
- Introduce the CMake option USE_BUNDLED_TINYXML2 with a default value
of ON. This preserves the behavior as in the past and uses the
bundled version under externals/tinyxml2 by default.
- Usage of the installed tinyxml2 version of a system can be enabled
now using -DUSE_BUNDLED_TINYXML2=OFF as a cmake parameter.
- Some Linux distros do not install tinyxml2*.cmake files, which are
required to find tinyxml2 using find_package().
Try first using find_package(tinyxml2 QUIET) and if this fails, try
again using find_library(tinyxml2_LIBRARY tinyxml2)
2020-11-22 08:57:07 +01:00
Paul Fultz II
4a8a78a925
Fix issue 10002: False positive: constParameter with reference to pointer ( #2918 )
2020-11-22 08:47:24 +01:00
Paul Fultz II
f6399c4cba
Fix issue 9980: FP nullPointerRedundantCheck - condition after while loop ( #2912 )
2020-11-20 09:36:09 +01:00
Daniel Marjamäki
9c27ba835d
astyle formatting
2020-11-19 21:25:49 +01:00
Paul Fultz II
e8c1c792a5
Fix issue 9987: false positive: danglingTempReference with && variable and assignment ( #2907 )
2020-11-17 06:52:12 +01:00
IOBYTE
c4b3d4cd77
fix #9983 (TemplateSimplifier: template not simplified : f(0,0);) ( #2905 )
...
Currently template type deduction for functions only works for single
template argument single function argument functions with a literal
argument.
This patch starts to add support for single template argument multiple
function argument functions. It correctly handles functions with
multiple arguments of the same type. It also handles a mix of template
and non-template arguments.
It does not add support for overloading non-template arguments.
It does not add support for multiple parameter template functions.
It does not add support for type deduction from variable arguments.
Co-authored-by: Robert Reif <reif@FX6840>
2020-11-17 06:51:32 +01:00
Daniel Marjamäki
22d6160624
Improve handling of decltype
2020-11-16 20:11:26 +01:00
Daniel Marjamäki
c7cbe7f2d3
rename externals/tinyxml to externals/tinyxml2
2020-11-16 09:11:53 +01:00
Daniel Marjamäki
8b0699cd6a
Revert "improved decltype() handling"
...
This reverts commit 6e8f77c519
.
2020-11-15 21:32:05 +01:00
Daniel Marjamäki
6e8f77c519
improved decltype() handling
2020-11-15 20:58:17 +01:00
Daniel Marjamäki
7878eb2512
AST: Do not generate AST for decltype
2020-11-15 16:47:36 +01:00
Daniel Marjamäki
54a93c4374
Fixed #9452 (FP syntaxError - _Pragma before struct with two constructors)
2020-11-15 15:03:47 +01:00
Daniel Marjamäki
6236beeb3f
Fixed #9950 (Wrong severity for redundantAssignInSwitch)
2020-11-15 13:09:28 +01:00
Ken-Patrick Lehrmann
7c3afa0b36
9955: Fix ast when throwing a cast ( #2900 )
...
```
throw (std::string)"Error: " + strerror(errnum);
```
would result in a broken ast:
```
throw
`-::
|-std
`-string
```
instead of
```
throw
`-+ 'signed char *'
|-( 'container(std :: string|wstring|u16string|u32string)'
| `-"Error: " 'const char *'
`-( 'signed char *'
|-strerror
`-errnum 'signed int'
```
2020-11-15 10:37:29 +01:00
Falital
2e2d4a0055
Added Hash to plist file names ( #2898 )
2020-11-13 15:52:24 +01:00
Rikard Falkeborn
324e267559
getSizeOf: Handle long double ( #2888 )
2020-11-11 22:51:17 +01:00
Daniel Marjamäki
4330a43acb
Fixed #9933 (FP: uninitvar when reading to struct)
2020-11-11 22:47:23 +01:00
Daniel Marjamäki
bfa8c6fb98
Fixed cppcheck warning and corrected checkHeaders test
2020-11-11 15:28:32 +01:00
Daniel Marjamäki
c95b0d2a51
Fixed #9977 (Template simplifier does not simplify in header)
2020-11-11 09:50:51 +01:00
Daniel Marjamäki
7182da5c8e
astyle formatting
2020-11-11 09:17:54 +01:00
Rikard Falkeborn
829c543331
TestCondition: Don't warn when sizeof is involved ( #2896 )
2020-11-11 08:01:11 +01:00
IOBYTE
e785885b4d
fix #9975 (Template method not simplified) ( #2894 )
2020-11-10 21:19:04 +01:00
Paul Fultz II
bd7e915c20
Add generic reverse valueflow ( #2878 )
2020-11-10 16:00:55 +01:00
Ken-Patrick Lehrmann
79bdd64689
Fix false positive memoryleak ( #2882 )
...
```
int *f() {
int *p = static_cast<int *>(realloc(nullptr, 10));
if (!!(!p)) {
return nullptr;
}
return p;
}
```
would give
```
memleak2.cpp:4:5: error: Memory leak: p [memleak]
return nullptr;
^
```
Because of the additional `!!̀ .
2020-11-10 15:59:51 +01:00
Paul Fultz II
ae6f611df0
Fix issue 9973: False positive: mismatching iterator container, reference ( #2893 )
2020-11-10 09:38:05 +01:00
Daniel Marjamäki
bd5fc4b579
Clang import: Fixed variable type for pointers
2020-11-10 09:35:41 +01:00
Daniel Marjamäki
bd5b2133ab
Clang import: Variable::isReference() should return true for r-value references also
2020-11-09 21:00:48 +01:00
Daniel Marjamäki
5cfe2e319c
Clang import: Fix Variable::isRValueReference
2020-11-09 20:44:46 +01:00
Daniel Marjamäki
970beaa79a
Clang import: Fix Variable::isReference
2020-11-09 20:35:00 +01:00
Daniel Marjamäki
8b52ed590e
Clang import: Better handling of const methods
2020-11-09 14:50:34 +01:00
Daniel Marjamäki
06909df8f5
Clang import: better handling of ArrayToPointerDecay implicit casts
2020-11-08 19:53:28 +01:00
Daniel Marjamäki
1c742b7995
Clang import: Handle AccessSpecDecl
2020-11-08 17:02:19 +01:00
Daniel Marjamäki
1078855029
Clang import: Full name for methods
2020-11-08 10:31:48 +01:00
Daniel Marjamäki
87323b33bd
Clang import: Fixed problems when handling CXXConstructorDecl
2020-11-08 01:17:34 +01:00
Daniel Marjamäki
565e67d373
Clang import: Ignore VisibilityAttr
2020-11-07 22:27:11 +01:00
Daniel Marjamäki
1c2e480449
Proper fix for test-clang-import.py failure
2020-11-07 18:12:47 +01:00
Daniel Marjamäki
b8e0cdcdb4
Travis: temporary hack to make test-clang-import.py happy
2020-11-07 17:23:56 +01:00
Daniel Marjamäki
ff17d3e7c6
Clang import: Better handling of scope types
2020-11-07 15:02:36 +01:00
Georgy Komarov
80dee36e68
library: Add new warning: ignoredReturnErrorCode ( #2877 )
...
* library: Add optional "type" attribute to "use-retval"
Added an optional "type" attribute to "use-retval" nodes in the
configuration. When the return type of a function configured with
`<use-retval type="error-code"\>` node does not used, the new style
error "ignoredReturnErrorCode" will be generated.
* Fix and improve patch after the initial review
* Fixed severity level and [[nodiscard]] attribute
* Fix incorrect condition
* Remove redundant condition
2020-11-05 13:35:52 +01:00
Jesse Boswell
f70e8de315
Fix #9567 (Inline suppression of unusedFunction errors not working when using compile database) ( #2870 )
2020-11-04 21:01:48 +01:00
uhziel
aad29ddb9a
fix an error in Tokenizer::simplifyTypedef() ( #2880 )
2020-11-04 13:32:31 +01:00
Rikard Falkeborn
a7f6621fc0
cfg: cppunit: Fix FP with compareBoolExpressionWithInt within CPPUNIT_ASSERT_EQUAL ( #2879 )
2020-11-04 07:48:53 +01:00
Daniel Marjamäki
ae1b9cb14e
SymbolDatabase: Improved function matching in C code
2020-11-04 07:17:17 +01:00
Daniel Marjamäki
198bbc8a5a
Clang import: Better type handling
2020-11-03 21:37:28 +01:00
Daniel Marjamäki
eece8ee66b
astyle formatting
2020-11-03 21:08:21 +01:00
Daniel Marjamäki
8956ecb5fc
Clang import: Fixed data for inline static functions
2020-11-03 17:52:53 +01:00
Oliver Stöneberg
98946143f6
Fix #9964 (false positive: compareBoolExpressionWithInt with ASSERT_FALSE() and --library=googletest) ( #2876 )
2020-11-03 10:20:25 +01:00
Daniel Marjamäki
e053066d8b
Clang import: Fixed Variable::mTypeStartToken and Variable::mTypeEndToken for unnamed parameters
2020-11-02 20:58:43 +01:00
Oliver Stöneberg
488813d00f
added validateCFG and checkcfg targets to CMake / some refactorings ( #2687 )
2020-11-02 20:16:15 +01:00
Daniel Marjamäki
a2a948a311
Clang Import; Better handling of derived classes
2020-11-01 20:32:42 +01:00
Daniel Marjamäki
9dc085c3ec
Clang import: Improved handling of overloaded operators
2020-11-01 15:30:51 +01:00
vilarion
2c34e660b3
Fix #9805 (False positive; Unused function (template)) ( #2871 )
...
* Add test
* Ignore templates with trailing return type as well
2020-11-01 15:10:02 +01:00
Daniel Marjamäki
26e6eed189
Revert "AST: Adjust AST for variable declaration 'char var[] = str;'"
...
This reverts commit 376860f796
.
2020-11-01 11:41:41 +01:00
Daniel Marjamäki
4094274723
TestClangImport: Fix tests
2020-11-01 11:33:01 +01:00
Daniel Marjamäki
5aab1f9692
Clang import: Improved handling of structs
2020-11-01 09:12:58 +01:00
Daniel Marjamäki
226e996e46
Clang import: Improved handling of empty structs/classes
2020-11-01 08:44:38 +01:00
Daniel Marjamäki
597a6eb99c
Clang import: Fix Variable::mTypeStartToken for const argument
2020-10-31 17:43:36 +01:00
Daniel Marjamäki
376860f796
AST: Adjust AST for variable declaration 'char var[] = str;'
2020-10-31 17:05:42 +01:00
vilarion
bc5ec38149
Fix #9806 (False positive: template function can be static) ( #2868 )
...
* Include detecting variadic template functions by matching against endTok instead of startTok.
* Add argument count check for variadic (template) member functions.
2020-10-31 10:02:15 +01:00
shaneasd
a623168942
fix passedByValueError on enums ( #2869 )
2020-10-30 18:32:35 +01:00
Daniel Marjamäki
6d0b78433b
astyle formatting
2020-10-29 21:43:56 +01:00
Daniel Marjamäki
e044d6e219
Clang import: fixed AST for 'return new S()'
2020-10-29 21:43:35 +01:00
Daniel Marjamäki
9ed4dc4199
Clang Import: Fix AST for 'new S;'
2020-10-29 20:52:09 +01:00
Rikard Falkeborn
de19dc9e3e
Fix #8327 (Memleak with mmap return value check) ( #2864 )
...
Also fix a broken test case related to checking the return value -1
where socket was not defined in the library used in the tests.
This was tested running test-my-pr with 500 packages. The difference was
six fewer FPs.
2020-10-29 13:17:33 +01:00
Daniel Marjamäki
16f4f198eb
Clang import: handle DefaultStmt
2020-10-29 09:48:35 +01:00
Daniel Marjamäki
4eb829933e
Tokenizer: Fixed unwanted unknownMacro warning for decltype
2020-10-27 09:08:13 +01:00
Daniel Marjamäki
34c8334882
Fixed #9737 (False positive: unreadVariable)
2020-10-25 20:32:45 +01:00
Daniel Marjamäki
05514950af
astyle formatting
...
[ci skip]
2020-10-25 07:12:30 +01:00
miltolstoy
d55874ec37
checkunusedvar: handle initialization list ( #2836 )
2020-10-25 07:11:45 +01:00
Daniel Marjamäki
3876b601d5
Fixed #9476 (Tokenizer: report unknown macro)
2020-10-24 22:12:10 +02:00
Rikard Falkeborn
d7a8e25d92
Fix #9647 : Set correct enum value ( #2856 )
...
* Tokenize: Set varId for variables in enum
Set varIds in enum values. It was previously disabled in 5119ae84b8
to avoid issues with enums named the same as global variables. Take care
to only set varids to variables used to set the value of an enumerator,
not the enumerator itself. This is somewhat complicated by the fact that
at the time this happens, astOperand1(), astOperand2(), astParent() etc
are not set. The current implementation is not perfect, for example in
the code below, y will not have a varid set, but x and z will. This is
deemed sufficient for now.
int x, y, z;
enum E { a = f(x, y, z); };
* Fix #9647 : Value of enums with variables as init values
C++ allows enum values to be set using constexprs, which cppcheck did
not handle before. To solve this, add a new pass to valueflow to update
enum values after global consts have been processed. In order to do so,
I moved all settings of enum values to valueflow. After setting the enum
values, we need another call to valueFlowNumber() to actually set users
of the enums.
There is still room for improvements, since each pass of
valueFlowGlobalConstVar() and valueFlowEnumValue() only sets variables
that are possible to set directly, and not if setting the value of a
variable allows us to set the value of another. For example
constexpr int a = 5;
constexpr int b = a + 5;
enum E { X = a };
constexpr E e = X;
Here both b and e will not have their values set, even though cppcheck
should be possible to figure out their values. That's for another PR
though.
This was tested by running test-my-pr.py with 500 packages. The only
difference was one error message in fairy-stockfish_11.1, where cppcheck
now printed the correct size of an array instead of 2147483648 which I
assume is some kind of default value. In that package, using a constexpr
when setting enum values is common, but as mentioned, there was no
change in the number of warnings.
2020-10-22 07:45:04 +02:00
Paul Fultz II
64638d82bb
Fix issue 9945: FP: containerOutOfBounds ( #2845 )
2020-10-22 07:41:52 +02:00
Daniel Marjamäki
47914b9960
Crash: Add regression test
2020-10-22 07:40:06 +02:00
Ken-Patrick Lehrmann
e4a54a24db
Fix regression in CheckCondition ( #2854 )
...
Introduced by e2a81a382f
.
2020-10-20 07:56:41 +02:00
Rikard Falkeborn
2624d791e6
Symboldatabase: Don't set unknown enum values ( #2852 )
...
Previously, if an enum value was set to a value unknown to cppcheck, the
next enum value would erroneously be set to the last set value plus one
(or zero, if no enum value had been set before). This partially fixes
Trac ticket #9647 , in the sense that it no longer sets wrong values for
these enum values. Further improvements to this would be to set the
correct values instead. It also fixes the false positive mentioned in the
comments in the ticket.
2020-10-18 20:41:36 +02:00
Rikard Falkeborn
33739d23aa
Fix #9941 : Return value type of library functions returning unsigned ( #2848 )
...
Fix return value types of library functions returning unsigned.
Previously, the valueType of auto x = f() would be signed even if f()
was specified to return an unsigned type.
This fixes #9941 , which is a regression in cppcheck 2.2 compared to 2.1.
The regression was introduced in 32df807b22
.
2020-10-16 07:56:31 +02:00
Daniel Marjamäki
f1ce5a9101
Fixed #9929 (False positive: suspicious semicolon after macro)
2020-10-09 20:34:20 +02:00
Paul Fultz II
047c3ed6ba
Fix issue 9935: FP: knownConditionTrueFalse value flow doesn't account for virtual functions ( #2839 )
2020-10-09 17:21:27 +02:00
Daniel Marjamäki
586ddf74f1
Clang import; fixed ast for function call with multiple arguments
2020-10-09 07:54:16 +02:00
Daniel Marjamäki
65721dd7a9
Bug hunting; Better handling of constant
2020-10-08 17:24:35 +02:00
Daniel Marjamäki
40faca7dd9
Fix TestClangImport
2020-10-06 23:19:32 +02:00
Daniel Marjamäki
64608f4e95
clang import; fix symbol database for 'struct Fred { int a; }; int b; void f(int c, int d) { int e; }'
2020-10-06 19:06:10 +02:00
Paul Fultz II
372161c89b
Fix issue 9939: False positive: Reference to temporary returned (static variable) ( #2840 )
2020-10-06 09:16:54 +02:00
Daniel Marjamäki
67cc1776d5
Clang import: fixed return type
2020-10-04 20:02:19 +02:00
Daniel Marjamäki
e3ab688597
Clang import: Fix syntax tree for 'case 1'
2020-10-04 19:33:28 +02:00
Daniel Marjamäki
c3de128a5f
Testing backwards compatible inline suppression
2020-10-04 16:42:09 +02:00
Daniel Marjamäki
c3517924d0
Clang import testing: Compare AST
2020-10-04 11:27:31 +02:00
Daniel Marjamäki
b052843655
exprengine: Use and tweak ExprEngine::ArrayValue::MAXSIZE
2020-10-04 11:21:13 +02:00
Paul
828a5e2326
Fix issue 9930: valueFlowLifetime hang
2020-10-03 11:01:53 +02:00
Daniel Marjamäki
8d20d8afb5
Update Copyright year
2020-10-03 09:15:56 +02:00
Daniel Marjamäki
27fbe28804
Try to make Travis happy
2020-10-02 21:24:30 +02:00
Daniel Marjamäki
aa055fe430
try to make test/cli happy
2020-10-02 20:30:28 +02:00
Daniel Marjamäki
6de91d6386
Fixed #9707 (False positive: unreadVariable, union)
2020-10-02 20:22:22 +02:00
Daniel Marjamäki
ea3a9d658a
Suppressions: Add special case for backwards compatibility. suppression comment after a {.
2020-10-02 18:56:26 +02:00
Daniel Marjamäki
1251d35ba4
Fix SymbolDatabase for 'extern const char ( * x [ 256 ] ) ;'
2020-10-02 08:25:43 +02:00
orbitcowboy
da6f10e369
Astyle formatting code [ci skip]
2020-10-01 08:33:16 +02:00
Daniel Marjamäki
1548bf2267
Fix googletest.cfg macros ASSERT_THROW and EXPECT_THROW to avoid syntax errors
2020-09-30 18:45:04 +02:00
orbitcowboy
63917bc3c3
Better fix for c4dd8536c1
2020-09-30 15:44:06 +02:00
Daniel Marjamäki
c4dd8536c1
Fixed make checkcfg
2020-09-30 12:36:31 +02:00
Daniel Marjamäki
fe2717fa37
Fixed testrunner
2020-09-29 17:43:53 +02:00
Daniel Marjamäki
bf3833dad5
Avoid constStatement false positives for 'foo() || x=5'. Found in daca@home.
2020-09-29 13:35:39 +02:00
Daniel Marjamäki
f956dee58a
Tokenizer: Fixed simplification of parentheses in expression 'a=(b,c);'
2020-09-29 12:06:30 +02:00
Daniel Marjamäki
31c800e19e
Fixed false positive: suspicious operator ',' seen in daca@home
2020-09-29 11:32:48 +02:00
Daniel Marjamäki
ad9b2741cd
varid: set varid for 'extern const char (*x[256]);'. This is a partial fix for #9922
2020-09-29 10:53:20 +02:00
Daniel Marjamäki
d901edd4af
Avoid clarifyCalculation warning for 'x % 16 ? 1 : 0' expression. Fixes FP seen in daca@home. It seems likely that the order is understood otherwise the ternary calculation could easily be simplified away.
2020-09-29 08:39:21 +02:00
Daniel Marjamäki
e32ccb591b
Fixed clarifyCalculation fp for 'a % b ? "a" : "b"'. seen in daca@home.
2020-09-29 08:29:23 +02:00
Daniel Marjamäki
bf236e91d7
Fixed #9918 (False positive: autoVariable pointer is NULLed later)
2020-09-28 22:48:57 +02:00
Daniel Marjamäki
8395522390
Fixed #9919 (False positive: clarifyCalculation for code: flags & ZRL_EOL_NUL ? '\0' : '\n')
2020-09-28 19:18:34 +02:00
Daniel Marjamäki
fa42d8c49c
Fixed #9920 (Tokenizer: The keyword is not replaced, leads to false positive)
2020-09-28 16:35:50 +02:00
Daniel Marjamäki
2748201d73
Fixed #9782 (Segmentation fault due to broken AST)
2020-09-27 20:41:09 +02:00
Daniel Marjamäki
ba84303501
Fixed #9680 (false positive: style: Variable 'x' is assigned a value that is never used with smart pointers)
2020-09-27 19:15:15 +02:00
Daniel Marjamäki
7bb82c5df7
Fixed #9901 (False positive: variable is assigned value that is not used 'if (--N == 0)')
2020-09-26 22:13:05 +02:00
Daniel Marjamäki
0ec77879ea
Fix crash in createAST when checking wiggle in daca@home
2020-09-26 19:22:24 +02:00
Daniel Marjamäki
5578b09452
More fixing for #9914 . New warning id and warning message when variable expression is explicitly hidden.
2020-09-26 13:49:47 +02:00
Daniel Marjamäki
05b0a0f970
Make duplicateAssignExpression warnings inconclusive for 'x&&false' etc. ( #9914 )
2020-09-26 10:50:58 +02:00
Paul Fultz II
887b40e08b
Fix issue 9916: False positive: duplicateAssignExpression when it's checked if variables have initial value later ( #2825 )
2020-09-26 10:31:40 +02:00
Daniel Marjamäki
5856fef83b
Fixed #9914 (False positive: knownArgument for 'x && false')
2020-09-25 20:27:16 +02:00
Daniel Marjamäki
5b78c64420
Fixed testrunner
2020-09-25 20:04:07 +02:00
Daniel Marjamäki
485153c930
Limit variableScope check. Do not check C code if all local variables are declared at function level.
2020-09-25 08:34:47 +02:00
Daniel Marjamäki
093ff58f5f
Fix crash in cbmc detected with daca@home
2020-09-24 20:48:26 +02:00
Daniel Marjamäki
801cc8d331
Fixed knownArgument false positive for pointer
2020-09-24 19:48:20 +02:00
Daniel Marjamäki
c08e1a9a94
Fix knownArgument false positive when sizeof is used
2020-09-24 19:43:39 +02:00
Daniel Marjamäki
514b7f4da4
Fixed #9906 (False positive: constParameter (function pointer))
2020-09-23 22:10:47 +02:00
Oliver Stöneberg
dae37f1c9f
disabled precompiled headers in CMake as they currently do not emit any compiler warnings / adjusted check for precompiled header ( #2820 )
2020-09-23 07:51:21 +02:00
Paul Fultz II
d9eacaecbb
Fix issue 9842: ValueFlow: wrong handling of ?, seems to think that the whole expression is a condition ( #2821 )
2020-09-23 07:45:03 +02:00
Daniel Marjamäki
107ee57e7a
Fixed #9909 (False positive: knownArgument for calculation 'self->maxsize * sizeof(intptr_t)')
2020-09-21 20:02:55 +02:00
Oliver Stöneberg
7189b303ae
fixed some modernize-loop-convert clang-tidy warnings ( #2815 )
2020-09-21 19:30:47 +02:00
Paul Fultz II
7b6d3f8061
Fix issue 9907: False positive: knownEmptyContainer after function call with :: ( #2814 )
2020-09-20 22:37:28 +02:00
Daniel Marjamäki
730b95331e
Fixed #9905 (False positive: known argument 'header.length()')
2020-09-20 20:17:10 +02:00
Paul Fultz II
857722f859
Fix issue 9711: FP knownConditionTrueFalse for variable modified via pointer ( #2813 )
2020-09-20 14:27:09 +02:00
Paul Fultz II
c2e8051196
Fix issue 9904: False positive: duplicateCondition when modifying variable in lambda ( #2811 )
2020-09-18 07:44:26 +02:00
Paul Fultz II
e5d0ffdbe7
Fix issue 9900: False positive: Returning lambda that captures local variable 'x' that will be invalid when returning. ( #2809 )
2020-09-17 08:33:52 +02:00
Paul Fultz II
782684a7cc
Fix issue 9530: False positive: Reference to temporary returned when using initializer lists ( #2796 )
2020-09-17 08:33:16 +02:00
Paul Fultz II
11c99d7387
Fix issue 9880: False positive: danglingLifetime ( #2810 )
2020-09-17 07:23:38 +02:00
Paul Fultz II
ebbff08932
Fix issue 9899: False positive: Non-local variable will use object that points to local variable ( #2808 )
2020-09-15 07:11:52 +02:00
Daniel Marjamäki
3459f0da32
Fixed #9812 (False positive; syntax error 'using array_p = const array_t *;')
2020-09-14 21:59:58 +02:00
shaneasd
53a0760fdf
Improve ast generation for templated function parameters ( #2803 )
2020-09-14 18:44:50 +02:00
Paul Fultz II
a42976d656
Fix issue 9898: false positive: knownConditionTrueFalse ( #2806 )
2020-09-14 18:43:11 +02:00
Daniel Marjamäki
4dd85cfbe0
Merge pull request #2802 from rikardfalkeborn/9228-fix-fn-with-realloc-and-null-assignment
...
Improve memleakOnRealloc with assignment to NULL
2020-09-14 11:04:29 +02:00
Paul Fultz II
94850fec3f
Fix issue 9897: False positive: nullPointerRedundantCheck ( #2805 )
2020-09-14 09:17:29 +02:00
Paul Fultz II
bb7164171c
Fix issue 9894: ValueFlow: wrong known value below while with assignment ( #2804 )
...
* Fix issue 9894: ValueFlow: wrong known value below while with assignment
2020-09-14 08:03:25 +02:00
Rikard Falkeborn
791051ced0
Fix #9228 (FN common realloc mistake with assignment of NULL)
...
Do not match for assignments with NULL.
2020-09-13 21:49:49 +02:00
Rikard Falkeborn
da8ad9ce19
memleakOnRealloc: Don't warn if pointer is NULL in condition
2020-09-12 18:48:23 +02:00
Paul
be900873cc
FIx issue 9895: ValueFlow: Wrong known value below function call with reference parameter
2020-09-11 16:03:57 -05:00
Daniel Marjamäki
e03a8e1dc1
Fixed #9892 (Crash: endless recursion in Token::typeDecl for expression 'auto combo = widget->combo = new Combo{};')
2020-09-11 21:29:48 +02:00
Daniel Marjamäki
61145cf878
test/cli/test-inline-suppress.py: better testing
2020-09-11 18:29:42 +02:00
Daniel Marjamäki
600538a325
Merge pull request #2793 from Ken-Patrick/mixedoperators
...
Fix false positives with condition with || and &&
2020-09-11 10:11:31 +02:00
Daniel Marjamäki
d46b9cec5f
Merge pull request #2795 from pfultz2/fp-lifetime-temp-function-obj
...
Fix issue 9889: False positive: Using reference to dangling temporary with function object
2020-09-11 09:05:43 +02:00
Daniel Marjamäki
7e02789d3f
Merge pull request #2794 from pfultz2/lifetime-temp-ref-move
...
Fix issue 9888: False positive: Using reference to dangling temporary with std::move
2020-09-11 07:20:32 +02:00
Daniel Marjamäki
ac66f67bad
Merge pull request #2790 from pfultz2/forward-analyze-accumulate-actions
...
Fix issue 9833: False positive: Division by zero when using pointer to struct
2020-09-11 07:17:10 +02:00
Paul
71bc79ac28
Fix issue 9889: False positive: Using reference to dangling temporary with function object
2020-09-10 22:58:17 -05:00
Paul
b26c581556
Fix issue 9888: False positive: Using reference to dangling temporary with std::move
2020-09-10 22:38:31 -05:00
Paul
4d1b3e06c7
Fix FPs
2020-09-10 17:06:49 -05:00
Ken-Patrick Lehrmann
a114bf0293
Fix false positives with condition with || and &&
...
The value of something in the middle of a condition with mixed || and &&
gives no information on which branch will be taken.
For instance with:
```
int f(int a, int b, bool x) {\n"
if (a == 1 && (!(b == 2 && x))) {
} else {
if (x) {
}
}
return 0;
}
```
We can enter the if part whether x is true or false, and similarly,
enter the else part whether x is true or false. Same thing with the
value of b.
This fixes the following false positive with above code:
```
:4:13: style: Condition 'x' is always true [knownConditionTrueFalse]
if (x) {
^
:2:33: note: Assuming that condition 'x' is not redundant
if (a == 6 && (!(b == 21 && x))) {
^
```
2020-09-10 23:27:39 +02:00
Daniel Marjamäki
2b12ef653d
Merge pull request #2792 from IOBYTE/main
...
fix #9886 (Hang in TemplateSimplifier (gcc/gcc/testsuite/g++.dg/cpp0x…
2020-09-10 21:47:44 +02:00
Daniel Marjamäki
51f5f2c7d0
Fix inline suppressions problem
2020-09-10 21:46:15 +02:00
Robert Reif
a52ce7379a
fix #9886 (Hang in TemplateSimplifier (gcc/gcc/testsuite/g++.dg/cpp0x/decltype34.C))
2020-09-10 14:47:59 -04:00
Paul
5033fb4418
Fix issue 9869: False positive: knownEmptyContainer when passed to constructor
2020-09-09 22:23:42 -05:00
Paul
75b955b9c6
Fix issue 9833: False positive: Division by zero when using pointer to struct
2020-09-09 21:29:26 -05:00
Paul Fultz II
34d65e25d6
Merge branch 'main' into lifetime-subfunction
2020-09-09 12:02:02 -05:00
Daniel Marjamäki
7c8c0ef3a2
Bug hunting: Avoid uninit struct member false positives
2020-09-09 18:26:04 +02:00
Daniel Marjamäki
f95a53b0ca
Fixed #9821 (False positive: Delegating constructor and initialization list)
2020-09-09 18:04:21 +02:00
Paul Fultz II
bfe53fce04
Fix issue 9878: false positive: multiCondition ( #2787 )
2020-09-09 15:39:36 +02:00
Daniel Marjamäki
b1401c6536
Merge pull request #2789 from pfultz2/smart-ptr-constructor
...
Fix issue 9496: False negative: Dereferencing returned smart null-pointer
2020-09-09 08:16:30 +02:00
Daniel Marjamäki
1c37423f1b
Merge pull request #2788 from pfultz2/lifetime-dangling-temp-reference
...
Fix issue 9835: False negative: Return reference to temporary with const reference
2020-09-09 08:01:22 +02:00
Paul
965fea370f
Formatting
2020-09-08 21:55:53 -05:00
Paul
382408f59e
Fix issue 9496: False negative: Dereferencing returned smart null-pointer
2020-09-08 21:54:38 -05:00
Paul
8d7088aa24
Fix issue 9835: False negative: Return reference to temporary with const reference
2020-09-08 18:30:45 -05:00
Daniel Marjamäki
5376decbe7
Merge pull request #2783 from pfultz2/out-of-bounds-at-index
2020-09-08 20:30:31 +02:00
Paul
8c425790f4
Merge branch 'main' into lifetime-subfunction
2020-09-08 13:18:01 -05:00
Daniel Marjamäki
18e99176e5
Fix issue 9883: endless recursion in getLifetimeTokens ( #2786 )
2020-09-08 20:14:54 +02:00
Paul Fultz II
5099ca3c8b
Fix issue 9882: segfault in ForwardTraversal ( #2785 )
2020-09-08 20:14:10 +02:00
Paul
d5489fd1f0
Fix issue 9883: endless recursion in getLifetimeTokens
2020-09-08 11:33:29 -05:00
Paul
1be67ea008
Merge
2020-09-08 11:00:57 -05:00
Daniel Marjamäki
e802d85315
Fixed #9445 (Syntax error on typeof word in C)
2020-09-08 17:12:54 +02:00
Daniel Marjamäki
c0ef640304
Fixed #9881 ((Regression) Hang with operator() in function call)
2020-09-07 21:32:29 +02:00
Daniel Marjamäki
07f6876dc8
Bug hunting; avoid uninit var fp for struct variables
2020-09-07 21:19:07 +02:00
Daniel Marjamäki
cfd41fea83
Fixed #9879 (Tokenizer: Better handling of operator() '(*this)(...)')
2020-09-07 20:07:21 +02:00
IOBYTE
2106e30304
fix template namespace bug ( #2780 )
...
Co-authored-by: Robert Reif <reif@FX6840>
2020-09-07 17:45:19 +02:00
Daniel Marjamäki
acfff072ae
Bug hunting; avoid bughuntingUninitVar fp for template variable
2020-09-07 16:25:37 +02:00
Paul Fultz II
ac67049661
Fix issue 9858: Token::astOperand1() cyclic dependency on valid C++ code ( #2784 )
2020-09-07 10:54:32 +02:00
Paul Fultz II
362ab44c40
Fix issue 9646: False negative: Return reference to temporary with const reference ( #2782 )
2020-09-07 10:52:54 +02:00
Daniel Marjamäki
06c4b8897b
Bug hunting: Avoid uninitialized fp for smart pointer
2020-09-07 09:34:08 +02:00
Paul Fultz II
a4f43fc2ad
Fix issue 8234: false negative: (warning) Opposite inner 'if' condition leads to a dead code block. ( #2781 )
2020-09-07 07:53:41 +02:00
Paul
7754449fd6
Format
2020-09-06 23:48:05 -05:00
Paul
04c85baf03
Fix issue 8869: false negative: (error) Invalid v.at() argument nr 1
2020-09-06 23:46:31 -05:00
Paul
786672e19d
Format
2020-09-06 21:59:21 -05:00
Paul
c7a5d3c5f1
Fix FPs
2020-09-06 21:58:36 -05:00
Daniel Marjamäki
136ac2c643
Fixed #9266 (handle operator() better)
2020-09-06 21:02:06 +02:00
Daniel Marjamäki
4bf411d63d
ImportProject: Add test case
2020-09-06 16:08:42 +02:00
Daniel Marjamäki
54b5e77548
TestImportProject: Use raw strings
2020-09-06 16:00:19 +02:00
Dan
7efd84ecaf
Fix false skipping of folder-seperator ( #2749 )
2020-09-06 15:35:14 +02:00
shaneasd
9712c136bd
make result of <<|>> an xvalue ( #2775 )
2020-09-05 12:07:06 +02:00
Paul Fultz II
cc2bc74084
Track lifetime for lambdas with explicit capture ( #2776 )
2020-09-05 07:56:01 +02:00
Daniel Marjamäki
8027f40418
Fixed #8506 (CPPCheck printing invalid characters in output)
2020-09-04 20:43:54 +02:00
Daniel Marjamäki
1daf1ec108
Fixed #9875 (Crash)
2020-09-04 19:15:48 +02:00
Paul
264c0cae8b
Formatting
2020-09-04 11:59:30 -05:00
Paul
bb37b07def
Extend lifetimes to subfunctions
2020-09-04 11:56:34 -05:00
Daniel Marjamäki
30d3643bb8
Fixed #9851 (FP virtualDestructor - private virtual dtor)
2020-09-04 18:56:12 +02:00
Daniel Marjamäki
040da4ff32
astyle formatting
2020-09-04 18:43:17 +02:00
Daniel Marjamäki
7d01ad5b50
add test-clang-import that compares symboldatabases
2020-09-04 15:29:19 +02:00
IOBYTE
2db0d2878b
fix daca crash in TemplateSimplifier::getNewName ( #2772 )
...
Don't add the same template instantiation multiple times.
Co-authored-by: Robert Reif <reif@FX6840>
2020-09-04 07:08:28 +02:00
shaneasd
84dd0c961f
False positive dynamic_cast auto variable which has been checked against null ( #2769 )
2020-09-04 07:06:26 +02:00
Daniel Marjamäki
dba7108832
Remove test-clang-import for now so I can fix that
2020-09-03 21:43:26 +02:00
Daniel Marjamäki
1ce6eb34fb
test-clang-import: try to use --std=c++11
2020-09-03 21:13:08 +02:00
Daniel Marjamäki
c4da64b38b
Fix test-clang-import
2020-09-03 20:19:33 +02:00
Daniel Marjamäki
b3d7289460
test-clang-import: Only run tests if clang is in PATH
2020-09-03 20:18:33 +02:00
Daniel Marjamäki
5cd92a0eb1
test/cli/test-clang-import: Improved testing
2020-09-03 19:49:02 +02:00
Daniel Marjamäki
115ad374ba
test-clang-import.py: make it python2 compatible
2020-09-03 19:04:42 +02:00
Daniel Marjamäki
5acd6fcdc8
astyle formatting
2020-09-03 18:55:40 +02:00
shaneasd
08ea6435ac
fix false positives in constParameter ( #2758 )
2020-09-03 18:44:44 +02:00
Daniel Marjamäki
68ec7dad41
Add clang import test
2020-09-03 18:39:46 +02:00
Daniel Marjamäki
3fe46239cf
SymbolDatabase; Refactoring, use Tokenizer::isFunctionHead to skip function attributes
2020-09-03 11:21:12 +02:00
Dan
974b6fb8e5
Add test cases for assign operators with default implementation ( #2767 )
2020-09-03 07:29:54 +02:00
Paul Fultz II
090eba7e7f
FIx issue 6140: ValueFlow: valueFlowForward, loop ( #2770 )
2020-09-03 07:17:36 +02:00
Paul Fultz II
03cefd5d70
Fix issue 9853: False positive: returnReference when using a pointer to container ( #2765 )
2020-09-02 20:01:08 +02:00
Daniel Marjamäki
12d51ae5c4
Fixed #9809 (Tokenizer; Fix handling of variable declaration with @)
2020-09-02 13:04:33 +02:00
Paul Fultz II
32df807b22
Fix issue 9783: wrong lifetime analysis temporary assigned to object ( #2711 )
2020-09-02 07:13:15 +02:00
Paul Fultz II
dea5a23c34
Improve check: check for known empty containers passed to algorithms ( #2768 )
2020-09-02 07:11:23 +02:00
Daniel Marjamäki
8e79b0c8bc
astyle formatting
...
[ci skip]
2020-09-01 20:00:04 +02:00
Daniel Marjamäki
1f8896e51c
clang import: try to handle CXXFunctionalCastExpr
2020-09-01 19:59:41 +02:00
Paul Fultz II
ba84196dca
Fix issue 9865: false positive: knownConditionTrueFalse ( #2764 )
2020-09-01 11:22:38 +02:00
Paul Fultz II
0a718694af
Fix issue 9852: False positive: danglingTemporaryLifetime when returning a vector of vectors ( #2766 )
2020-09-01 11:21:29 +02:00
Paul Fultz II
3e99bff764
Same expression when comparing with zero ( #2762 )
2020-08-31 08:48:48 +02:00
Paul Fultz II
1c5f496350
Fix issue 8373: false negative: invalid iterator ( #2761 )
2020-08-31 08:46:56 +02:00
Paul Fultz II
6ab3c93fb1
Fix issue 9756: false negative: invalid iterator from std::find_if ( #2760 )
2020-08-28 19:29:09 +02:00
Paul Fultz II
82bdbcd73b
Fix issue 9859: false positive: knownConditionTrueFalse ( #2759 )
2020-08-28 19:26:09 +02:00
Paul Fultz II
494fff65b7
Add outOfBounds check for iterators to containers ( #2752 )
2020-08-26 21:05:17 +02:00
IOBYTE
8774e97f26
fix #9771 (Syntax error; operator != <> ()) ( #2757 )
2020-08-26 18:39:33 +02:00
Daniel Marjamäki
bb5cad42cd
astyle formatting
...
[ci skip]
2020-08-26 10:15:09 +02:00
Paul Fultz II
9ec27c112f
Fix issue 9855: false positive: uninitvar ( #2754 )
2020-08-26 07:02:15 +02:00
IOBYTE
7cf3909275
fix #9854 (Syntax error on valid C++ code) ( #2756 )
2020-08-26 07:00:58 +02:00
Paul Fultz II
46bf2d7d52
Dont diagnose impossible values for iterators ( #2755 )
2020-08-26 06:58:53 +02:00
shaneasd
45fc6a0eeb
Test for syntax error in nested templates ( #2746 )
2020-08-25 07:14:44 +02:00
Paul Fultz II
ec89c57a90
Fix issue 9849: false positive: containerOutOfBounds ( #2753 )
2020-08-25 07:12:41 +02:00
Daniel Marjamäki
6277eece67
Variable contracts
2020-08-24 20:57:49 +02:00
Paul Fultz II
02287d9d34
Fix issue 7324: valueFlowForward : decrement ( #2737 )
2020-08-24 13:10:36 +02:00
Daniel Marjamäki
2bb73840fc
astyle formatting
2020-08-23 17:17:33 +02:00
Paul Fultz II
ac846b96d1
New check: Iterating a known empty container ( #2740 )
2020-08-22 09:16:26 +02:00
eivindt
27e40af06c
Add support for comments at end of suppression in suppression files ( #2736 )
2020-08-20 21:49:07 +02:00
Paul Fultz II
a332062385
Add exprId to tokens ( #2744 )
2020-08-20 18:21:29 +02:00
Daniel Marjamäki
6446790d48
Merge pull request #2739 from dan-42/fix_ticket_9839_ast_error
...
Fix ticket 9839: AST broken; range for loop that uses decltype
2020-08-18 21:59:50 +02:00
Paul
7776fb82a2
Fix issue 737: new check: Dereference end iterator
2020-08-17 16:36:45 -05:00
Daniel Friedrich
160b8f0f17
Add test case to reproduce bug
...
Add tokenizer test range based for with decltyle(x) *
2020-08-17 20:51:45 +02:00
Paul
71c228a01a
Check for containers that modify the size using square bracket
2020-08-10 22:07:22 -05:00
Paul
a5b0a1c9e2
Evaluate container size in program memory
2020-08-10 20:08:49 -05:00
Paul
fec2914700
Add tests for container changes
2020-08-09 22:52:03 -05:00
Paul
26693df788
Use forward analyzer for container forward
2020-08-08 00:10:03 -05:00
Daniel Marjamäki
b263b93f73
Merge pull request #2732 from pfultz2/invalid-container-subobj
...
Fix issue 9780: FP: invalidContainer calling push_back after getting the address of the vector
2020-08-07 09:52:25 +02:00
Paul
56affc9080
Fix issue 9780: FP: invalidContainer calling push_back after getting the address of the vector
2020-08-06 21:08:30 -05:00
Daniel Marjamäki
5372e93964
Fixed #9825 (redundantAssignment: Do not warn about volatile data)
2020-08-06 22:18:25 +02:00
Paul
0cc1f69862
Fix issue 9770: FP returnDanglingLifetime for class method taking const char* and returning std::string
2020-08-05 23:17:35 -05:00
Daniel Marjamäki
d5b64d9c3a
Clarify inconclusive uninitMemberVar warning in copy constructors, it's in general a good idea to copy all the data.
2020-08-05 13:57:40 +02:00
Daniel Marjamäki
7a85b8e452
Do not ask that calculation is clarified when different order would be invalid
2020-08-05 13:20:18 +02:00
Jens Yllman
5ba5916a11
clearer name on the test
2020-08-03 10:30:21 +02:00
Jens Yllman
1cc16deba3
test added to show it works after fix
2020-07-30 22:22:54 +02:00
Daniel Marjamäki
fab3a8efc8
Merge pull request #2721 from KenPatrickLehrmann/compound_assign_bitshift
...
Add missing operators <<= and >>=
2020-07-25 09:39:32 +02:00
Daniel Marjamäki
6a839ad511
Fixed #9814 (False positive: functionConst, trailing return type)
2020-07-24 19:40:42 +02:00
Paul
46e008c3e2
Fixed #9816 (False positive: Condition '!b' is always false in nested do-while loop)
2020-07-24 08:13:14 +02:00
Daniel Marjamäki
53e11ead8f
Fix Cppcheck warning: unused variable in test
2020-07-23 19:50:41 +02:00
Ken-Patrick LEHRMANN
a923115710
Add missing operators <<= and >>=
...
This fixes issues (at least false positives) in code using them.
For instance:
```
unsigned compute(unsigned long long a) {
unsigned num = 0;
while (a > 0xFFFFFFFF) {
a >>= 32;
num += 32;
}
if (a > 0xFFFF) {
a >>= 16;
num += 16;
}
if (a > 0xFF) {
num += 8;
}
return num;
}
```
would give false positive:
```
cppcheck --enable=style sl3.cpp
Checking sl3.cpp ...
sl3.cpp:11:11: style: Condition 'a>0xFF' is always false [knownConditionTrueFalse]
if (a > 0xFF) {
^
sl3.cpp:3:14: note: Assuming that condition 'a>0xFFFFFFFF' is not redundant
while (a > 0xFFFFFFFF) {
^
sl3.cpp:11:11: note: Condition 'a>0xFF' is always false
if (a > 0xFF) {
^
```
2020-07-23 14:36:34 +02:00
Daniel Marjamäki
682a6d1c02
Fixed #9017 (Simple classes without side effects not reported as unused)
2020-07-23 11:10:08 +02:00
Daniel Marjamäki
25ad22c6af
astyle formatting
...
[ci skip]
2020-07-23 10:09:06 +02:00
Daniel Marjamäki
df99d8aa0a
Merge pull request #2719 from pfultz2/fp-unreachable-alias
...
Fix issue 9807: False positive: ValueFlow in unreachable code, || lhs is true
2020-07-23 09:52:54 +02:00
Daniel Marjamäki
2fd44fa464
Merge pull request #2710 from pfultz2/fp-invalid-container-pointer
...
Fix issue 9796: False positive: lifetime, pointer item is not deallocated by pop_back
2020-07-22 09:24:54 +02:00
Paul
abeea7b32b
Merge branch 'main' into fp-invalid-container-pointer
2020-07-21 13:31:13 -05:00
Paul
dbb410cdae
Merge branch 'main' into condition-in-expr
2020-07-21 13:28:59 -05:00
Rikard Falkeborn
7973fd843c
Refactor: Simplify checkSignConversion
...
The loop only checks astoperand1 and astoperand2. Simplify the condition
to loop over these instead of using a stack. Also, add a testcase for
when astoperand2 is negative.
2020-07-20 11:16:56 +02:00
Paul
e2a81a382f
Track reading aliases during valueflow forward
2020-07-19 23:25:35 -05:00
Daniel Marjamäki
4a76dbb632
Bug hunting; Avoid bailout uninit FP, stream object
2020-07-19 16:54:44 +02:00
Daniel Marjamäki
7e65b561f0
AST: Fix ast for 'for ((..initexpr..);;)'
2020-07-19 11:10:38 +02:00
Daniel Marjamäki
e9281babc4
Bug hunting; avoid false positives for structs/classes with constructors
2020-07-18 18:54:21 +02:00
Georgy Komarov
382f21a5c9
Fixed crash on garbage code: comparisson with an empty second operand
...
This will fix #9774 .
2020-07-18 07:02:12 +03:00
Paul
831690f89b
Use parseDecl instead
2020-07-16 14:33:39 -05:00
Daniel Marjamäki
47ff29f1c8
Merge pull request #2708 from pfultz2/multi-mutex-lock
...
Handle FPs: mutexes being locked at different scopes
2020-07-16 08:35:05 +02:00
Paul
423dcfd005
Fix issue 9796: False positive: lifetime, pointer item is not deallocated by pop_back
2020-07-15 12:22:36 -05:00
Daniel Marjamäki
af0db3cc21
Add cppcheck-id for warnings. To start with it's a simple id that changes when file is changed.
2020-07-14 22:30:42 +02:00
Paul
1f74400f13
Merge branch 'revert-mutex-delete' into multi-mutex-lock
2020-07-14 13:05:14 -05:00
Paul
4373404238
Revert "Fixed #9795 (False positive: Local lock is not ineffective, mutex is locked in thread also.)"
...
This reverts commit 27841d6b81
.
2020-07-14 13:04:59 -05:00
Daniel Marjamäki
e0be224f4e
Merge pull request #2709 from pfultz2/fp-duplicate-cond-this
...
Fix FP of duplicateCondition when modifying the this variable
2020-07-13 21:14:58 +02:00
Daniel Marjamäki
b2f463dd65
Merge pull request #2707 from Ken-Patrick/fp_pointer_expressions
...
Fix some false positives when the same expression at different places…
2020-07-13 20:59:22 +02:00
Paul
519f2a537a
Format
2020-07-13 13:55:45 -05:00
Daniel Marjamäki
33557012a1
Merge pull request #2706 from rikardfalkeborn/condition-fn-with-sizeof
...
Fix FN with known condition and sizeof
2020-07-13 20:54:25 +02:00
Daniel Marjamäki
cb221e970d
Bug hunting: Add test case for CVE-2019-12977. Passing uninitialized struct to function
2020-07-13 20:42:53 +02:00
Daniel Marjamäki
8ba714373f
Merge pull request #2704 from rikardfalkeborn/9635-memleak-with-comma-operator-in-if-statement
...
Fix #9635 (FP: Memory leak with comma operator in if-statement)
2020-07-13 20:08:57 +02:00
Paul
450bdfedf3
Fix FP of duplicateCondition when modifying the this variable
2020-07-13 12:40:01 -05:00
Daniel Marjamäki
4465d033f6
Bug hunting; When passing uninitialized data to unknown function it is inconclusive if that would be a problem for the function or not
2020-07-13 11:43:11 +02:00
Daniel Marjamäki
0009b4c8af
test/bug-hunting/cve.py: Add --slow argument to check slow packages
2020-07-13 11:18:51 +02:00
Paul
caabe56f14
Handle FPs: mutexes being locked at different scopes
2020-07-12 21:31:53 -05:00
Ken-Patrick Lehrmann
61ccf888b3
Fix some false positives when the same expression at different places does not have the same value
...
Typically with
```
int F(int *f);
void F2(int *a, int *b) {
int c = *a;
F(a); // modifies *a
if (b && c != *a) {}
}
```
we would get the following FP:
```
[test.cpp:3] -> [test.cpp:5]: (style) The comparison 'c != *a' is always false because 'c' and '*a' represent the same value.\n
```
I guess it boils down to isSameExpression only checking that the
expression is the same (in the above case, "*a" and "*a" are indeed the
same), but there's not real check on the values.
So the patch here is a bit hackish, and we still have false negatives in
cases with dereferenced pointers.
2020-07-11 14:13:18 +02:00
Rikard Falkeborn
d8e7e9176b
Fix FN with known condition and sizeof
...
cppcheck behaved differently if sizeof was to the left or right of the
comparison. In order to fix this, we cannot break the while loop until
all operands have been processed.
2020-07-10 23:39:16 +02:00
Daniel Marjamäki
27841d6b81
Fixed #9795 (False positive: Local lock is not ineffective, mutex is locked in thread also.)
2020-07-10 19:24:45 +02:00
Rikard Falkeborn
1e679cc5d1
Fix #9635 (FP: Memory leak with comma operator in if-statement)
...
When checking for comparisons in if-statements, if there are comma
operators in the if-statement, skip until after the last comma.
2020-07-09 21:31:43 +02:00
Daniel Marjamäki
0c6aabe444
Merge pull request #2703 from rikardfalkeborn/9652-fp-function-call-cast-config
...
Fix #9652 (fp memleak with function call with cast)
2020-07-08 15:10:41 +02:00
Rikard Falkeborn
4996ec190e
Fix #9652 (fp memleak with function call with cast)
...
When the first argument was (void *)(1), at the start of the second
iteration, arg was pointing to the "1", which caused problems for
nextArgument(), which saw the ")" as the next token and returned
nullptr, signalling that there are no more arguments.
Instead, save the first token in the argument, which makes
nextArgument() do the right thing.
2020-07-08 00:02:39 +02:00
Rikard Falkeborn
d5345052ab
Fix #9793 (false positive, memleak with lambda)
...
Skip scopes with lambdas (similar to how checkleakautovar does). In
order to fix this when the lambda is inside a for loop, make
hasInlineOrLambdaFunction() recursive. This should be what all existing
users want.
2020-07-07 21:51:36 +02:00
Daniel Marjamäki
921997c9e9
itc.py; false negative is fixed
2020-07-03 17:50:56 +02:00
orbitcowboy
cabafca5ae
windows.cfg: Added some constants from WinUser.h
2020-07-01 16:14:59 +02:00
Daniel Marjamäki
d2b2bae7bf
Fixed #7733 (False positive: scope of the variable can be reduced (variable is used in hidden code))
2020-07-01 08:24:52 +02:00
Daniel Marjamäki
f56a17bf3d
Fixed #8858 (FP: identicalConditionAfterEarlyExit when there is #if)
2020-07-01 07:48:32 +02:00
Daniel Marjamäki
0583763cc6
Fixed #3088 (False positive: Dont report "struct or union member is never used" for structs with __attribute__((packed)) or #pragma pack(push))
2020-06-30 11:00:40 +02:00
Paul
07d8cb4f01
Extend scope of afterCondition until end of function
2020-06-29 11:55:59 -05:00
Paul
edcf668ae2
Update test mesg
2020-06-29 10:15:36 -05:00
Daniel Marjamäki
a49d277e0d
Fixed #6471 (FP functionConst - member function modifying member variable after cast (inconclusive))
2020-06-29 13:09:01 +02:00
Paul
d5b6d49d96
Fix issue 9578: false negative: (style) Condition '...' is always false
2020-06-28 15:28:08 -05:00
Daniel Marjamäki
ad5e4fef1f
Bug hunting; improved handling of 'malloc' in uninit checker
2020-06-28 21:20:59 +02:00
Daniel Marjamäki
6c588cc3ef
Library: Refactoring <alloc> init attribute
2020-06-28 21:01:43 +02:00
Daniel Marjamäki
d4bd3016da
ExprEngine; Improved handling of for loop, loop variable
2020-06-28 17:28:40 +02:00
Daniel Marjamäki
c42c751d61
ExprEngine; Fixed testing
2020-06-28 13:41:27 +02:00
Daniel Marjamäki
e1704f2b50
Bug hunting; fix juliet test cases error id
2020-06-28 08:16:46 +02:00
Daniel Marjamäki
bcaf792e30
Bug hunting; Fix FP for struct with uninitialized members passed to function in C
2020-06-27 22:11:12 +02:00
Daniel Marjamäki
d353a4ecba
ExprEngine; copy Data => copy arrays
2020-06-27 18:09:43 +02:00
Daniel Marjamäki
e6aa96d90f
Bug hunting; Improved uninit checking
2020-06-27 14:59:02 +02:00
Daniel Marjamäki
e19ef6ac62
Bug hunting; Improved uninit checking for function calls with constant parameter
2020-06-27 14:15:53 +02:00
Daniel Marjamäki
ff5a717fc6
Bug hunting; Avoid false positives for const parameter data
2020-06-27 12:17:11 +02:00
Daniel Marjamäki
b09bcdc38c
Use ValueFlow for compareBoolExpressionWithInt
2020-06-27 08:13:22 +02:00
Daniel Marjamäki
1ad70bbeb8
Merge pull request #2697 from pfultz2/unique_lock
...
Extend mutex checking for more locking patterns
2020-06-27 07:32:26 +02:00
Daniel Marjamäki
c3749625f3
Merge pull request #2688 from jpyllman/fix_chklibfunc
...
not report locally declared functions as missing configuration of --check-library
2020-06-27 06:53:09 +02:00
Daniel Marjamäki
72bdeb9307
Merge pull request #2698 from pfultz2/const-param-casts
...
Fix issue 9778: False positive: constParameter when returning non-const reference cast
2020-06-27 06:45:30 +02:00
Paul
cf475fab51
Fix issue 9778: False positive: constParameter when returning non-const reference cast
2020-06-26 15:47:59 -05:00
Daniel Marjamäki
f5ace9ffbe
SymbolDatabase; Improved ValueType when container methods items
2020-06-26 22:47:28 +02:00
Paul
82b91869ee
Extend mutex checking for more locking patterns
2020-06-26 15:06:20 -05:00
orbitcowboy
b33326bf51
windows.cfg: Added a regression test for GetSystemInfo that ensure no uninitvar-FP is shown.
2020-06-26 20:45:18 +02:00
Daniel Marjamäki
cb8396aaf8
Merge pull request #2696 from pfultz2/getTokenArgumentFunction-ast
...
Fix issue 9710 and 9767: Use AST to get function from argument
2020-06-26 09:50:18 +02:00
Daniel Marjamäki
af6e76d623
Fixed #9787 (Better handling of user defined literals)
2020-06-25 22:06:34 +02:00
Paul
1676ad5f45
Fix issue 9710 and 9767: Use AST to get function from argument
2020-06-25 12:54:46 -05:00
Daniel Marjamäki
ec8fbb1580
Merge pull request #2682 from pfultz2/check-mutexes
...
Add new check for incorrect usage of mutexes and lock guards
2020-06-25 16:21:36 +02:00
Paul
3c10a9c659
Update message
2020-06-24 18:09:30 -05:00
Jens Yllman
a87686911a
one more test updated for the new checkLibraryFunction
2020-06-23 09:06:54 +02:00
Daniel Marjamäki
9b5986505e
AST; Improved ast for variable declaration with assignment
2020-06-22 08:34:31 +02:00
Daniel Marjamäki
f792cabc2b
ExprEngine; better handling of containers
2020-06-21 21:48:36 +02:00
Daniel Marjamäki
5497e8ed67
ExprEngine; Improved handling of stream read
2020-06-21 20:05:26 +02:00
Daniel Marjamäki
8ec5605bac
Merge pull request #2689 from Ken-Patrick/9769
...
9769: Improve value flow for ternary operator
2020-06-21 13:04:43 +02:00
Daniel Marjamäki
f270ca1909
ExprEngine; Better handling of function calls
2020-06-20 23:00:39 +02:00
Ken-Patrick Lehrmann
5a3789a23f
9769: Improve value flow for ternary operator
...
In some cases, the condition of the ternary operator is assigned a known
value after the two possible results, and in such cases, we would not
take the opportunity to assign a value to the ternary operator (and to
the other parents in the ast).
This patch adds this capability.
2020-06-20 10:29:28 +02:00
Jens Yllman
aa380e0de1
fix a test that was suppressed because #9002
2020-06-19 23:04:15 +02:00
Daniel Marjamäki
af45148e58
ExprEngine; Refactor and improve code. Add tests for increments.
2020-06-19 20:40:20 +02:00
Daniel Marjamäki
06aeac75dc
Bug hunting; Fix false negatives
2020-06-19 18:38:02 +02:00
Daniel Marjamäki
6ec15b6d7b
ExprEngine; Simple handling of increment/decrement
2020-06-19 17:35:35 +02:00
Daniel Marjamäki
f516bde744
ExprEngine; Fix TODO assertion
2020-06-19 14:05:19 +02:00
Daniel Marjamäki
ab663feea8
Add testbughuntingchecks.cpp
2020-06-19 13:38:56 +02:00
Daniel Marjamäki
d0ac583b97
Add 'bughuntingchecks'
2020-06-19 13:16:48 +02:00
Daniel Marjamäki
d3df68e376
Updated bug hunting test
2020-06-18 14:31:51 +02:00
Paul
f7029e62ac
Check for mor FPs
2020-06-17 17:06:06 -05:00
Daniel Marjamäki
3f8218af1b
Removed CheckClass::operatorEq: does not 'belong'
2020-06-17 20:35:43 +02:00
Ken-Patrick Lehrmann
c297ed8204
Better handle noreturn or throwing functions in valueflow
...
Teaching cppcheck about `BOOST_THROW_EXCEPTION` and
`boost::throw_exception`, and using noreturn information from libraries
in value flow.
This fixes false positive nullPointerRedundantCheck with the following
code:
```
void throwexception(int * buf)
{
if (!buf)
boost::throw_exception(std::bad_alloc());
*buf = 0;
}
```
2020-06-17 19:06:14 +02:00
Paul
21f76d62a1
Merge branch 'main' into check-mutexes
2020-06-17 10:45:43 -05:00
Daniel Marjamäki
51a6af299f
Merge pull request #2683 from Ken-Patrick/cast_expandTemplate
...
Fix handling of c++ casts in template expansion
2020-06-17 09:21:01 +02:00
Daniel Marjamäki
94f92f00fe
Merge pull request #2684 from firewave/precompiled
...
use precompiled headers if CMake supports it
2020-06-17 07:53:51 +02:00
Daniel Marjamäki
4947a3b7ab
Bug hunting; review and improve handling of multi dimensional arrays
2020-06-16 22:50:45 +02:00
firewave
a49d60f0b3
use precompiled headers if CMake supports it
2020-06-16 19:56:53 +02:00
Ken-Patrick Lehrmann
5c1a2db434
Fix handling of c++ casts in template expansion
...
Cast were not expanded properly: the `<` was not taken into account in
typeindentlevel, so we would then miss a `>`, resulting in syntaxError.
2020-06-16 19:36:04 +02:00
Paul
18225ee27e
Update text and change to warnings
2020-06-16 10:32:39 -05:00
Paul
172537807b
Add check for incorrect usage of mutexes and lock guards
2020-06-15 19:40:54 -05:00
Daniel Marjamäki
6faad9cd90
Bug hunting; better handling when assigning multidimensional array in for loop
2020-06-15 22:42:45 +02:00
Daniel Marjamäki
f5fe5ca2dd
9768: Fix ast with throw in the middle of return ( #2678 )
...
* 9768: Fix ast with throw in the middle of return
```
int f(bool x)
{
return x ? 0 : throw 0;
}
```
The `throw` part was not included in the ast, leading to an invalid
ternary operator.
* 8526: Fix ast construction for ternary operator
This tries to decide a bit more properly when ':' can be part of a
ternary operator. More precisely, there are some times when we want to
delay the construction of the ast for ':', so that it is place
accordingly to the matching '?'.
Typically, this fixes an issue with
`return val < 0 ? throw 1 : val;`,
where the ast for ':' would be constructed during as part of the
`throw`, and the ast for `?` would be invalid.
This patch is a bit of a hardcode, stating that we don't expect ':'
inside a throw, unless there is a complete ternary operator in there
(there can't be a range based for loop, a case in a switch). When we
reach ':', we know we are and the end of the `throw`.
2020-06-15 10:36:02 +02:00
Daniel Marjamäki
3fe2b6fe50
Update test. An inconclusive warning message is now shown.
2020-06-14 22:57:50 +02:00
Daniel Marjamäki
2b0e4926bc
valueFlowAfterAssign: variable initialization
2020-06-14 21:14:05 +02:00
Ken-Patrick Lehrmann
7ddb7aef7d
8526: Fix ast construction for ternary operator
...
This tries to decide a bit more properly when ':' can be part of a
ternary operator. More precisely, there are some times when we want to
delay the construction of the ast for ':', so that it is place
accordingly to the matching '?'.
Typically, this fixes an issue with
`return val < 0 ? throw 1 : val;`,
where the ast for ':' would be constructed during as part of the
`throw`, and the ast for `?` would be invalid.
This patch is a bit of a hardcode, stating that we don't expect ':'
inside a throw, unless there is a complete ternary operator in there
(there can't be a range based for loop, a case in a switch). When we
reach ':', we know we are and the end of the `throw`.
2020-06-14 18:57:18 +02:00
Ken-Patrick Lehrmann
4023a487ff
9768: Fix ast with throw in the middle of return
...
```
int f(bool x)
{
return x ? 0 : throw 0;
}
```
The `throw` part was not included in the ast, leading to an invalid
ternary operator.
2020-06-14 14:49:10 +02:00
Daniel Marjamäki
37245a8179
Update copyright year
2020-06-13 16:37:12 +02:00
Paul Fultz II
06ed088bd0
Fix issue 9751: Wrong lifetime caused by std::function ( #2676 )
2020-06-13 10:26:54 +02:00
Paul Fultz II
03b41ac987
Fix issue 9718: False positive: Parameter can be declared const when written to via stream extraction operator ( #2677 )
2020-06-13 09:20:40 +02:00
orbitcowboy
258d0a6ade
Running astyle [ci skip].
2020-06-12 16:08:40 +02:00
orbitcowboy
9f445fc735
Library: simplified code and added test cases for validating <valid>-tag expressions
2020-06-12 16:06:43 +02:00
orbitcowboy
05c36a79b5
Fix testrunner fail, introduced by latest commit
2020-06-12 09:18:16 +02:00
orbitcowboy
a3d58a9302
std.cfg: Allow scientific floating point notation for '<valid>'-tags
2020-06-12 08:51:33 +02:00
orbitcowboy
e767bb8ff3
std.cfg: Added tests for 'atanh'
2020-06-11 15:13:19 +02:00
orbitcowboy
0fe0e56986
std.cfg: Added tests for 'acosh'
2020-06-11 15:07:35 +02:00
Daniel Marjamäki
3f1f62e078
Fixed #9746 (SymbolDatabase: Wrong valueType for return)
2020-06-10 21:13:53 +02:00
orbitcowboy
4880f30dc3
std.cfg: Added tests for 'aligned_alloc'
2020-06-10 19:33:22 +02:00
Daniel Marjamäki
d31d778bf4
Fixed #9533 (Syntax Error: AST broken, 'for' doesn't have two operands incrementing pointer in initializer)
2020-06-09 20:57:00 +02:00
Paul Fultz II
0c659a1499
Fix incorrect logic for condition ( #2675 )
2020-06-09 08:16:53 +02:00
Daniel Marjamäki
6d796b434e
Fixed #9731 (ValueFlow: does not handle many assignments well)
2020-06-08 21:17:12 +02:00
Simon Martin
1705d096f7
Simplify empty anonymous namespaces. ( #2673 )
2020-06-07 13:49:04 +02:00
Ken-Patrick Lehrmann
a45c7752a5
9185: Don't syntax error on nested lambdas ( #2672 )
2020-06-07 08:58:12 +02:00
Paul Fultz II
86ed860d26
Fix issue 9548: False negative: Mismatching iterators when inserting into a vector ( #2595 )
2020-06-06 17:54:56 +02:00
Ken-Patrick Lehrmann
99ff04f617
9757: skip template parameters when computing scope ( #2670 )
...
The template parameter is confusing simplifyUsing: it does not compute
properly the scope, and we end up replace "type" in "to_string" with
"void", then later "void" is removed and we have an internal error.
2020-06-06 17:51:15 +02:00
Daniel Marjamäki
44ff22f879
Fixed #9276 (FP literalWithCharPtrCompare)
2020-06-06 17:47:30 +02:00
Daniel Marjamäki
120c572252
Fixed #9750 (Chained stream operation gives uninitvar error)
2020-06-06 15:24:01 +02:00
Ken-Patrick Lehrmann
8c2c81dbcd
Fix some false positive in loop forward analysis ( #2669 )
...
* Fix some false positive in loop forward analysis
In cases like:
```
bool b();
void f()
{
int val[50];
int i, sum=0;
for (i = 1; b() && i < 50; i++)
sum += val[i];
for (; i < 50; i++)
sum -= val[i];
}
```
The forward analysis assumed the second loop was entered, and we ended
up with false positive in it:
`Array 'val[50]' accessed at index 50, which is out of bounds`
* Fix style
2020-06-05 18:06:03 +02:00
Paul Fultz II
3109d16b42
Fix issue 9742: FP iterators3 for address of reference to vector in struct ( #2668 )
2020-06-01 08:53:08 +02:00
Paul Fultz II
eb4754b7d9
Fix issue 9587: False positive: parameter can be declared with const ( #2667 )
2020-05-31 10:10:10 +02:00
Sebastian
5cbed0464c
opencv2.cfg: Add types, macros, functions and memory (de)allocation ( #2620 )
...
* opencv2.cfg: Add types, macros, functions and memory (de)allocation
* cfg/cppcheck-cfg.rng: Allow alloc/realloc functions in classes
2020-05-30 17:41:44 +02:00
Paul Fultz II
eed2e829a7
Revert "Cleanup: Removed Tokenizer::simplifyTokenList2. As a side-effect, rules for "simple" token list are now executed on normal token list." ( #2666 )
...
This reverts commit 187cde183d
.
2020-05-30 11:23:22 +02:00
PKEuS
187cde183d
Cleanup: Removed Tokenizer::simplifyTokenList2. As a side-effect, rules for "simple" token list are now executed on normal token list.
2020-05-29 21:21:07 +02:00
PKEuS
bf69541369
Visual Studio: Use new files precompiled.h with several common includes for core and testrunner.
...
- CLI+Core: Reduces build time by 55% from 3:53 to 1:47
- Testrunner: Reduces build time by 27% from 1:40 to 1:13
2020-05-29 12:16:04 +02:00
Daniel Marjamäki
67115491ea
Fixed #9739 (Tokenizer: simplifyTypedef: wrong simplification in using)
2020-05-29 11:16:49 +02:00
Daniel Marjamäki
7ff692341e
Fixed #9730 (Regression: TEXT macro not handled in windows code)
2020-05-28 22:03:16 +02:00
miltolstoy
79c3af56e4
fix 9296: false negative uninit variable ( #2663 )
2020-05-28 21:28:18 +02:00
Daniel Marjamäki
d64631219b
Fixed #9741 (Wrong value for sizeof)
2020-05-28 21:24:48 +02:00
Paul Fultz II
c9798590ba
Fix issue 9701: False positive. 3rd expression in for uses comma operator. ( #2664 )
2020-05-28 07:41:47 +02:00
Daniel Marjamäki
f482eb49cd
ExprEngine; Fixed bug. Constraint expressions must be boolean
2020-05-27 19:37:07 +02:00
Oliver Stöneberg
3a90341961
some CMake cleanups and additions ( #2639 )
2020-05-27 05:15:46 +02:00
Oliver Stöneberg
4f68d85633
optimized non-matchcompiled Token::simpleMatch() a bit ( #2640 )
2020-05-26 20:13:56 +02:00
Daniel Marjamäki
9edca82138
Fix testrunner
2020-05-25 16:02:34 +02:00
Daniel Marjamäki
f7f26ffe90
Tokenizer: Better handling of c alternative tokens in const method
2020-05-25 15:07:23 +02:00
Paul Fultz II
bbe6157e16
Fix issue 9712: False positive: Returning pointer to local variable when return line implicitly cast to return type ( #2662 )
2020-05-23 23:12:00 +02:00
Ken-Patrick Lehrmann
084529575f
Skip ast validation inside template ( #2661 )
2020-05-23 21:11:08 +02:00
Daniel Marjamäki
5a4b309e6f
Bug hunting: Add 'buffer overflow' check. Detect CVE-2019-19334
2020-05-23 17:50:24 +02:00
Oliver Stöneberg
c1f762b861
disabled some Visual Studio warnings ( #2635 )
2020-05-23 17:42:56 +02:00
orbitcowboy
5142c9e9ed
wxwidgets.cfg: Fixed containerOutOfBounds-false negatives for wxArrayInt and wxArrayString. These containers have std::vector like implementation
2020-05-23 09:24:01 +02:00
Oliver Stöneberg
37bc0483a4
made check.h less heavy ( #2633 )
2020-05-23 07:16:49 +02:00
Paul Fultz II
0832830a95
Fix issue 9721: ValueFlow: Comparison is always false, but ValueFlow says it is always true ( #2658 )
2020-05-23 07:15:13 +02:00
Paul Fultz II
4270819728
Fix issue 9713: FP invalidContainerLoop when modifying container and immediately exiting the loop ( #2659 )
2020-05-23 07:14:45 +02:00
Paul Fultz II
6162ebd608
Fix issue 9714: FP invalidContainer related to auto and std::string::insert ( #2660 )
2020-05-23 07:13:55 +02:00
Paul Fultz II
526abd4b52
Fix issue 9738: ValueFlow: handle std::tie better ( #2657 )
2020-05-22 22:57:20 +02:00
Daniel Marjamäki
c86cfdaa50
Fixed #9736 (False positive: knownArgument in assert calls)
2020-05-22 11:49:28 +02:00
Daniel Marjamäki
43b58dbc9e
Fixed #9729 (AST: lambda with noexcept)
2020-05-22 11:29:10 +02:00
Daniel Marjamäki
ac1ceb85b6
AST: improved AST when expression starts with %char% or %str%
2020-05-22 09:35:55 +02:00
Daniel Marjamäki
81d8686f99
Changed TODO_ASSERT_EQUALS, we have a false negative
2020-05-21 09:12:19 +02:00
Paul Fultz II
8301fa8244
Fix issue 8144: valueFlowBeforeCondition: struct ( #2645 )
2020-05-21 08:47:48 +02:00
orbitcowboy
9861a5291e
Formatted the code, there are no functional changes [ci skip]
2020-05-20 23:45:00 +02:00
miltolstoy
a9d8b3495d
feat: add modulo of one check ( #9528 ) ( #2650 )
2020-05-20 23:01:32 +02:00
PKEuS
fb1afe2345
Fixed test suite: Do no longer apply simplifyTokenList2 to token lists, except for those tests that test those simplifications, because checks are no longer run on that simplified token list
...
Changed failing unit test to TODO tests, as they indicate patterns we do no longer understand properly.
2020-05-20 18:54:16 +02:00
Daniel Marjamäki
f5f7cb7ff7
test: Removed AstStyle::Verbose
2020-05-19 18:27:44 +02:00
shaneasd
44a3501f1b
cleanup after #9700 ( #2648 )
2020-05-19 18:15:05 +02:00
Daniel Marjamäki
32e569704b
executeCommand in CppCheckExecutor or QCheckThread
2020-05-19 16:04:40 +02:00
PKEuS
f6788c0472
Fixed Token::isKeyword: Actually set this flag to a reasonable value in all code paths
2020-05-19 13:47:25 +02:00
PKEuS
c9d8f607df
Optimization: Reduced peak memory usage (30% in my test case) by immediately deleting simplecpp::TokenList while creating the cppcheck TokenList.
2020-05-19 12:08:17 +02:00
PKEuS
4948f85460
Visual Studio: Updated solution
...
- Enable several compiler warnings again
- Let __cplusplus have a reasonable value
2020-05-19 08:35:13 +02:00
PKEuS
d6390dbd14
Optimization: Improved performance of simplifyTypedef for code with lots of typedefs
...
20% performance gain when checking ExtremeTuxRacer sourcecode (with glext.h available)
2020-05-19 08:35:13 +02:00
PKEuS
793ed68029
Refactorization: Moved code from header to source
...
- from utils.h to new utils.cpp
- from token.h to token.cpp
- from valueflow.h to valueflow.cpp
- from errorlogger.h to errorlogger.cpp
2020-05-19 08:35:12 +02:00
Daniel Marjamäki
330e634937
Revert "TestTrac: Add separate file for black box / integration tests in testrunner"
...
This reverts commit e895fa4c3f
.
2020-05-19 07:53:54 +02:00
Daniel Marjamäki
e895fa4c3f
TestTrac: Add separate file for black box / integration tests in testrunner
2020-05-18 20:22:00 +02:00
shaneasd
7bfd686f04
Fix #9700 duplicateBranch false positive from missing scope operator :: in ast ( #2646 )
2020-05-18 19:31:13 +02:00
Daniel Marjamäki
9eda399323
Less strict unknownMacro
2020-05-17 19:12:16 +02:00
Daniel Marjamäki
871cf379d5
ExprData: Better handling of ternary operator
2020-05-15 21:34:52 +02:00
Daniel Marjamäki
76f4fae806
Bug hunting; Started to activate some itc tests for uninitialized variables
2020-05-15 20:58:33 +02:00
Paul Fultz II
d123279fc1
Fix issue 9709: ValueFlow: variable value is not known ( #2643 )
2020-05-14 14:10:32 +02:00
Daniel Marjamäki
4afaff059b
Fix replacement in TestExprEngine
2020-05-13 09:56:21 +02:00