Commit Graph

634 Commits

Author SHA1 Message Date
Oliver Stöneberg 61bbcbeeee
fixed #12108 - Crash in `CTU::FileInfo::getErrorPath()` with Clang-built binary (#5746)
This is actually just a workaround as it seems the issue is an upstream
Clang one.
2023-12-14 17:44:09 +01:00
chrchr-github 4b9f3c68fb
Fix #12188 FN uninitvar with increment of struct member (#5665) 2023-11-16 18:11:12 +01:00
chrchr-github 72a36172aa
Fix #12142 FP uninitStructMember, unreadVariable with pointer to member (#5618) 2023-11-04 13:40:06 +01:00
Oliver Stöneberg 989d276dde
removed the need for `Check` object in `CTU::getUnsafeUsage()` callback / some CheckUninitVar cleanups (#5610)
The `Check` objects were just created for that purpose so they basically
just were wrappers for the pointers passed into them and were
unnecessary.
2023-11-03 18:27:11 +01:00
Oliver Stöneberg 09785a4eb8
moved `MyFileInfo` definitions into source files (#4697) 2023-10-21 16:58:29 +02:00
Daniel Marjamäki 9d4e3829c2
Partial fix #12030 (False positive: uninitialized variable, conditional modification, flag) (#5543) 2023-10-12 13:56:47 +02:00
Oliver Stöneberg a22c181553
fixed "Redundant elaborated type specifier" Rider warnings (#5517) 2023-10-08 09:10:17 +02:00
Oliver Stöneberg fe8730cf0f
MathLib: renamed `to{U}LongNumber()` to `toBig{U}Number()` (#5503)
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 #11897 (Safety: show what checks are enabled/disabled) (#5372)
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 (#5362) 2023-08-23 12:07:47 +02:00
Paul Fultz II 52081ef08f
Add special function to match lifetimes (#5320)
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 #5311 (#5315) 2023-08-12 23:46:31 +02:00
chrchr-github a7d487f6db
Fix #11805 FP uninitvar for stringstream into deref pointer to uninit var / #11804 FP uninitvar for array in struct in struct (#5311) 2023-08-11 18:45:58 +02:00
chrchr-github 72212331fb
Fix #11832 False positive: uninitialized variable '*(&var) = 0' (#5241) 2023-07-14 19:14:33 +02:00
chrchr-github 4eebf2e733
Fix uninitdata regression (#5179) 2023-06-21 21:19:22 +02:00
chrchr-github bb962e2bc3
Enable and mitigate readability-else-after-return (#5175) 2023-06-20 18:43:21 +02:00
chrchr-github f96e3c9d84
Fix #11766 FP uninitdata with cast (#5170) 2023-06-20 18:06:57 +02:00
Daniel Marjamäki 9a290c959f
Fix #11776 (False positive: uninitialized variable, struct array member initialized in function) (#5165) 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 (#5143) 2023-06-10 21:35:17 +02:00
chrchr-github 7696bd1357
Fix #11225 FN constParameter with cast (#5100)
* Fix #11225 FN constParameter with cast

* Add const
2023-05-31 16:51:03 +02:00
chrchr-github ec2f00d7c2
Fix #1175 uninitialized data: casted to 'int *' and dereferenced (#5008) 2023-05-29 15:29:53 +02:00
chrchr-github 10b55cc0cf
Fix #11654 FN functionConst if only non-const member usage is call to itself (#5092)
* Fix #11654 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 (#5079)
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 #10596 FN uninitdata with value initialization (#5056)
* Assign values to pointers with C++11 init

* Handle assigning empty init list

* Fix #10596 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 (#4897) 2023-03-17 13:51:55 +01:00
Paul Fultz II 61e8b84578
Fix 11610: false negative: knownConditionTrueFalse with address of variable (#4883) 2023-03-12 19:57:11 +01:00
Oliver Stöneberg e2f38fdaf3
removed `experimental` and `safe` from `Certainty` (#4819) 2023-03-12 14:15:29 +01:00
chrchr-github b4c90f8b2a
Fix #11597 FP uninitvar with nested enum (#4847) 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}` (#4642) 2023-01-26 22:23:22 +01:00
Oliver Stöneberg a09667a6d9
removed unused error messages (#4689) 2023-01-07 10:35:39 +01:00
Oliver Stöneberg 1cfe49e340
use `const_iterator` where possible (#4662) 2022-12-30 15:13:47 +01:00
Oliver Stöneberg 6fedbb4f77
add/preserve `const` in `dynamic_cast` (#4655) 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 (#4529)
* 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 (#4488)
* 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 (#4470)
* 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 (#4459)
* 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 (#4204) 2022-08-21 17:21:02 +02:00
Oliver Stöneberg c9c1f83a69
use `emptyString` more consistently (#4034) 2022-07-10 10:57:29 +02:00
Paul Fultz II 185294499c
Adjust the severity of the uninitvar (#4234) 2022-06-28 22:52:35 +02:00
Paul Fultz II 3e3abecba0
Rename old uninitvar ID to use legacyUninitvar (#4043) 2022-04-27 17:37:37 +02:00
chrchr-github 1bc0317719
Fix #11002 FP uninitStructMember with extra parentheses (#4047) 2022-04-25 22:22:35 +02:00
Paul Fultz II 6b9ac6f7a8
Warn when incrementing uninitialized value (#4042)
* Warn when incrementing uninitialized value

* Format
2022-04-24 09:56:58 +02:00
Paul Fultz II 3feecc51d6
Fix 10988: FP: Regression, uninitvar (#4037) 2022-04-21 19:29:38 +02:00
Paul Fultz II d97942d3c6
Fix 6577: Detect pointer to uninitialised memory with clock_settime() (#3993)
* 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 (#3917)
* valueFlowUninit: Handle arrays and pod types

* Format

* Catch another array case
2022-03-24 06:35:44 +01:00
chrchr-github 1aff160411
Fix #9303 FP uninitvar after lambda expression (#3903)
* Fix #9303 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 #9696 FP uninitdata - writing pointer to stream (#3772) 2022-02-02 12:24:32 +01:00
chrchr-github c74eeb6bad
Fix FN uninitVar with std::array (#3707) 2022-01-27 19:45:27 +01:00