Commit Graph

629 Commits

Author SHA1 Message Date
Daniel Marjamäki 9d4e3829c2
Partial fix (False positive: uninitialized variable, conditional modification, flag) () 2023-10-12 13:56:47 +02:00
Oliver Stöneberg a22c181553
fixed "Redundant elaborated type specifier" Rider warnings () 2023-10-08 09:10:17 +02:00
Oliver Stöneberg fe8730cf0f
MathLib: renamed `to{U}LongNumber()` to `toBig{U}Number()` ()
The name was misleading as it was actually a `long long` and also if we
ever move to an (optional) 128-bit value it wouldn't even less fitting.
We should name it to match our alias type.
2023-10-05 19:21:42 +02:00
Daniel Marjamäki 276f017fbe
Partial fix for (Safety: show what checks are enabled/disabled) ()
Example output on stdout:
```
$ ./cppcheck m1.cpp 
Checking m1.cpp ...
Active checkers: 59/177
```
2023-08-29 12:00:52 +02:00
chrchr-github 8cd61941dc
Unified checks for unevaluated context () 2023-08-23 12:07:47 +02:00
Paul Fultz II 52081ef08f
Add special function to match lifetimes ()
This also removes the termination checking in `valueFlowUninit` as this
causes a lot of FNs.
2023-08-14 10:27:00 +02:00
chrchr-github d4d77edeae
Fix FP uninitStructMember / cleanup from () 2023-08-12 23:46:31 +02:00
chrchr-github a7d487f6db
Fix FP uninitvar for stringstream into deref pointer to uninit var / FP uninitvar for array in struct in struct () 2023-08-11 18:45:58 +02:00
chrchr-github 72212331fb
Fix False positive: uninitialized variable '*(&var) = 0' () 2023-07-14 19:14:33 +02:00
chrchr-github 4eebf2e733
Fix uninitdata regression () 2023-06-21 21:19:22 +02:00
chrchr-github bb962e2bc3
Enable and mitigate readability-else-after-return () 2023-06-20 18:43:21 +02:00
chrchr-github f96e3c9d84
Fix FP uninitdata with cast () 2023-06-20 18:06:57 +02:00
Daniel Marjamäki 9a290c959f
Fix (False positive: uninitialized variable, struct array member initialized in function) () 2023-06-17 10:20:20 +02:00
Daniel Marjamäki f6a65afdee
Fix FP uninitStructMember when other variable is only nonzero if struct member is initialized () 2023-06-10 21:35:17 +02:00
chrchr-github 7696bd1357
Fix FN constParameter with cast ()
* Fix  FN constParameter with cast

* Add const
2023-05-31 16:51:03 +02:00
chrchr-github ec2f00d7c2
Fix uninitialized data: casted to 'int *' and dereferenced () 2023-05-29 15:29:53 +02:00
chrchr-github 10b55cc0cf
Fix FN functionConst if only non-const member usage is call to itself ()
* Fix  FN functionConst if only non-const member usage is call to itself

* Format

* Add const
2023-05-26 17:24:13 +02:00
Anton Lindqvist 3d6c453058
Fix uninitvar false positive in designed initializers ()
Stop interpreting struct fields in designed initializers as usage of local
variables which can happen if they share the same name.

```
$ cat test.c
struct a { int b; };
int main() {
  char *b;
  extern int foo(struct a *);
  return foo(&(struct a){.b = 0});
}
$ cppcheck --quiet test.c
test.c:5:27: error: Uninitialized variable: b [legacyUninitvar]
  return foo(&(struct a){.b = 0});
```
2023-05-26 11:59:10 +02:00
chrchr-github 096d3a78b0
Fix FN uninitdata with value initialization ()
* Assign values to pointers with C++11 init

* Handle assigning empty init list

* Fix  FN uninitdata with value initialization

* Fix test
2023-05-13 22:07:09 +02:00
chrchr-github 3ccd0505cd
Enable and mitigate readability-simplify-boolean-expr () 2023-03-17 13:51:55 +01:00
Paul Fultz II 61e8b84578
Fix 11610: false negative: knownConditionTrueFalse with address of variable () 2023-03-12 19:57:11 +01:00
Oliver Stöneberg e2f38fdaf3
removed `experimental` and `safe` from `Certainty` () 2023-03-12 14:15:29 +01:00
chrchr-github b4c90f8b2a
Fix FP uninitvar with nested enum () 2023-03-04 11:57:12 +01:00
Daniel Marjamäki 464fbe8d53 Update copyright year 2023-01-28 10:16:34 +01:00
Oliver Stöneberg bea6aec2b2
extracted `ValueFlow::Value` to `vfvalue.{cpp|h}` () 2023-01-26 22:23:22 +01:00
Oliver Stöneberg a09667a6d9
removed unused error messages () 2023-01-07 10:35:39 +01:00
Oliver Stöneberg 1cfe49e340
use `const_iterator` where possible () 2022-12-30 15:13:47 +01:00
Oliver Stöneberg 6fedbb4f77
add/preserve `const` in `dynamic_cast` () 2022-12-19 20:01:12 +01:00
Oliver Stöneberg cff1cd9cda
applied clang-tidy `misc-const-correctness` fixes for POD types, iterators and references ()
* applied `misc-const-correctness` fixes for POD types and iterators

