Commit Graph

27689 Commits

Author SHA1 Message Date
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 4d18f3e68b
Fix use-after-free crash when using --clang (#5367)
Still ran into an assert failure in `Tokenizer::hasIfdef()`, since some
checks assume that the tokenizer is always present. Seems like
clangimport is yet another rogue under-tested feature...
2023-08-28 09:28:47 +02:00
chrchr-github 737e2f2f70
Update AUTHORS [skip ci] (#5371)
https://github.com/danmar/cppcheck/pull/5370
2023-08-27 00:04:47 +02:00
chrchr-github f6340c02da
Partial fix for #11894 FP knownArgument with function pointer (#5366) 2023-08-26 00:37:10 +02:00
Valentin Batz 078e967ab2
qt library: Make Q_PROPERTY a variadic macro to avoid preprocessorErrorDirective (#5370)
Treat Q_PROPERTY as variadic macro to avoid preprocessorErrorDirective
with associative container templates itroducing a "," like for example
`QHash<QString, int>`. Using templates is totally fine in the context of
a moc compiler.

The macro Q_PROPERTY is defined as variadic in
qobjectdefs.h/qtmetaobject.h when not compiling using the moc compiler.

See following references:
* For Qt 5.15
https://code.qt.io/cgit/qt/qtbase.git/tree/src/corelib/kernel/qobjectdefs.h?h=5.15#n104
* For Qt 6.6
https://code.qt.io/cgit/qt/qtbase.git/tree/src/corelib/kernel/qtmetamacros.h?h=6.6#n5
2023-08-26 00:36:47 +02:00
Daniel Marjamäki 74ad7243ce
Partial fix #11892 (Safety: status message when checkers are skipped) (#5368) 2023-08-25 13:38:27 +02:00
Daniel Marjamäki 6017c254dd
Cppcheck: Remove dumpfile and filelist file using RAII class to avoid that these files are forgotten in early returns or exceptions. (#5369) 2023-08-24 22:47:20 +02:00
chrchr-github 394996581e
Fix FP incorrectCharBooleanError with known condition (#5365) 2023-08-24 10:36:01 +02:00
chrchr-github 4654b6561b
Fix #11890 FP uninitvar for address taken in init list (#5360) 2023-08-24 10:35:33 +02:00
chrchr-github 5a7c7b9b5a
Fix FP incorrectStringBooleanError with unknown macro (#5364) 2023-08-23 18:06:41 +02:00
chrchr-github 8cd61941dc
Unified checks for unevaluated context (#5362) 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` (#5350) 2023-08-23 11:22:41 +02:00
Oliver Stöneberg 0901e496ed
refs #3450 (CLI --report-progress is currently useless) - added `--report-progress=<val>` to specify interval (#5353) 2023-08-23 11:20:20 +02:00
Anton Lindqvist 73b9442edd
Fix constParameterPointer regression (#5361)
Commit 73251544a ("Fix #11842 FN constParameterPointer with library
function (#5257)") 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 #11882 (add --premium=misra-c-2023 option) (#5363) 2023-08-23 10:28:02 +02:00
Paul Fultz II 2adaafd20e
Fix 11887: FP knownPointerToBool with const_cast (#5357) 2023-08-23 01:07:49 +02:00
chrchr-github 6ffe08c9b3
Fix #11886 performance regression (hang) in 2.12dev (#5355)
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 (#5358) 2023-08-22 19:33:24 +02:00
chrchr-github 05a2d88ec8
Fix #11888 FP knownPointerToBool with incorrect overload match / FP unreadVariable (#5356) 2023-08-22 16:53:38 +02:00
Oliver Stöneberg d6beccc445
fixed #11783 (Remove .plist files generated by unit tests) (#5312) 2023-08-22 15:25:28 +02:00
Daniel Marjamäki 18b526b08a
CI: Fix selfcheck cppcheck warnings (#5359) 2023-08-22 14:49:08 +02:00
andymacg 5a136c3f38
Fix #11877 FP misra 10.4 On array member comparison (#5342)
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 #11878 FP misra-c2012-18.7 on function pointer parameter with array-type args (#5343)
https://trac.cppcheck.net/ticket/11878#ticket
2023-08-22 12:03:12 +02:00
Oliver Stöneberg f91df64fec
fixed some Clazy `level0` warnings (#5344)
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 (#5354)
This was introduced in #5279. 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 #11879 FN unreadVariable (regression) (#5345) 2023-08-21 10:44:17 +02:00
chrchr-github 725c431ecc
Fix #11881 FP returnStdMoveLocal / Fix FP incorrectStringBooleanError / Support std::string::starts/ends_with() (#5347) 2023-08-21 10:43:54 +02:00
Paul Fultz II 03b952d5eb
Fix 11579: false negative: knownConditionTrueFalse with non-bool as bool parameter (#5349)
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 (#5352) 2023-08-20 22:01:04 +02:00
chrchr-github 63811b2993
Fix #11872 FN unusedVariable with multidimensional array (#5334) 2023-08-20 11:08:17 +02:00
Paul Fultz II d691450443
Improve knownArgument to check arguments to any nary function (#5348) 2023-08-19 19:59:15 +02:00
Oliver Stöneberg a92b10ca3b
fixes #11104 (avoid C++-only parsing when processing C code in parsedecl()) / also avoid remaining `Library::detect*()` calls (#5346) 2023-08-18 22:48:24 +02:00
chrchr-github 41bdd87d30
Fix #11875: hang in hasBorrowingVariables() (#5337) 2023-08-18 21:02:08 +02:00
Oliver Stöneberg 74c4daaadf
optimized `Token::Match()` a bit by always inlining `Token::multiCompare()` (#5332)
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 (#5322) 2023-08-18 13:45:25 +02:00
Oliver Stöneberg bfb50ca9d8
removed unnecessary `Settings` parameter from `Check::runChecks()` and made `Tokenizer` a reference (#5308)
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>` (#5331)
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>` (#5331)
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` (#5329) 2023-08-18 11:55:23 +02:00
chrchr-github 7f22ef4e14
Set ValueType for auto with ternary (#5304) 2023-08-18 10:33:26 +02:00
chrchr-github 827e87afe7
Fix #11579 FN knownConditionTrueFalse with non-bool as bool parameter / #9450 string literal to bool conversion in function call (#5338) 2023-08-18 10:32:52 +02:00
Oliver Stöneberg 5dbcea3f1d
enabled and mitigated `readability-container-size-empty` clang-tidy warnings (#5340) 2023-08-17 17:01:08 +02:00
Oliver Stöneberg 3cf9100198
fixed #6316 (Use std::to_string() in place of MathLib::toString() ...) - deleted default implementation of `Mathlib::toString()` (#5341)
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 (#5327) 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 (#5335) 2023-08-16 17:13:36 +02:00
Oliver Stöneberg 6a263ba026
optimized `Library::detectContainerInternal()` a bit (#5333)
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() (#5330) 2023-08-16 10:20:53 +02:00
chrchr-github 824f89514a
Add test for #10350, fix arg direction in windows.cfg (#5328) 2023-08-14 17:25:00 +02:00
Paul Fultz II 8aa9d710d1
Fix 11844: FP negativeIndex for known loop (#5282) 2023-08-14 15:17:05 +02:00
chrchr-github c257c70347
Fix #11546 FP danglingTemporaryLifetime with unknown member (#5256) 2023-08-14 14:32:35 +02:00