chrchr-github
81f9b9b2b7
Fix FP with ptr to ptr const ( #4050 )
2022-04-25 21:45:11 +02:00
chrchr-github
7721cd14b6
Fix #10466 FP constVariable with pointer typedef ( #4018 )
...
* Fix #10466 FP constVariable with pointer typedef
* Fix flag check
* Use isStatic()
2022-04-13 21:56:45 +02:00
chrchr-github
da1e2b22be
Add some tests ( #4014 )
...
* Test for #10454
* Test for #10493
* Test for #10069
* Test for #10228
* Fix test case
2022-04-13 12:25:53 +02:00
chrchr-github
4c375e7224
Fix #9815 FP redundantInitialization with lambda / #10864 debug: valueFlowConditionExpressions bailout ( #3970 )
...
* Fix #9815 FP redundantInitialization with lambda
* Fix #10864 debug: valueFlowConditionExpressions bailout
* Format
2022-04-05 23:19:17 +02:00
chrchr-github
aae810dd2c
Fix #10107 FP: duplicateValueTenary ( #3969 )
2022-04-04 06:33:54 +02:00
chrchr-github
7a7b3e40eb
Fix regression FN constVariable with static arrays ( #3965 )
...
* Fix regression FN constVariable with static arrays
* Fix test case
2022-04-02 20:39:45 +02:00
chrchr-github
a9f29fbc09
Fix #10307 FP functionStatic with class template and east-const / #10471 FP constParameter with std::array and east-const ( #3963 )
2022-04-01 23:26:44 +02:00
chrchr-github
47ba053054
Fix #10744 FP constVariable with static pointer ( #3957 )
2022-03-30 19:21:09 +02:00
chrchr-github
63d96e49fc
Fix #10928 , #10930 FP constStatement ( #3946 )
...
* Fix #10928 , #10930 FP constStatement
* Fix test cases (first one did not compile)
2022-03-27 07:59:29 +02:00
chrchr-github
5ed521622f
Fix #10923 FP constStatement with ptr to ptr to ptr ( #3944 )
...
* Fix #10923 FP constStatement with ptr to ptr to ptr
* simpleMatch
2022-03-26 06:12:26 +01:00
chrchr-github
796ad6c008
Fix #10913 FP variableScope - vector referenced via iterator ( #3936 )
2022-03-25 09:21:17 +01:00
chrchr-github
39567ea8c8
Fix #8541 FP variableScope (std::for_each with lambda) ( #3924 )
2022-03-22 21:50:46 +01:00
chrchr-github
0e147502cc
Fix #10888 FN variableScope with enum and struct ( #3920 )
...
* Fix #10888 FN variableScope with enum and struct
* Scope reduction
* Scope reduction
2022-03-21 16:05:38 +01:00
chrchr-github
297b0b5c60
Fix #10886 FP: Label 'enum' is not used. [unusedLabel] ( #3912 )
2022-03-17 17:38:23 +01:00
chrchr-github
f90a93591f
Add tests for #9871 , #10144 ( #3902 )
...
* Add test for #9871
* Add test for #10144
* Format
2022-03-15 12:54:19 +01:00
chrchr-github
f53793c413
Fix #10823 FP cstyleCast with function pointer and calling convention ( #3853 )
2022-02-23 09:12:14 +01:00
chrchr-github
18e00bb4fd
Fix #10817 Crash in checkPassByReference() / #10810 Stack overflow with decltype / #10763 Crash on invalid code ( #3840 )
...
* Fix #10817 Crash in checkPassByReference()
* Format
* Fix #10810 Stack overflow with decltype
* Fix #10763 Crash on invalid code in TemplateSimplifier::templateParameters
2022-02-18 12:59:21 +01:00
Daniel Marjamäki
f2420509c9
Revert "constPointer: Fix false positives when pointer is not read"
...
This reverts commit 6427b4888b
.
If variable/parameter is unused it is better to warn about that.
2022-02-13 08:40:45 +01:00
Daniel Marjamäki
6427b4888b
constPointer: Fix false positives when pointer is not read
2022-02-12 22:23:25 +01:00
chrchr-github
c5ab936088
Fix #10405 FN shadowVariable in range-based for loop ( #3789 )
2022-02-12 08:10:53 +01:00
chrchr-github
5f3ddabd56
Fix FP constParameter with std::map ( #3823 )
2022-02-11 19:40:11 +01:00
Oliver Stöneberg
f32583e097
removed OVERRIDE and FINAL defines and use the keywords directly ( #3767 )
2022-02-10 23:02:24 +01:00
Julien Marrec
2535bf984b
Allow passing std::string_view by value ( #3817 )
2022-02-10 21:01:12 +01:00
chrchr-github
cd7532df21
Fix #7709 FN C-style pointer casting with built-in or typedef types /… ( #3814 )
2022-02-10 20:48:51 +01:00
chrchr-github
ddd84f9b98
Add tests/TODO for #7950 , #9974 ( #3818 )
...
* Add tests/TODO for #7950 , #9974
* Comment
2022-02-10 20:05:14 +01:00
chrchr-github
e64ea20089
Fix #10527 FP variableScope for if with init-statement ( #3811 )
2022-02-08 16:12:09 +01:00
Paul Fultz II
260d155bb6
Fix 10785: False positive: constParameter when using member pointer ( #3807 )
2022-02-07 18:45:32 +01:00
Daniel Marjamäki
3989408738
Update copyright year
2022-02-05 11:45:17 +01:00
chrchr-github
511520d623
Fix #10679 FP constParameter with const/nonconst overload ( #3780 )
2022-02-02 19:38:32 +01:00
chrchr-github
dad64bfcc8
Fix #10091 FP shadowFunction with default destructor implementation / Tests for #8635 , #9776 , #9940 , #9951 , #10018 ( #3763 )
2022-02-02 19:30:49 +01:00
chrchr-github
0807924d32
Fix FP passedByValue for unions / FN passedByValue for array members ( #3784 )
2022-02-01 17:17:08 +01:00
Daniel Marjamäki
637aca8d59
Fixed #10752 (False positive: shadow variable in static method)
2022-01-28 16:03:06 +01:00
Oliver Stöneberg
171da2e6f9
avoid dependency on transitive includes - based on include-what-you-use ( #3757 )
2022-01-27 19:03:20 +01:00
chrchr-github
158f3d494e
Fix #10143 false positive: redundantInitialization with std::shared_ptr ( #3746 )
2022-01-24 21:50:50 +01:00
chrchr-github
b491fcc489
Add test cases for #9850 , #9910 ( #3747 )
2022-01-24 15:06:40 +01:00
chrchr-github
7f9ef8c321
Add test cases for #7899 , #7974 , #9256 ( #3726 )
...
* Add test case for #7899 and #7974
* Add test case for ##9256
2022-01-20 16:15:38 +01:00
chrchr-github
089ca67d78
Use TODO_ASSERT ( #3704 )
2022-01-18 22:03:52 +01:00
orbitcowboy
b6c010c17e
Added regression test for Ticket 7981.
2022-01-18 13:09:02 +01:00
Paul Fultz II
89bc226738
Fix 10718: Crash in CheckOther::checkDuplicateExpression ( #3713 )
2022-01-16 12:34:20 +01:00
chrchr-github
fe077fc141
Add test for #10312 ( #3673 )
2022-01-04 20:50:00 +01:00
Paul Fultz II
01a8890d6d
Fix 9760: False positive: constParameter on parameter used to take non-const pointer via array decaying ( #3660 )
2022-01-02 08:15:38 +01:00
chrchr-github
922e27de4c
Fix #7754 FP Same expression on both sides of '||' ( #3635 )
2021-12-31 08:24:05 +01:00
chrchr-github
f64097465f
Fix #9342 FP oppositeExpression - negated value is not opposite for bitwise logical operators ( #3615 )
2021-12-10 18:06:45 +01:00
chrchr-github
33c55f77a8
Fix #9570 ( #3608 )
2021-12-07 07:44:07 +01:00
chrchr-github
ca311ebcdf
ASSERT() on calls to Tokenizer::tokenize() in test code ( #3501 )
2021-11-29 07:34:39 +01:00
Rikard Falkeborn
085d25f1b1
SymbolDatabase: Fix valuetype with constexpr and auto ( #3577 )
2021-11-24 16:51:40 +01:00
chrchr-github
a6b8339990
Add test for #10607 ( #3576 )
...
* Add test for #10607
* Format
2021-11-24 14:42:19 +01:00
Daniel Marjamäki
c7ef602cd6
Fixed #9759 (False positive: constParameter on parameter used by non-const call via pointer to member function)
2021-11-21 20:03:38 +01:00
Daniel Marjamäki
921f5c1818
Fixed #10547 (False positive: constVariable, buffer written by stream read)
2021-10-18 19:38:53 +02:00
Paul Fultz II
fc6a791a74
Fix 9766: False positive; suspicious operator is written in declaration ( #3476 )
2021-10-03 09:59:51 +02:00
Daniel Marjamäki
6234e9ddda
Fixed #10483 (FP constParameter with array member and memcpy)
2021-09-15 21:25:16 +02:00
Daniel Marjamäki
6f4ce486a2
Fix FP in constVariable
2021-09-11 20:25:46 +02:00
Daniel Marjamäki
e95395e5f0
Fixed #10397 (FP constParameter - implementing an interface)
2021-08-10 15:37:59 +02:00
Paul Fultz II
7f358b2bed
Format with uncrustify ( #3388 )
2021-08-07 20:51:18 +02:00
chrchr-github
edd86c0b0a
Add regression test for ticket #10374 ( #3386 )
2021-08-06 09:41:26 +02:00
Paul Fultz II
8b8ae55490
Fix 10129: false negative: knownConditionTrueFalse ( #3382 )
...
* Add symbolic matching
* Check for truncated values
* Dont propagate uninit values
* Update errorpath test
* Add test case for 10129
* Add test case for FP
* Remove symbolic values that are the same as the token
* Fix test messages
* Fix cppcheck issue
* Format
2021-08-04 21:07:31 +02:00
Daniel Marjamäki
1ec7397c21
astyle formatting
...
[ci skip]
2021-08-01 14:05:30 +02:00
chrchr-github
9d51b4450b
Add test cases for tickets #9976 and #10371 ( #3364 )
2021-07-27 22:26:19 +02:00
Paul Fultz II
41c94b656a
Fix FP const pointer with class variable and add more tests ( #3345 )
2021-07-21 07:36:13 +02:00
Daniel Marjamäki
fb5ab5e439
constPointer; Improved checking dereferenced pointer is used in calculation/comparison
2021-07-20 10:38:38 +02:00
Daniel Marjamäki
4d23c02320
constPointer; Improved checking when pointer is not dereferenced
2021-07-20 10:28:35 +02:00
Daniel Marjamäki
eb9a251a4c
const variables/parameters; Improved check to handle pointers also (misra 8.13)
2021-07-18 10:59:52 +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
3e7b6f262d
std.cfg: Added not-overlapping-data configuration to wmemcpy()
2021-07-08 17:12:53 +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
1783fd1bba
duplicateBreak; Allow extra return that clarifies for tool(s) that function does not continue
2021-06-29 11:17:12 +02:00
orbitcowboy
df6b0bcd87
#10026 : Added a regression test for 'false negative: duplicateExpression'
2021-05-24 08:54:45 +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
a197e94573
Fixed #10266 (False positive; parameter can be const)
2021-05-08 13:40:52 +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
cf8a423636
Unreachable code; better handling of throw in C code
2021-04-05 04:53:07 +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
42437277dc
Update Copyright year
2021-03-21 20:58:32 +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
PKEuS
cf1937294a
Refactorization: Removed unnecessary \n and spaces in strings
...
Merged from LCppC.
2021-02-20 12:58:42 +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
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
Oliver Stöneberg
ac7647fcd8
some self-check suppression cleanups ( #3032 )
2021-01-09 20:32:38 +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
bcf6039558
Fixed #10058 (False positive: redundant assignment, there is break)
2020-12-25 09:08:15 +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
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
2cd8ea83a7
Fixed #9860 (unused template not removed properly by default)
2020-11-22 16:43:36 +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
Daniel Marjamäki
6236beeb3f
Fixed #9950 (Wrong severity for redundantAssignInSwitch)
2020-11-15 13:09:28 +01:00
shaneasd
a623168942
fix passedByValueError on enums ( #2869 )
2020-10-30 18:32:35 +01:00
Daniel Marjamäki
f1ce5a9101
Fixed #9929 (False positive: suspicious semicolon after macro)
2020-10-09 20:34:20 +02:00
Daniel Marjamäki
c3517924d0
Clang import testing: Compare AST
2020-10-04 11:27:31 +02:00
Daniel Marjamäki
fe2717fa37
Fixed testrunner
2020-09-29 17:43:53 +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
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
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
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
Daniel Marjamäki
107ee57e7a
Fixed #9909 (False positive: knownArgument for calculation 'self->maxsize * sizeof(intptr_t)')
2020-09-21 20:02:55 +02:00
Daniel Marjamäki
730b95331e
Fixed #9905 (False positive: known argument 'header.length()')
2020-09-20 20:17:10 +02: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
bfe53fce04
Fix issue 9878: false positive: multiCondition ( #2787 )
2020-09-09 15:39:36 +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
Daniel Marjamäki
1daf1ec108
Fixed #9875 (Crash)
2020-09-04 19:15:48 +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
Paul Fultz II
3e99bff764
Same expression when comparing with zero ( #2762 )
2020-08-31 08:48:48 +02:00
Paul Fultz II
02287d9d34
Fix issue 7324: valueFlowForward : decrement ( #2737 )
2020-08-24 13:10:36 +02:00
Daniel Marjamäki
5372e93964
Fixed #9825 (redundantAssignment: Do not warn about volatile data)
2020-08-06 22:18:25 +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
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
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
Paul
cf475fab51
Fix issue 9778: False positive: constParameter when returning non-const reference cast
2020-06-26 15:47:59 -05:00
Paul
1676ad5f45
Fix issue 9710 and 9767: Use AST to get function from argument
2020-06-25 12:54:46 -05: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
Paul Fultz II
eb4754b7d9
Fix issue 9587: False positive: parameter can be declared with const ( #2667 )
2020-05-31 10:10:10 +02:00
Daniel Marjamäki
c86cfdaa50
Fixed #9736 (False positive: knownArgument in assert calls)
2020-05-22 11:49:28 +02:00
miltolstoy
a9d8b3495d
feat: add modulo of one check ( #9528 ) ( #2650 )
2020-05-20 23:01:32 +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
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
08ddd84780
Update copyright year
2020-05-10 11:16:32 +02:00
Daniel Marjamäki
3e0218299b
Revert "Update copyright year"
...
This reverts commit 6eec6c4bd5
.
2020-05-10 11:13:05 +02:00
Daniel Marjamäki
6eec6c4bd5
Update copyright year
2020-05-10 11:11:34 +02:00
Daniel Marjamäki
da6e0308c5
Fixed #9195 (False positive: shadowFunction when constructor is shadowed)
2020-04-20 18:02:10 +02:00
Daniel Marjamäki
54978847c5
Fixed #8916 (FP: followVar does not seem to handle non-const method call properly)
2020-04-18 19:54:55 +02:00
Daniel Marjamäki
5376ba1701
AST: Throw validation exception if ternary operator is missing operands
2020-03-07 21:46:38 +01:00
amai2012
b795d30db6
Enable another zeroDivCond test which got fixed recently
2020-03-06 17:15:54 +01:00
Rikard Falkeborn
f6e7fb4bd9
Bugfix valuetype for some integer constants ( #2545 )
2020-02-19 07:51:39 +01:00
Daniel Marjamäki
320cb9008f
minor tweaks of knownConditionTrueFalse
2020-02-15 20:21:13 +01:00
Rikard Falkeborn
b1c6f2946a
Fix redundant FP assignment with unsigned zero ( #2521 )
...
* Refactor isNullOperand out of FwdAnalysis
* Improve isNullOperand
* Fix redundantAssignment FP with unsigned zero
* isNullValue check number
* Enhance isNullOperand to handle c++ casts
Also handle cast of NULL.
2020-02-09 11:16:08 +01:00
Daniel Marjamäki
e78775fac3
astyle formatting
...
[ci skip]
2020-01-10 11:31:12 +01:00
Rikard Falkeborn
9afeef01c6
Improve duplicateExpressionTernary ( #2484 )
...
Test both the cases where sizeof(int) == sizeof(long) and when they are
different to improve testing.
2020-01-10 10:02:50 +01:00
Ken-Patrick Lehrmann
eca7ee9260
9356: Prevent false positive when passing non-const reference to member constructor ( #2370 )
...
* Add cases for 9356
* 9356: Prevent false positive when passing non-const reference to member constructor
This workarounds false positives 'Parameter can be declared with const [constParameter]'
when said parameter is used in constructor call. It assume the
constructor call might change the parameter (without any checks.
The drawback is that we have false negative, in cases where we could
check the constructor actually takes a const reference, or a copied by
value parameter.
* Add todo comment in isVariableMutableInInitializer
2020-01-04 11:36:45 +01:00
Daniel Marjamäki
235ef0a01e
Fixed #9420 (False positive - redundantInitialization)
2019-12-18 19:39:23 +01:00
Daniel Marjamäki
bcfc5924fa
Fixed #9532 (False positive: Out of bounds access in expression 'v[0]' because 'v' is empty.)
2019-12-14 19:04:19 +01:00
Paul Fultz II
06752d75a5
Fix issue 9485: knownConditionTrueFalse false positive with integer constants ( #2447 )
...
* Fix issue 9485: knownConditionTrueFalse false positive with integer constants
* Formatting
2019-12-14 09:15:00 +01:00
Dmitry-Me
064795a705
Remove duplicate test
...
This partially reverts commit 047418dda1
2019-12-11 19:17:59 +03:00
amai2012
f5df06a143
Run astyle [ci skip]
2019-12-08 11:22:19 +01:00
Dmitry-Me
047418dda1
Improve test coverage for redundant bitwise operations
2019-12-06 19:14:03 +03:00
Paul Fultz II
ed1acc319d
Fixx issue 9355: FP constParameter when returning non-const reference to struct member ( #2373 )
2019-11-18 06:39:50 +01:00
Rikard Falkeborn
38dea4719b
Fix #9166 (print proper types in invalidCast message) ( #2347 )
...
* Fix #9166 (print proper types in invalidCast message)
* Use ValueType->str()
* astyle
* Set default sign to avoid issues on different platforms
2019-11-11 07:17:50 +01:00
Dmitry-Me
0b97f37736
Improve test coverage
2019-11-01 18:41:10 +03:00
Daniel Marjamäki
68ea60d207
Try to make Travis happy
2019-10-20 07:44:56 +02:00
Daniel Marjamäki
00fae7fb42
Fixed #9261 (Inconsistent violation report between using global enum and namespaced enum.)
2019-10-20 07:07:38 +02:00
Daniel Marjamäki
4943771e41
Fix #9262 (False positive on variable assignment when putting enum in namespace)
2019-10-19 21:41:50 +02:00
Daniel Marjamäki
99ef64459b
Fixed #9344 (FP redundantAssignment related to increasing index variable for vector)
2019-10-17 18:31:05 +02:00
Steve Mokris
506a952ad2
Parse `extern "C"`, and use it to avoid FP reference warnings ( #2234 )
...
Previously, cppcheck discarded the `extern "C"` specifier. This patch modifies cppcheck to parse each as a Scope in the symbol database, then uses that scope to avoid false positives when making recommendations about changing a function argument to be a reference (since variable references is a C++ feature, unavailable in C, and thus unavailable in `extern "C"`).
2019-10-08 17:48:09 +02:00
Oliver Stöneberg
eac040a00b
Various clang-tidy fixes ( #2192 )
...
* use range loops
* removed redundant string initializations
* use nullptr
* use proper boolean false
* removed unnecessary continue from end of loop
* removed unnecessary c_str() usage
* use emplace_back()
* removed redundant void arguments
2019-09-25 15:25:19 +02:00
Paul Fultz II
ad8abdb0c3
Add impossible values to ValueFlow ( #2186 )
...
* Add impossible category
* Replace values
* Try to adjust known values
* Add ! for impossible values
* Add impossible with possible values
* Remove contradictions
* Add values when the branch is not dead
* Only copy possible values
* Dont bail on while loops
* Load std lib in valueflow
* Check for function calls
* Fix stl errors
* Fix incorrect impossible check
* Fix heap-after-use error
* Remove impossible values when they are lowered
* Show the bound and remove overlaps
* Infer conditions
* Dont push pointer values through dynamic_cast
* Add test for dynamic_cast issue
* Add shifttoomanybits test
* Add test for div by zero
* Add a test for issue 9315
* Dont make impossible value inconclusive
* Fix FP with shift operator
* Improve handleKnownValuesInLoop for impossible values
* Fix cppcheck warning
* Fix impossible values for ctu
* Bailout for streams
* Check equality conditions
* Fix overflows
* Add regression test for 9332
* Remove duplicate conditions
* Skip impossible values for invalid value
* Check for null
* Rename bound to range
* Formatting
2019-09-20 15:06:37 +02:00
Paul Fultz II
068b0b246c
Fix issue 9352: FP constParameter and constVariable for auto& in combination with ternary ?: operator ( #2173 )
2019-09-13 08:33:30 +02:00
Paul Fultz II
e657cf4073
Fix issue 9320: False positive knownConditionTrueFalse related to truncation ( #2144 )
2019-09-05 15:15:58 +02:00
Daniel Marjamäki
a9fda3f488
Clarify redundantVarAssignment warnings
2019-09-04 10:55:41 +02:00
Daniel Marjamäki
4bd9d76a4c
Try to make Travis happy
2019-08-25 10:24:13 +02:00
Daniel Marjamäki
82eec11898
Created redundantInitialization id
2019-08-25 09:45:39 +02:00
Daniel Marjamäki
324e5e581b
Redundant assignments: Fix false positive when reassignment expression contains assembler
2019-08-24 20:15:52 +02:00
Daniel Marjamäki
7061cc334b
RedundantAssignment: Don't warn for initialization with {0}
2019-08-23 08:51:16 +02:00
Paul Fultz II
aaeec462e6
Re-enable valueFlowSubFunction ( #2063 )
...
* Re-enable valueFlowSubFunction
* Formatting
* Skip ternary operators in subfunctions
* Fix test with iostreams
* Fix FP with multiple parameters
2019-08-05 16:26:32 +02:00
Paul Fultz II
744a94ad5a
Fix issue 9231: FP constParameter - argument passed parent ctor ( #2032 )
2019-07-24 20:59:58 +02:00
Paul Fultz II
bb52a63c4e
Add check for const variables
...
When a local reference is declared, this will check if that local reference can be declared as `const`.
2019-07-24 09:59:01 +02:00
Daniel Marjamäki
d11d6f112e
Detect shadowed arguments
2019-07-17 17:08:42 +02:00
Daniel Marjamäki
cf06acae08
Fixed #5995 (False negative selfAssignment regression from 1.65)
2019-07-13 21:45:54 +02:00
Paul Fultz II
8f4cb36e1e
Check for more garbage code ( #1949 )
...
* Check for garbage commas
* Find garbage dot operator
2019-07-03 08:28:24 +02:00
Scott Furry
a195477470
Correct Zero/Null as pointer constant ( #1938 )
...
Building with enhanced clang warnings indicated a large number of
instances with the warning:
`warning: zero as null pointer constant`
Recommended practice in C++11 is to use `nullptr` as value for
a NULL or empty pointer value. All instances where this warning
was encountered were corrected in this commit.
Where warning was encountered in dependency code (i.e. external library)
no chnages were made. Patching will be offered upstream.
2019-06-30 21:39:22 +02:00
Daniel Marjamäki
7ceb51a952
Try to improve 'clarifyStatement' warning message
2019-06-22 08:44:41 +02:00
Daniel Marjamäki
16bed07c60
Clarify tests
2019-06-22 07:50:43 +02:00
Daniel Marjamäki
5d10b57b04
Fixed #8997 (False positive redundantAssignment when pointer is updated with +=)
2019-05-31 12:24:31 +02:00
Paul Fultz II
9838bfa79f
Fix false positive in constArgument when passing struct member ( #1845 )
2019-05-21 10:41:16 +02:00
Daniel Marjamäki
57c6628732
Revert 'Cleaning up unsimplified templates'. This fix caused problems.
2019-05-16 21:11:04 +02:00
Daniel Marjamäki
4d9b1e6c3d
Fixed #9094 (Tokenizer::createLinks2 problem with 'x%x<--a==x>x')
2019-05-11 19:11:40 +02:00
Daniel Marjamäki
d58d4273f9
Cleaning up unsimplified templates
2019-05-11 13:00:03 +02:00
Daniel Marjamäki
253f2c9e9d
Fixed #9043 (false positive & regression: Variable '*s' is reassigned a value before the old one has been used.)
2019-04-16 19:07:26 +02:00
Daniel Marjamäki
773d19b2d6
Fix compiler errors. After removing the -std=posix.
2019-04-12 10:41:53 +02:00
Daniel Marjamäki
3f9dd4c567
Variable scope: Fix FP for reference variable in range for loop
2019-04-02 12:59:24 +02:00
IOBYTE
5b72e1f568
Fixed #9040 (Type alias 'BOOL' declared with 'using' keyword breaks type detection) ( #1759 )
...
Moved simplifyUsing from TemplateSimplifier to Tokenizer.
2019-03-26 07:09:56 +01:00
Daniel Marjamäki
418eb43d45
Fixed #9032 (False-positive detection of reassigned value before used for pointer parameter)
2019-03-23 19:01:02 +01:00
Daniel Marjamäki
3dc34f1515
Disable all simplified checks
2019-03-16 09:17:50 +01:00
Rikard Falkeborn
a4269042e8
Add regression test for #8994 ( #1733 )
...
Trac ticket #8994 was fixed in b222953bae
.
Add a regression test to ensure it stays fixed.
2019-03-11 06:14:37 +01:00
Daniel Marjamäki
f9a12b2a71
Fix small mistake in unit test
2019-03-07 06:38:58 +01:00
Daniel Marjamäki
6eaf2c03d9
CheckOther::checkInvalidFree: Move check to normal checking. And clarify the message.
2019-03-07 06:35:44 +01:00
Daniel Marjamäki
f20936ed8a
Moved CheckOther::checkPassByReference to normal checking
2019-03-06 20:59:45 +01:00
Paul Fultz II
e846312fed
Check subtraction of pointers to different objects
2019-02-27 06:55:48 +01:00
Daniel Marjamäki
68062e3702
Fixed #8954 (false positive: Local variable x shadows outer variable)
2019-02-23 16:22:22 +01:00
Paul Fultz II
fd3c1fd040
Fix issue 1777: Undefined Behavior: Comparing pointers to different objects
...
This uses the lifetime analysis to check when comparing pointer that point to different objects:
```cpp
int main(void)
{
int foo[10];
int bar[10];
int diff;
if(foo > bar) // Undefined Behavior
{
diff = 1;
}
return 0;
}
```
2019-02-23 08:32:08 +01:00
Paul Fultz II
941dd79f0d
Fix FP issue 8986: constArgument check warns for elements of const array ( #1683 )
2019-02-22 06:39:59 +01:00
Paul Fultz II
cf1ad5087a
Extend constStatement checker
...
This reworks constStatement to find more issues. It catches issue [8827](https://trac.cppcheck.net/ticket/8827 ):
```cpp
extern void foo(int,const char*,int);
void f(int value)
{
foo(42,"test",42),(value&42);
}
```
It also catches from issue [8451](https://trac.cppcheck.net/ticket/8451 ):
```cpp
void f1(int x) {
1;
(1);
(char)1;
((char)1);
!x;
(!x);
~x;
}
```
And also:
```cpp
void f(int x) {
x;
}
```
The other examples are not caught due to incomplete AST.
2019-02-15 13:31:40 +01:00
rikardfalkeborn
dc4e7cef88
Run simplifyPlatformTypes on library return types ( #1672 )
...
Add a call to simplifyPlatformTypes() in
SymbolDatabase::setValueTypeInTokenList() to simplify return types of
library configured functions. This fixes the FN in #8141 . Regression
tests are added, both for the original issue and another FN in the comments.
In order to do that, move simplifyPlatformTypes() to TokenList from Tokenizer.
This is a pure refactoring and does not change any behaviour. The code was
literally copy-pasted from one file to another and in two places
'list.front()' was changed to 'front()'.
When adding the call to simplifyPlatformTypes(), the original type of
v.size() where v is a container is changed from 'size_t' to 'std::size_t'.
Tests are updated accordingly. It can be noted that if v is declared as
'class fred : public std::vector<int> {} v', the original type of 'v.size()'
is still 'size_t' and not 'std::size_t'.
2019-02-15 13:29:52 +01:00
Daniel Marjamäki
bd7790fd8c
Update copyright year
2019-02-09 07:24:06 +01:00
Paul Fultz II
d7c20b15e7
Fix FP with const argument when doing a variable and cast ( #1649 )
2019-02-07 14:59:09 +01:00
rikardfalkeborn
91de606243
TestOther: Shorter test cases ( #1637 )
...
* Remove newlines after check(
* Remove unneeded statements after if-statements
As an example, the previous test case
check(
"bool foo(int x) {\n"
" if (x < 0)"
" return true;\n"
" return false;\n"
"}");
is changed to
check("void foo(int x) {\n"
" if (x < 0) {}\n"
"}");
2019-01-31 23:57:05 +01:00
rikardfalkeborn
7779a9186e
Use valueflow in unsigned less than zero checker ( #1630 )
...
The unsigned less than zero checker looked for patterns like "<= 0".
Switching to use valueflow improves the checker in a few aspects.
First, it removes false positives where instead of 0, the code is using
0L, 0U, etc. Instead of having to hard code the different variants of 0,
valueflow handles this automatically. This fixes FPs on the form
uint32_t value = 0xFUL;
void f() {
if (value < 0u)
{
value = 0u;
}
}
where 0u was previously not recognized by the checker. This fixes #8836 .
Morover, it makes it possible to handle templates properly. In commit
fa076598ad
, all warnings inside templates
were made inconclusive, since the checker had no idea if "0" came from
a template parameter or not.
This makes it possible to not warn for the following case which was
reported as a FP in #3233
template<int n> void foo(unsigned int x) {
if (x <= n);
}
foo<0>();
but give a warning for the following case
template<int n> void foo(unsigned int x) {
if (x <= 0);
}
Previously, both these cases gave inconclusive warnings.
Finally, it makes it possible to give warnings for the following code:
void f(unsigned x) {
int y = 0;
if (x <= y) {}
}
Also, previously, the checker for unsigned variables larger than 0, the
checker used the string of the astoperand. This meant that for code like
the following:
void f(unsigned x, unsigned y) {
if (x -y >= 0) {}
}
cppcheck would output
[unsigned-expression-positive.c] (style) Unsigned variable '-' can't be negative so it is unnecessary to test it.
using expressionString() instead gives a better error message
[unsigned-expression-positive.c] (style) Unsigned expression 'x-z' can't be negative so it is unnecessary to test it.
2019-01-31 09:30:29 +01:00
rikardfalkeborn
080c9d53af
8205 regression test ( #1618 )
...
* Fix trac ticket reference
* Add regression test for #8205
Ticket #8205 was fixed in f65cf220ba
.
Add a test case to avoid regressions.
2019-01-24 07:20:26 +01:00
rikardfalkeborn
8356ec6774
Add regression test for #6906 and #7284 ( #1614 )
...
* Add regression test for #6906
Ticket #6906 was fixed in f65cf220ba
.
Add a test to make sure there are no regressions.
* Add regression test for #7284
Ticket #7284 was fixed in 5d1fdf7958
.
Add tests to avoid regressions.
2019-01-23 09:09:03 +01:00
Daniel Marjamäki
8dd641b8be
Use OVERRIDE in test
2019-01-12 15:45:25 +01:00