* applied `misc-const-correctness` fixes for references
2022-10-02 07:12:40 +02:00
Oliver Stöneberg dc03a50414
some small cleanups and refactorings ()
* moved `plistFile` from `ErrorLogger` to `CppCheck`

* got rid of global CWE objects

* lib/CMakeLists.txt: suppress some `-Wfloat-equal` clang warning in matchcompiled builds as well

* lib/CMakeLists.txt: moved a loop into proper block

* test/CMakeLists.txt: simplified `add_fixture`

* test/CMakeLists.txt: moved `fixture_cost`

* fixed `naming-privateMemberVariable` selfcheck warning
2022-09-24 11:59:13 +02:00
Oliver Stöneberg 339484d2a1
mitigated and enabled more clang-tidy warnings ()
* fixed some `performance-inefficient-string-concatenation` clang-tidy warnings

* fixed and enabled `modernize-replace-random-shuffle` clang-tidy warning

* fixed and enabled `bugprone-suspicious-string-compare` clang-tidy warning

* mitigated and enabled `readability-non-const-parameter` clang-tidy warnings

* clang-tidy.md: documented some disabled checks

* mitigated and enabled `performance-unnecessary-value-param` clang-tidy warnings
2022-09-16 18:58:59 +02:00
Paul Fultz II 43caa32abf
Fix 9755: false negative: access of moved variable in conditional code ()
* Fix 9755: false negative: access of moved variable in conditional code

* Format
2022-09-11 12:32:01 +02:00
PKEuS d81a758850
LCppC backports: Refactorizations/Optimizations () 2022-08-21 17:21:02 +02:00
Oliver Stöneberg c9c1f83a69
use `emptyString` more consistently () 2022-07-10 10:57:29 +02:00
Paul Fultz II 185294499c
Adjust the severity of the uninitvar () 2022-06-28 22:52:35 +02:00
Paul Fultz II 3e3abecba0
Rename old uninitvar ID to use legacyUninitvar () 2022-04-27 17:37:37 +02:00
chrchr-github 1bc0317719
Fix FP uninitStructMember with extra parentheses () 2022-04-25 22:22:35 +02:00
Paul Fultz II 6b9ac6f7a8
Warn when incrementing uninitialized value ()
* Warn when incrementing uninitialized value

* Format
2022-04-24 09:56:58 +02:00
Paul Fultz II 3feecc51d6
Fix 10988: FP: Regression, uninitvar () 2022-04-21 19:29:38 +02:00
Paul Fultz II d97942d3c6
Fix 6577: Detect pointer to uninitialised memory with clock_settime() ()
* Fix 6577: Detect pointer to uninitialised memory with clock_settime()

* Format
2022-04-11 07:23:44 +02:00
Paul Fultz II 4b4037540a
valueFlowUninit: Handle arrays and pod types ()
* valueFlowUninit: Handle arrays and pod types

* Format

* Catch another array case
2022-03-24 06:35:44 +01:00
chrchr-github 1aff160411
Fix FP uninitvar after lambda expression ()
* Fix  FP uninitvar after lambda expression

* Format
2022-03-15 14:32:33 +01:00
Daniel Marjamäki 3989408738 Update copyright year 2022-02-05 11:45:17 +01:00
chrchr-github 2b13a27140
Fix FP uninitdata - writing pointer to stream () 2022-02-02 12:24:32 +01:00
chrchr-github c74eeb6bad
Fix FN uninitVar with std::array () 2022-01-27 19:45:27 +01:00
Oliver Stöneberg 171da2e6f9
avoid dependency on transitive includes - based on include-what-you-use () 2022-01-27 19:03:20 +01:00
chrchr-github f49cfcd23c
Fix False positive: uninitStructMember () 2022-01-25 12:14:20 +01:00
Paul Fultz II e20ddd55d6
Propagate partially uninit variables in ValueFlow () 2021-10-30 07:43:37 +02:00
Paul Fultz II ca83222bae
Add subexpression analyzer to set values for uninitialized members of struct ()
* Add subexpression analyzer

* Fix errors

* Add tests

* Format

* Add more tests

* Run members first

* Format

* Uncomment todo assert

* Formatting

* Use simpleMatch
2021-10-21 14:44:48 +02:00
Paul Fultz II 257efb4019
Check if uninit value is used in library function () 2021-10-20 20:51:59 +02:00