Commit Graph

12793 Commits

Author SHA1 Message Date
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 8c0d43d928
removed unnecessary encapsulation of severity enum and made it an `enum class` (#5541) 2023-10-12 11:58:39 +02:00
chrchr-github 179d26f06b
Fix #12064 FP useStlAlgorithm with loop over initializer list (#5542) 2023-10-12 10:06:52 +02:00
chrchr-github e247e818ec
Fix #12052 FP: containerOutOfBounds (#5534) 2023-10-11 14:08:17 +02:00
Oliver Stöneberg 7393083d5d
added `CmdLineLogger::printRaw()` / CppCheckExecutor: more `CmdLineLogger` usage (#5537) 2023-10-09 22:22:39 +02:00
Oliver Stöneberg cc92b09ec1
fixed #12016 - ProcessExecutor: added missing invocation of clang-tidy (#5529)
No changes in tests since the intercepted invocation function in called
in a forked process. The clang-tidy integration is also broken.
2023-10-09 12:26:58 +02:00
Oliver Stöneberg 06b5ef1e4d
cleaned up includes based on include-what-you-use (#5532) 2023-10-09 10:07:20 +02:00
Oliver Stöneberg 0f28f3e493
generate `AddonInfo` only once (#4958)
Currently the `AddonInfo` is generated and discarded on each addon
invocation. This leads to an unnecessary process invocation for each
addon on each file.

Also if an addon is completely broken we will still perform the whole
analysis only for it to be failed at the end so we should bail out early
if we know it doesn't work at all.
2023-10-08 21:28:57 +02:00
Oliver Stöneberg 960e8bb4ea
testrunner: got rid of some redundant preprocessing code / added some missing asserts (#5521)
This consolidates the stray invocations of preprocessing.
2023-10-08 11:29:52 +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 3ba53c6b6a
fixed #12022 - disallow using `--project` with source files (#5515) 2023-10-08 09:07:15 +02:00
Oliver Stöneberg 8dee551cad
added testing of clang-tidy invocation to executor tests / also some cleanups (#5514) 2023-10-08 09:06:02 +02:00
moui0 eb076d877b
Improve testcases for unsigned char platforms (#5524)
I got error messages while building `cppcheck 2.12.0` for RISC-V Arch
Linux:
```
Testing Complete
Number of tests: 4420
Number of todos: 331
Tests failed: 2

/usr/src/debug/cppcheck/cppcheck/test/testcondition.cpp:4501(TestCondition::alwaysTrue): Assertion failed. 
Expected: 
[test.cpp:6]: (style) Condition 'o[1]=='\0'' is always false\n

Actual: 
[test.cpp:4] -> [test.cpp:6]: (style) Condition 'o[1]=='\0'' is always false\n

_____
/usr/src/debug/cppcheck/cppcheck/test/testcondition.cpp:5014(TestCondition::alwaysTrueContainer): Assertion failed. 
Expected: 
[test.cpp:5]: (style) Condition 'buffer.back()=='\0'' is always false\n

Actual: 
[test.cpp:3] -> [test.cpp:5]: (style) Condition 'buffer.back()=='\0'' is always false\n
```

I found out the reason is that the testcases were designed for
x86/x86_64 or other `signed char` platforms (i.e. default character type
is `signed char` ), whereareas RISC-V is an `unsigned char` platform,
which causes different behavior in
`lib/valueflow.cpp:valueFlowImpossibleValues`. I'm not sure whether this
error leads from a functional bug, so if you have a better approach to
fix it, please let me know.

Maybe you could reproduce this error on x86_64 platform by setting
`defaultSign = 'u';` in `Platform::set(Type t)`.
2023-10-07 23:04:57 +02:00
orbitcowboy e9c39c124a
windows.cfg: Fix wrong FlushConsoleInputBuffer configuration (#5526)
After flushing, the function returns. Before it was configured to
not-return.
A proper regression test was added.
2023-10-07 20:05:43 +02:00
Paul Fultz II d48df980b4
Fix 12030: False positive: uninitialized variable, conditional modification, flag (#5520) 2023-10-07 14:01:06 +02:00
orbitcowboy 1d30b617c1
windows.cfg: Fixed wrong configuration of GetModuleHandle(A|W)-functions (#5525)
This fixes a FP: `Variable 'path' can be declared as const array
[constVariable]`

The reason was the wrong direction attribute of GetModuleHandle()
2023-10-07 13:59:01 +02:00
chrchr-github 903eccb336
Fix #12039 FP knownConditionTrueFalse (#5513) 2023-10-06 09:53:24 +02:00
Oliver Stöneberg 5a52fa80fb
refs #12022 - disallow multiple `--project` options (#5499) 2023-10-05 21:36:44 +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
Oliver Stöneberg fc700b68eb
refs #4452 / refs #11705 - improved `--showtime=` behavior and testing (#4876)
This is a step onto leveraging the `ThreadExecutor` implementation for
`ProcessExecutor` which is a follow-up to #4870. We need to have the
proper test coverage and the existing implementations working as
expected before we move to the shared code.

Fixes:
- added `--showtime=` tests for all executor implementations
- only print `--showtime=summary` once at the end
- prevents `--showtime=` by multiple threads to be written at the same
time - essentially breaking the output
- reset the timer results before each test
- deprecated `top5` in favor of `top5_file`
- fixed printing for all executors except `ProcessExecutor`
2023-10-05 19:04:06 +02:00
chrchr-github 787da43dc9
Fix #12036 FN knownConditionTrueFalse comparing enum with number (#5510) 2023-10-05 18:15:18 +02:00
Daniel Marjamäki a52d2a23a0
Fix #12018 (False positive: null pointer, multiple arguments) (#5509) 2023-10-05 15:08:25 +02:00
chrchr-github d9a8909d2a
Fix #11408 debug: Function::addArguments found argument 't' with varid 0 (#5507) 2023-10-05 10:01:46 +02:00
Daniel Marjamäki 6a8f787915
Fix #12026 (simplifyTypedef: not handled properly when typedef and enum constant has same name) (#5500) 2023-10-01 21:26:54 +02:00
chrchr-github 6773cdb34b
Fix #12014 syntaxError due to bad typedef simplification (#5493) 2023-09-28 19:26:12 +02:00
Daniel Marjamäki ed5532c2a7
Fix #12019 (False positive: null pointer, array zero initialization) (#5495) 2023-09-28 15:18:08 +02:00
Daniel Marjamäki c4fe5ac8b7
Fix #12012 (FP: uninitvar, address of variable is casted to uintptr_t that is passed to function) (#5494) 2023-09-28 13:47:11 +02:00
chrchr-github 63b76d2266
Fix valueFlowBailoutIncompleteVar with ptr to ptr (refs #10045) (#5488) 2023-09-28 10:36:18 +02:00
chrchr-github 73d305ea46
Fix #12013 crash: crashes in release builds if cppcheck build dir is used (#5489) 2023-09-27 16:44:22 +02:00
chrchr-github e928f2b5aa
Fix valueFlowBailoutIncompleteVar with new (refs #10045) (#5487) 2023-09-26 21:39:07 +02:00
Oliver Stöneberg 3774d46303
TestCmdlineParser: store messages in logger class instead of utilizing the redirect (#5482) 2023-09-26 21:38:15 +02:00
chrchr-github f037edf586
Fix #11440 FN Moved value when using {} to initialize (#5479) 2023-09-26 10:04:22 +02:00
Oliver Stöneberg 9f96803f62
TestCheck: added missing registration (#5484) 2023-09-26 10:03:53 +02:00
chrchr-github 99e38cf8f8
Partial fix for #10968 FN detect always false/true comparison of function with constant (#5480) 2023-09-25 22:18:07 +02:00
Oliver Stöneberg 3fd00c19df
perform logging in `CmdLineParser` through an interface (#5478)
This is in preparation of avoiding accessing `std::cout` directly as
well as streamlining and improving the logging during the settings
parsing. There are no functional changes yet.
2023-09-25 13:43:18 +02:00
Oliver Stöneberg 1959c85e34
test/cli/test-other.py: improved addon tests (#5469) 2023-09-25 13:39:17 +02:00
Oliver Stöneberg 3979ade9ea
got rid of test-only `Library` functions / avoid some more direct modifications of library data structures in test (#5468) 2023-09-25 13:37:24 +02:00
chrchr-github bba96c5c8f
Fix valueFlowConditionExpressions bailout for C++ casts (refs #10045) (#5472) 2023-09-22 18:19:36 +02:00
chrchr-github b745d9ad6e
Fix #12010 Improve unknownMacro message: int (#5473) 2023-09-22 10:16:21 +02:00
chrchr-github dc59543348
Fix #12006 Improve unknownMacro message (#5470) 2023-09-21 00:28:49 +02:00
chrchr-github 57bbb17f3b
Fix #11986 debug: Executable scope 'x' with unknown function. (#5463) 2023-09-20 17:18:00 +02:00
chrchr-github dc19916966
Fix valueFlowConditionExpressions bailout for library function (refs #10045) (#5461) 2023-09-20 15:49:13 +02:00
Oliver Stöneberg f49fedb2ad
fixed #11483 (FN unusedFunction for method with inline implementation) (#5457)
Co-authored-by: chrchr-github <78114321+chrchr-github@users.noreply.github.com>
2023-09-20 14:45:44 +02:00
Oliver Stöneberg 21e001cd1a
refs #11993 - error out in `TestFileLister::recursiveAddFiles()` instead of looping infinitely when repository root directory is not found (#5462)
Not a proper fix yet but at least it prevents the hang and gives some
feedback.
2023-09-20 10:49:00 +02:00
Oliver Stöneberg a43b55a0ca
Improved addon execution errorhandling (#5451) 2023-09-20 10:40:57 +02:00
Paul Fultz II 58a7519cbb
Fix 11992: FN (regression): uninitvar (#5465) 2023-09-20 06:43:58 +02:00
chrchr-github c6b3c56174
Improve findEnumerator() (refs #10045) (#5459) 2023-09-19 11:45:59 +02:00
Tomasz Edward Posluszny b6f60ad952
Support importing projects with project-name (#5456) 2023-09-18 13:54:20 +02:00
chrchr-github 10c1ac977c
Fix findEnumerator() with nested enum (refs #10045) (#5454) 2023-09-18 12:09:59 +02:00
chrchr-github 640b561633
Fix #11995 FP passedByValue when variable is moved from (#5455) 2023-09-17 22:32:35 +02:00
chrchr-github 0c51977f86
Fix valueFlowBailoutIncompleteVar for cast and template args (refs #10045) (#5452) 2023-09-16 13:03:14 +02:00
chrchr-github 50ba5061c7
Fix #11438 MathLib error on user defined literals (#5448)
Based on #4701, #5418

A helper function for the `isdigit()` test should be introduced on the
simplecpp side.

Co-authored-by: gerboengels <github@gerbo.org>
2023-09-15 10:00:00 +02:00
chrchr-github 5a21851bb7
Fix #11981 internalAstError with using declaration (#5446) 2023-09-14 12:14:08 +02:00
chrchr-github 775af5ec70
Add test for simplecpp#314 (#5438) 2023-09-14 09:41:39 +02:00
Paul Fultz II e6632d93e3
Fix 11983: False positive: uninitialized variable (#5443) 2023-09-13 23:27:08 +02:00
Paul Fultz II a1078f446a
Fix 11980: False positive returnDanglingLifetime returning pointer to stack array as std::string (by way of struct return value constructor) (#5445) 2023-09-13 21:26:37 +02:00
chrchr-github 844ed2bf22
Fix #11421 FP shiftTooManyBits with 64bit enum (#5406) 2023-09-13 17:59:47 +02:00
Daniel Marjamäki 7d1423c5fb
Fix #11975 (SymbolDatabase: findFunction does not find the correct function) (#5440) 2023-09-13 13:37:57 +02:00
chrchr-github 523c41a60b
Fix #11978 debug: Executable scope 'x' with unknown function. (#5437) 2023-09-13 11:39:09 +02:00
Oliver Stöneberg 98ce46a3e5
fixed #11919 - Removed deprecated command-line options `--template <template>` and `--template-format=<template>` (#5439) 2023-09-12 22:46:40 +02:00
chrchr-github 18ee859737
Fix #11976 FP incorrectStringBooleanError in assert (#5415) 2023-09-12 10:05:51 +02:00
Oliver Stöneberg e7dd490fed
adjusted tests to reduce the amount of `friend` declarations necessary (#5435)
We were calling several interface functions through their inherited
classes instead of using the base classes requiring us to add `friend`
declarations to make the implementations accessible. This adjusts
several of those cases.
2023-09-11 20:26:22 +02:00
chrchr-github 1b5b74d1f3
Fix FP knownArgument (f'up to #11927) (#5434) 2023-09-11 20:02:00 +02:00
chrchr-github c6721688e2
Fix #11929 FP knownPointerToBool with dynamic_cast (#5416) 2023-09-11 18:04:36 +02:00
chrchr-github cbbf500cd4
Fix valueFlowBailoutIncompleteVar for init list (refs #10045) (#5433) 2023-09-11 16:49:39 +02:00
chrchr-github aa281501c9
Fix #11923 FN unreadVariable (regression) (#5409) 2023-09-11 11:36:03 +02:00
Oliver Stöneberg 64cd09ab62
fixed #11917 (Default to `native` platform in Windows builds) (#5428) 2023-09-11 11:08:23 +02:00
Daniel Marjamäki 87719121bd
Fixed #11908 (SymbolDatabase: array not parsed properly 'int (**rs)[32]') (#5430) 2023-09-10 20:58:30 +02:00
chrchr-github f9b18bc9d8
Fix FP (regression): Resource handle 'fd' freed twice. [doubleFree] (#5424) 2023-09-10 20:32:55 +02:00
Oliver Stöneberg 91070ca794
utils.h: added `startsWith()` and started using it (#5381)
This makes the code much more readable. It also makes it less prone to
errors because we do not need to specify the length of the string to
match and the returnvalue is clear.

The code with the bad returnvalue check was never executed and I added a
test to show that.
2023-09-08 19:30:25 +02:00
Oliver Stöneberg 3cbbb77335
fixed #11926 (Treat MacOS filesystem as case insensitive) / TestPath: added more tests (#5412) 2023-09-08 17:33:37 +02:00
chrchr-github 4d5e84aa5f
Partial fix for #11927 FP knownArgument with unknown function type (#5413) 2023-09-08 16:41:07 +02:00
chrchr-github e4f92f6979
Fix #10837 crash/hang in expandTemplate (#5410) 2023-09-08 14:59:42 +02:00
chrchr-github 7a79366ba0
Fix #11914 Crash when checking widelands (#5404) 2023-09-05 11:12:04 +02:00
chrchr-github 03026c7304
Fix #11915 Assert failure in getTemplateNamePosition() (#5403) 2023-09-05 00:35:33 +02:00
Oliver Stöneberg ce780177b2
fixed #11910 - removed Visual Studio x86 targets from project files and builds from CI (#5397)
Windows XP Pro x64 was released on April 25, 2005 and consumer
processors supporting x86-64 have been around almost as long. Although
there are still 32-bit Windows images available there is not much of a
point maintaining support for these. We also never did any x86 builds
for non-Windows platforms in CI so we don't even know if we work on
those. You might still be able to build 32-bit binaries via CMake.
2023-09-04 19:40:13 +02:00
Oliver Stöneberg c068c74e86
CI-mingw.yml: use pre-installed MinGW / also use `lld` and `ccache` for faster builds (#4400)
This used to be one of the longest running jobs because of the slow
setup and linking. Now it will take only ~2 minutes if everything is
cached with half the time taken up by the tests.
2023-09-04 13:56:18 +02:00
Paul Fultz II fd12baaf89
Fix 11898: FP knownEmptyContainer (#5394) 2023-09-02 14:30:35 +02:00
Paul Fultz II ffbcfae988
Fix 11889: FP knownArgument with array element (#5395) 2023-09-02 14:29:38 +02:00
Paul Fultz II 6c0a5a5859
Fix 11894: FPs knownArgument with sizeof and function pointer (#5396) 2023-09-02 14:28:54 +02:00
Daniel Marjamäki 88a9119f88
Fixed #11907 (False positive: uninitialized member (mutable member, const method call)) (#5384) 2023-09-01 18:10:21 +02:00
Daniel Marjamäki c3136dbc2a
Refactor: The code to generate id string from pointer can be simplified (#5382) 2023-08-31 23:14:28 +02:00
Daniel Marjamäki 85332b2af6
Fixed #11904 (One more related fix for Scope::findFunction) (#5383) 2023-08-31 23:12:54 +02:00
Daniel Marjamäki 44c149e51b
Fix #11897 (Safety: show what checks are enabled/disabled) (#5378)
This primarily adds the corresponding report in the GUI that we have in
the command line already
2023-08-31 18:28:47 +02:00
Daniel Marjamäki 22547beaaf
CI: Add test for #11649 (#5380) 2023-08-31 16:46:20 +02:00
Daniel Marjamäki 1b061564d9
Fix #11904 (Scope::findFunction: better handling when non-virtual method with same name and arguments exists both in base class and derived class) (#5379) 2023-08-31 14:44:44 +02:00
Oliver Stöneberg ad1caa8100
report `internalError` when command execution returns errorcode / also some related cleanups and tests (#5037)
Encountered while investigating https://trac.cppcheck.net/ticket/11708.

This has been like this since the introduction of `internalError` in
b6bcdf2936 (almost ten years ago to the
day). Logging internal errors which bail out(!) of the analysis simply
to `std::cout` for them possibly never to be seen (and also not affected
the exitcode) is pretty bad IMO. They should always be visible.

I also removed the filename from the message as it is already available
(and thus redundant) and its existence should be defined by the
template.
2023-08-31 13:33:29 +02:00
Oliver Stöneberg 0fadf9ed25
sped up `Tokenizer::dump()` (#5009)
Scanning the `cli` folder with `DISABLE_VALUEFLOW=1` `Tokenizer::dump()`
will consume almost 25% of the total Ir count when an addon is
specified. This is mainly caused by the usage of `std::ostream`.

Encountered while profiling #4958.
2023-08-31 11:54:46 +02:00
Daniel Marjamäki 7c992ced4c
Fixed #11901 (Performance regression: large array with strings) (#5375)
Analysis has slowed down a lot when there are many strings in an array.
2023-08-30 19:35:43 +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 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 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
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
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
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
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
chrchr-github 41bdd87d30
Fix #11875: hang in hasBorrowingVariables() (#5337) 2023-08-18 21:02:08 +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 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
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
Ryan M. Lederman d064f9c243
-j 0 causes indefinite hang. require >= 1 (#5326)
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 (#5325) 2023-08-14 11:37:59 +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
Paul Fultz II 48c91abba6
Fix issue 11867: Assert failure in valueFlowContainerSize() (#5317) 2023-08-13 22:31:38 +02:00
chrchr-github 466da1e77a
Fix FP misusedScopedObject (#5321) 2023-08-13 22:24:17 +02:00
chrchr-github d4d77edeae
Fix FP uninitStructMember / cleanup from #5311 (#5315) 2023-08-12 23:46:31 +02:00
Oliver Stöneberg 2b3dec4418
TestCmdlineParser: properly reset settings and parser between tests (#5310) 2023-08-12 21:43:12 +02:00
Paul Fultz II 0901ba9a7e
Fix 11865: Assert failure in setSymbolic() (#5318) 2023-08-12 19:58:09 +02:00
Anton Lindqvist 5c6962c273
Fix FP unusedVariable with arrays (#5319) 2023-08-12 16:55:52 +02:00
Anton Lindqvist b9cc138e57
Fix FP badBitmaskCheck in nested binary expressions (#5316)
If one operand is another binary expression, recursively ensure that no
nested operands are expanded macros.
2023-08-11 23:06:24 +02:00
chrchr-github 720ae01898
Fix #11353 FP uninitvar for struct member set via pointer (#5314) 2023-08-11 18:46:51 +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 560982de94
Fix FP leakNoVarFunctionCall (#5309) 2023-08-10 20:55:02 +02:00
chrchr-github 23deadb370
Fix #11866 FN memleak when pointer is converted to bool (#5306) 2023-08-10 15:38:12 +02:00
Paul Fultz II 24479c60f9
Fix 11850: false negative: knownConditionTrueFalse with std::string::empty() after modification (#5307) 2023-08-09 20:33:44 +02:00
Oliver Stöneberg 2502897265
avoid some redundant and unused settings in tests among other cleanups / added and used `WARN_UNUSED` attribute (#5284) 2023-08-09 12:43:55 +02:00
Paul Fultz II 037bed5b3c
testrunner: fix clang compile error related to `dinit` (#5297)
This fixes the compile error introduced in 5d201c4.
2023-08-08 23:55:07 +02:00
chrchr-github 5ea1bca99f
Fix argument direction in windows.cfg, missing Qt macros (#5302) 2023-08-08 22:55:55 +02:00
chrchr-github c3d7c91e88
Additional call to setValueTypeInTokenList() (#5300) 2023-08-08 22:54:27 +02:00
chrchr-github eee1221738
Use in-class initializers, default constructors, class -> struct (#4842) 2023-08-08 11:05:02 +02:00
chrchr-github 838b6b86e3
Fix #11862 FN constParameterPointer with increment (#5291) 2023-08-08 10:38:03 +02:00
chrchr-github 610777d586
Set enum ValueType for :: (#5298) 2023-08-07 21:40:33 +02:00
Oliver Stöneberg 072212e708
added `TestCheck` and moved some tests from `TestCppcheck` (#5289) 2023-08-07 20:49:10 +02:00
Oliver Stöneberg 988edd24c2
TestSingleExecutor: test clang-tidy invocation (#5294) 2023-08-07 20:47:24 +02:00
Oliver Stöneberg dcdf67a694
some `-Wdouble-promotion` Clang compiler warnings (#4820) 2023-08-07 20:44:25 +02:00
Oliver Stöneberg cc592a6927
CppCheckExecutor: improved library loading error handling a bit (#5275) 2023-08-07 19:48:11 +02:00
Oliver Stöneberg a17f6e89d1
pass `Suppressions` separately from `const Settings` into executors (#5278) 2023-08-07 18:39:57 +02:00
chrchr-github 73251544a4
Fix #11842 FN constParameterPointer with library function (#5257) 2023-08-05 18:48:43 +02:00
Samuel Poláček b2511fb3ae
Check if --cppcheck-build-dir exists (#5254)
Cppcheck does not report that cppcheck build dir does not exist and also
does not report any write issues to the non-existent directory.

This means that cppcheck build dir is actually not used.

We should either create the directory or fail.
2023-08-04 17:38:43 +02:00
Oliver Stöneberg 5d201c4e87
testrunner: use structs with designated initialization to pass options (#4975)
I need to add parameters to some `check()` functions in the tests and
things are already pretty messy with having to specify all the default
values - readability aside.

I found this on https://stackoverflow.com/a/49572324/532627 - apparently
the CC BY-SA license by StackOverflow allows the usage within GPL.
2023-08-04 13:56:18 +02:00
chrchr-github 5ff8955dbe
Fix #11862 FP truncLongCastAssignment with increment (#5290) 2023-08-03 13:49:11 +02:00
chrchr-github faf8047050
Fix FP truncLongCastReturn on Windows (#5262) 2023-08-02 12:27:29 +02:00
Oliver Stöneberg 45de338f1b
cleaned up includes based on include-what-you-use / iwyu.yml: updated to yet another distro to get the latest version and updated the Chaotic-AUR key (#5267)
This is a mess. The version is AUR is still outdated and also doesn't
install anymore. Fedora 38 carries the latest version of it so use that
now. Keep the old steps in case we need to switch again in the future.
2023-08-02 10:36:17 +02:00
Paul Fultz II 389e446dc0
Fix 11848: Assert failure in getParentValueTypes() (#5274) 2023-08-02 10:29:19 +02:00
chrchr-github 931a59a724
Fix FN variableScope (#5273)
Co-authored-by: chrchr-github <chrchr@github>
2023-08-01 23:56:24 +02:00
chrchr-github bfaa7c075a
Fix #11845 FP variableScope if buffer is passed to a conditionally called function (#5265)
Co-authored-by: chrchr-github <chrchr@github>
2023-07-27 22:18:34 +02:00
chrchr-github 99f7f88f39
Fix FN constParameterPointer (#5270)
Co-authored-by: chrchr-github <chrchr@github>
2023-07-27 20:54:12 +02:00
Tobias f10851dc37
posix.cfg: erand48/nrand48/jrand48 fixed argument direction (#5253) 2023-07-27 07:50:46 +02:00
chrchr-github 2cf4b3a6f3
Fix functionConst TODO (#5261) 2023-07-24 16:26:23 +02:00
chrchr-github 101ddea1e6
Fix #11840 FP constStatement with template parameters on operator (#5258) 2023-07-21 17:33:18 +02:00
chrchr-github a6b0129725
Fix #11838 FP uninitvar with label matching variable name (#5251) 2023-07-20 10:45:44 +02:00
chrchr-github d2546d5252
Fix #11788 False positive: unreadVariable in else (#5248) 2023-07-18 21:11:03 +02:00
chrchr-github 2878c68ec0
Fix FP unknownMacro (#5249) 2023-07-18 12:16:54 +02:00
Paul Fultz II 92caa835b6
Fix 11806: FP uninitvar for reference to unitvar in ternary ?: operator (#5247) 2023-07-17 10:34:54 +02:00
chrchr-github e4827cb3df
Fix #11828 False positive when getting a span via an out argument (#5243)
We didn't warn for the TODO even before this change.
2023-07-15 17:53:40 +02:00
chrchr-github 72212331fb
Fix #11832 False positive: uninitialized variable '*(&var) = 0' (#5241) 2023-07-14 19:14:33 +02:00
chrchr-github a4a29bfbc5
Fix #11411 FP selfInitialization after initialization of previous member from initializer list (#5239) 2023-07-14 10:33:05 +02:00
chrchr-github 48dd4dc33e
Fix #11831 FP negativeContainerIndex / wrong return value from virtual function (#5240) 2023-07-13 20:38:47 +02:00
chrchr-github 258581ce2e
Fix FP uselessOverride with macro (#5238) 2023-07-13 12:18:29 +02:00
chrchr-github c0bd9f8bbd
Fix #11827 FP duplInheritedMember - different return type (#5231) 2023-07-12 15:56:07 +02:00
chrchr-github 709fec88f9
Revert "Fix #11765 FN: minsize not checked for string literal, buffer… (#5235)
… access out of bounds not found (#5154)"

This reverts commit 9ad18f51af.
2023-07-11 22:19:01 +02:00
chrchr-github 8d3fd88d3f
Fix #11802 FP stlcstr for string in shared_ptr copied elsewhere (#5230) 2023-07-10 15:27:33 +02:00
chrchr-github 9ad18f51af
Fix #11765 FN: minsize not checked for string literal, buffer access out of bounds not found (#5154) 2023-07-08 14:46:32 +02:00
chrchr-github 49b79b7674
Extend duplInheritedMember check to functions (#5226) 2023-07-08 12:05:19 +02:00
chrchr-github 218650dc85
Fix #11820 FP duplicateExpression with double negation (#5227) 2023-07-07 23:30:59 +02:00
chrchr-github d6d3c7b3fc
Fix #11139, #11817 FP unreadVariable (#5221) 2023-07-07 20:18:15 +02:00
chrchr-github e73183a182
Fix FP uselessOverride with shadowed member functions (#5225)
We should probably use `getDuplInheritedMemberFunctionsRecursive()` as
part of the `duplInheritedMember` check.
2023-07-07 20:17:58 +02:00
chrchr-github cc38ef4168
Fix #11818 FP constParameterReference / #11819 FP stlcstrConstructor / #11814 FP unknownMacro (#5224) 2023-07-07 15:54:07 +02:00
chrchr-github c738627d15
Fix uselessOverride FPs (#5223) 2023-07-07 13:18:00 +02:00
chrchr-github fa03f49d2b
Fix #11810 nullptr deref in compilePrecedence2() (II) (#5222) 2023-07-07 10:42:11 +02:00
chrchr-github dde45455bf
uselessOverride: Detect code duplication in overriding function (#5219) 2023-07-05 22:58:01 +02:00
chrchr-github ee5cf0f141
Fix #11810 nullptr deref in compilePrecedence2() (#5218) 2023-07-05 22:34:25 +02:00
chrchr-github db49687ae5
Fix getOverriddenFunction(), add test (#5213) 2023-07-01 17:23:26 +02:00
chrchr-github b99931c59c
Fix #11808 FP uselessOverride - grandchildren calling grandfather (#5212) 2023-07-01 14:11:28 +02:00
Daniel Marjamäki 96955ccfe9
Tokenizer: detect unknown macro 'if (x) MACRO }' (#5209) 2023-07-01 13:17:41 +02:00
Paul Fultz II 59a8944e30
Fix 11656: FP: containerOutOfBounds std::array (#5210) 2023-07-01 09:43:57 +02:00
chrchr-github 6d9fa6f10a
Fix #11803 FP uselessOverride - overloaded virtual member function (#5211) 2023-06-30 15:21:08 +02:00
chrchr-github e9feeef81d
Fix FPs: uselessOverride (#5208) 2023-06-29 20:46:12 +02:00
chrchr-github a40e5817bf
Fix #11757 Detect useless overriding functions (#5155) 2023-06-29 07:43:35 +02:00
chrchr-github 818ebb8d7e
Fix autovarInvalidDeallocation regression (#5203) 2023-06-29 07:42:53 +02:00
Daniel Marjamäki 55af68aaf7
Update type for Settings::checksMaxTime. (#5205)
It's a time offset not a size. It should not have value SIZE_MAX that
makes it ineffective (overflow in calculation of stop time).
2023-06-28 19:52:33 +02:00
chrchr-github 4f71bbe986
Detect lambda with template argument (#5202) 2023-06-27 16:19:12 +02:00
chrchr-github 0a72cd3b72
Fix #11795 debug: simplifyUsing: unmatched body end (#5198) 2023-06-27 15:45:25 +02:00
chrchr-github e063656173
checkLibraryCheckType: handle global scope operator / Fix FN unreadVariable (#5199) 2023-06-27 14:28:14 +02:00
Paul Fultz II 63b7e6a283
Fix 11088: False positive: Array index out of bounds (function pointer parameter is array) (#5200) 2023-06-27 10:44:11 +02:00
chrchr-github a0c4e20e2d
Add tests for #10587, #11539 (#5197) 2023-06-26 13:37:33 +02:00