Commit Graph

12672 Commits

Author SHA1 Message Date
Oliver Stöneberg 3103736c51
refs #11928 / refs #10045 / fixes #11794 - generate `limits.h`/`climits` defines from platform (#5414) 2023-10-21 17:21:12 +02:00
chrchr-github 26ba29c303
Fix #12086 FN passedByValue with index operator and namespaced function call (#5574) 2023-10-21 12:41:39 +02:00
chrchr-github f4d18a8d1e
#12077 FP constStatement with ctor in namespace (#5572) 2023-10-21 12:12:56 +02:00
Oliver Stöneberg 27bd972832
test/CMakeLists.txt: updated the test fixture costs (#5565) 2023-10-21 09:15:22 +02:00
Oliver Stöneberg 7086ffaa1b
fixed #12045 - print error when using an option which has not been compiled in instead of treating it as non-existent or a no-op (#5508)
Also disabled more internal code around those options and did some
cleanups.
2023-10-21 09:12:59 +02:00
chrchr-github 41bd28c0b3
Fix #12087 Library: add Container::Action::FIND_CONST (#5579) 2023-10-20 21:22:06 +02:00
chrchr-github b61feaf77f
Fix syntaxError with const lambda (refs #11275) (#5571) 2023-10-20 15:32:46 +02:00
chrchr-github 0070a78101
Fix #12088 FP constStatement with delete in loop increment (#5576) 2023-10-20 10:25:31 +02:00
Daniel Marjamäki 17ea101e7b
Fix #12081 (Tokenizer::simplifyTypedef: Handle volatile structs better) (#5577) 2023-10-19 21:02:03 +02:00
Paul Fultz II f2c8153231
Set the lower and upper bounds for variable that are only incremented or decremented (#5523)
Also, changed `isExpressionChanged` and `isThisChanged` to return the
token that is being modified and renamed the functions to
`findExpressionChanged` and `findThisChanged`.
2023-10-19 18:42:52 +02:00
chrchr-github 7c3ae68e4d
Fix #11893 FP constStatement unused variable (#5567) 2023-10-19 10:51:16 +02:00
Paul Fultz II e1a120e6b0
Partial fix for 12031: False positive: uninitialized variable (#5573) 2023-10-18 23:49:22 +02:00
chrchr-github 09f426d980
Fix #12082 FP uninitvar for assignment to array member in conditional (#5570) 2023-10-18 18:50:49 +02:00
chrchr-github 285ef96b5b
Report unknownMacro in string concatenation (refs #11378) (#5558) 2023-10-18 18:46:47 +02:00
chrchr-github b60b374f9c
Fix internalASTError with decltype (regression, refs #11378) (#5564) 2023-10-18 12:17:20 +02:00
Oliver Stöneberg b40d36a09e
fixed #12063 - use less heavy code in executor tests (#5566)
The allocation invokes some heavy ValueFlow computations. We just want
to generate an unconditional error from the analysis so use some lighter
code which does the same.

`TestThreadExecutorFiles::deadlock_with_many_errors`

Before:
```
real    0m23.517s
user    0m33.453s
sys     0m2.297s
```

After:
```
real    0m5.051s
user    0m6.234s
sys     0m0.422s
```
2023-10-17 20:24:37 +02:00
Oliver Stöneberg 85fe627c68
fixed some typos (#5562) 2023-10-17 18:32:07 +02:00
Daniel Marjamäki dd76504f82
Fixed #3537 (Allow inline suppression comments for macros) (#5559) 2023-10-16 19:43:15 +02:00
Oliver Stöneberg 3811d01498
fixed "Redundant dereferencing and tasking address expression" Rider warnings (#5563) 2023-10-16 14:09:03 +02:00
Oliver Stöneberg 5e89eb05a6
iwyu.yml: made `include-what-you-use` output more verbose / cleaned up includes (#5540) 2023-10-16 12:57:49 +02:00
chrchr-github 93297727ef
Fix internalASTError with decltype (refs #11378) (#5553) 2023-10-15 20:47:01 +02:00
orbitcowboy 16c5a11786
posix.cfg: Warn in case the return value of localtime() is ignored. (#5555) 2023-10-14 16:59:42 +02:00
chrchr-github 903df84ddc
Fix #12072 FN constStatement with enum (#5554) 2023-10-13 21:40:47 +02:00
Daniel Marjamäki ec15772381
Refactoring suppressions code. (#5550) 2023-10-13 19:57:08 +02:00
chrchr-github efd488b519
Partial fix for #12062 FN: memleak (#5548) 2023-10-13 18:47:06 +02:00
chrchr-github f56677a99d
Fix #11857 FP constParameterReference with std::map (#5551) 2023-10-13 18:08:40 +02:00
Oliver Stöneberg ebb877adcc
gui/platforms.h: renamed `Platform` to `PlatformData` / Platform: removed unnecessary `cppcheck` namespace (#5545) 2023-10-13 16:02:04 +02:00
Johan Bertrand 44ab976451
Inline suppression for block of code or whole file (#5402)
Added new suppress comments:
- `cppcheck-suppress-begin` and `cppcheck-suppress-end` to remove blocks
of suppression
- `cppcheck-suppress-file` to remove suppression at file level

The suppressions do not interfere with each others. For example, all the
suppressions are matched in the following code:

```c
// cppcheck-suppress-file uninitvar
void f() {
    int a;
    // cppcheck-suppress-begin uninitvar
    // cppcheck-suppress uninitvar
    a++;
    // cppcheck-suppress-end uninitvar
}
```

Tickets:
https://trac.cppcheck.net/ticket/11902
https://trac.cppcheck.net/ticket/8528
2023-10-13 12:45:13 +02:00
chrchr-github 8ef4da475a
Add test for #2456, #12011 (#5544) 2023-10-12 16:27:10 +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 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