Commit Graph

27279 Commits

Author SHA1 Message Date
chrchr-github 394996581e
Fix FP incorrectCharBooleanError with known condition () 2023-08-24 10:36:01 +02:00
chrchr-github 4654b6561b
Fix FP uninitvar for address taken in init list () 2023-08-24 10:35:33 +02:00
chrchr-github 5a7c7b9b5a
Fix FP incorrectStringBooleanError with unknown macro () 2023-08-23 18:06:41 +02:00
chrchr-github 8cd61941dc
Unified checks for unevaluated context () 2023-08-23 12:07:47 +02:00
Oliver Stöneberg 499f566e9d
got rid of duplicated file/directory existence implementations / improved errorhandling and testing of `FileLister` () 2023-08-23 11:22:41 +02:00
Oliver Stöneberg 0901e496ed
refs (CLI --report-progress is currently useless) - added `--report-progress=<val>` to specify interval () 2023-08-23 11:20:20 +02:00
Anton Lindqvist 73b9442edd
Fix constParameterPointer regression ()
Commit 73251544a ("Fix  FN constParameterPointer with library
function ()") most likely introduced a regression for (C) function
pointers passed to functions provided by the standard library that
cppcheck has knowledge about.
2023-08-23 10:33:01 +02:00
Daniel Marjamäki e35d5d3ceb
Fix (add --premium=misra-c-2023 option) () 2023-08-23 10:28:02 +02:00
Paul Fultz II 2adaafd20e
Fix 11887: FP knownPointerToBool with const_cast () 2023-08-23 01:07:49 +02:00
chrchr-github 6ffe08c9b3
Fix performance regression (hang) in 2.12dev ()
Or maybe we should just limit the recursion depth.
2023-08-22 21:01:52 +02:00
chrchr-github af46c68a94
Fix FP incorrectStringBooleanError with macro () 2023-08-22 19:33:24 +02:00
chrchr-github 05a2d88ec8
Fix FP knownPointerToBool with incorrect overload match / FP unreadVariable () 2023-08-22 16:53:38 +02:00
Oliver Stöneberg d6beccc445
fixed (Remove .plist files generated by unit tests) () 2023-08-22 15:25:28 +02:00
Daniel Marjamäki 18b526b08a
CI: Fix selfcheck cppcheck warnings () 2023-08-22 14:49:08 +02:00
andymacg 5a136c3f38
Fix FP misra 10.4 On array member comparison ()
I also changed the comment header to run tests on misra-test-avr8.c
because I thought that was the intention to use it like misra-test.c; if
not, I can revert.
2023-08-22 12:18:12 +02:00
andymacg 5bb4c6f5bc
Fix FP misra-c2012-18.7 on function pointer parameter with array-type args ()
https://trac.cppcheck.net/ticket/11878#ticket
2023-08-22 12:03:12 +02:00
Oliver Stöneberg f91df64fec
fixed some Clazy `level0` warnings ()
Regarding the "normalized signatures" see
https://github.com/KDE/clazy/blob/master/docs/checks/README-connect-not-normalized.md
and https://doc.qt.io/qt-6/qmetaobject.html#normalizedSignature.
2023-08-22 12:01:30 +02:00
Oliver Stöneberg 59c3bd22e6
ProcessExecutor: removed unnecessary `\0` passing in message reading/writing - fixes stray `\0` characters in output ()
This was introduced in . We were transferring the terminating `\0`
via the pipe and also added another one in the parsing. As we are now
directly writing into a `std::string` these extra characters will now
show up in it. So just get rid of them.
2023-08-21 12:17:08 +02:00
chrchr-github 3281fc91db
Fix FN unreadVariable (regression) () 2023-08-21 10:44:17 +02:00
chrchr-github 725c431ecc
Fix FP returnStdMoveLocal / Fix FP incorrectStringBooleanError / Support std::string::starts/ends_with() () 2023-08-21 10:43:54 +02:00
Paul Fultz II 03b952d5eb
Fix 11579: false negative: knownConditionTrueFalse with non-bool as bool parameter ()
This adds a new checker to check for pointer to bool conversions that
are always known. I removed the previous knownConditionTrueFalse checks
since this was too noisy.
2023-08-20 22:32:41 +02:00
Paul Fultz II a5cfa85e0d
Fix 11884: Hang in valueFlowGetStrLength () 2023-08-20 22:01:04 +02:00
chrchr-github 63811b2993
Fix FN unusedVariable with multidimensional array () 2023-08-20 11:08:17 +02:00
Paul Fultz II d691450443
Improve knownArgument to check arguments to any nary function () 2023-08-19 19:59:15 +02:00
Oliver Stöneberg a92b10ca3b
fixes (avoid C++-only parsing when processing C code in parsedecl()) / also avoid remaining `Library::detect*()` calls () 2023-08-18 22:48:24 +02:00
chrchr-github 41bdd87d30
Fix : hang in hasBorrowingVariables() () 2023-08-18 21:02:08 +02:00
Oliver Stöneberg 74c4daaadf
optimized `Token::Match()` a bit by always inlining `Token::multiCompare()` ()
Scanning `mame_regtest` with `DISABLE_VALUEFLOW=1` and `--enable=all
--inconclusive`:

Clang 15 `1,170,770,173` -> `1,167,227,434`
GGC 12 `1,370,070,422` -> `1,366,775,852`
2023-08-18 20:41:50 +02:00
Oliver Stöneberg e669b102f8
renamed `Check::reportError(const ErrorMessage&)` to `writeToErrorList()` to reflect its actual behavior () 2023-08-18 13:45:25 +02:00
Oliver Stöneberg bfb50ca9d8
removed unnecessary `Settings` parameter from `Check::runChecks()` and made `Tokenizer` a reference ()
There was no need for the `Tokenizer` parameter to be a pointer as it
could never be `nullptr` and was also dereferenced without checking
first.

As a reference to the `Settings` was already available via the
`Tokenizer` there was no need to pass it separately. In the production
code there will only be one instance of it but in the tests we could
have accidentally passed a different one.
2023-08-18 12:03:50 +02:00
Oliver Stöneberg 1bedf4434d
CmdLineParser: deprecated `--template <template>` and `--template-location <template>` ()
Both are bugprone since they just take the next parameter which doesn't
start with `-`.

Also `--template` has not been documented since
17842394c0 back in 2011(!). And
`--template-location` has never been documented since its induction in
f058d9ad08. That's also why we can have a
short deprecation period.
2023-08-18 11:59:40 +02:00
Oliver Stöneberg c7f88db90a
CmdLineParser: deprecated `--template <template>` and `--template-location <template>` ()
Both are bugprone since they just take the next parameter which doesn't
start with `-`.

Also `--template` has not been documented since
17842394c0 back in 2011(!). And
`--template-location` has never been documented since its induction in
f058d9ad08. That's also why we can have a
short deprecation period.
2023-08-18 11:59:14 +02:00
Oliver Stöneberg 33dee83c21
moved suppression-specific code out of `ErrorLogger` () 2023-08-18 11:55:23 +02:00
chrchr-github 7f22ef4e14
Set ValueType for auto with ternary () 2023-08-18 10:33:26 +02:00
chrchr-github 827e87afe7
Fix FN knownConditionTrueFalse with non-bool as bool parameter / string literal to bool conversion in function call () 2023-08-18 10:32:52 +02:00
Oliver Stöneberg 5dbcea3f1d
enabled and mitigated `readability-container-size-empty` clang-tidy warnings () 2023-08-17 17:01:08 +02:00
Oliver Stöneberg 3cf9100198
fixed (Use std::to_string() in place of MathLib::toString() ...) - deleted default implementation of `Mathlib::toString()` ()
It was also used inconsistently and seemed to imply there is some
special handling which wasn't the case. It was just an alias for
`std::to_string()` for non-`double` types. So there was no need for it.

---------

Co-authored-by: Robert Reif <reif@earthlink.net>
2023-08-17 16:46:32 +02:00
Oliver Stöneberg d8b44dff56
fixed/suppressed several compiler warnings () 2023-08-16 19:35:53 +02:00
Oliver Stöneberg 84a9b3a5f2
enabled and mitigated `modernize-use-equals-default` clang-tidy warnings / removed unnecessary default destructors () 2023-08-16 17:13:36 +02:00
Oliver Stöneberg 6a263ba026
optimized `Library::detectContainerInternal()` a bit ()
Scanning `cli/filelister.cpp` with `DISABLE_VALUEFLOW=1` and
`--enable=all -Ilib -D__GNUC__`

Clang 15 `111,300,996` -> `106,883,955`
GCC 13 `110,555,879` -> `105,983,608`
2023-08-16 11:10:38 +02:00
chrchr-github 8b309a8829
Use readdir() instead of deprecated readdir_r() () 2023-08-16 10:20:53 +02:00
chrchr-github 824f89514a
Add test for , fix arg direction in windows.cfg () 2023-08-14 17:25:00 +02:00
Paul Fultz II 8aa9d710d1
Fix 11844: FP negativeIndex for known loop () 2023-08-14 15:17:05 +02:00
chrchr-github c257c70347
Fix FP danglingTemporaryLifetime with unknown member () 2023-08-14 14:32:35 +02:00
Ryan M. Lederman d064f9c243
-j 0 causes indefinite hang. require >= 1 ()
In cppcheck 2.11.1 (macOS), using `-j 0` actually causes cppcheck to do
nothing–it stalls indefinitely.

I could only find one place where `mSettings.jobs` was validated against
> 0 and it's simply an assert, so you wouldn't hit it in a release
build.

- Require -j >= 1 
- Cap -j at 1024, not 10000  (I don't even know what would happen if
you created 10,000 threads, but nothing good; likely exhaust virtual
memory or grind the process to a halt). 1024 is still obscene but there
may be some hypercomputers out there that have that many logical cores.
2023-08-14 11:55:32 +02:00
Oliver Stöneberg 693084470d
TestCmdlineParser: fixed some TODO test cases () 2023-08-14 11:37:59 +02:00
Oliver Stöneberg d076da8f7c
added missing `__GNUC__` define for selfcheck ()
This was causing some code not to be enabled in the selfchecks leading
to some missing warnings.
2023-08-14 10:29:04 +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
Paul Fultz II 48c91abba6
Fix issue 11867: Assert failure in valueFlowContainerSize() () 2023-08-13 22:31:38 +02:00
chrchr-github 466da1e77a
Fix FP misusedScopedObject () 2023-08-13 22:24:17 +02:00
Oliver Stöneberg 5371455606
optimized pipe writing/reading and `ErrorMessage` serialization a bit () 2023-08-13 11:52:02 +02:00