chrchr-github
192c30ab1d
Fix crash in arraySize() ( #4556 )
...
* Fix #11355 FN: arrayIndexOutOfBounds
* Fix
* Fix crash in arraySize()
2022-10-19 19:19:01 +02:00
gerboengels
6a01fa9b70
#11134 Fix broken AST with (designated) initializers ( #4550 )
...
* Make control flow a bit easier, and more similar to previous code
Made similar to around line 790
* In a cpp11init, always parse only the corresponding } (#11134 )
- _always_, because in some cases this was omitted (around line 790) or too strict (around line 860)
- _only_, and not following tokens which happen to be } as well (around line 1030)
* Fix unit tests: AST was incorrect, now is fixed
auto var{ {{},{}}, {} };
Old AST:
```
{
|-var
`-{
`-,
|-,
| |-{
| `-{
`-{
```
New AST:
```
{
|-var
`-,
|-{
| `-,
| | |-{
| | `-{
`-{
```
Compare the same example, but with `X{}` instead of just `{}`:
`auto var{ a{b{},c{}}, d{} };`
```
{
|-var
`-,
|-{
| |-a
| `-,
| | |-{
| | | `-b
| | `-{
| | | `-c
`-{
`-d
```
This structure is similar to that of the new AST, not the old AST
* Fix unit tests: another AST was incorrect, now is fixed
Code: `auto var{{1,a::b{2,3}}, {4,a::b{5,6}}};`
Old AST:
```
{
|-var
`-{
`-,
|-,
| |-1 'signed int'
| `-{
| | |-::
| | | |-a
| | | `-b
| | `-,
| | | |-2 'signed int'
| | | `-3 'signed int'
`-{
`-,
|-4 'signed int'
`-{
|-::
| |-a
| `-b
`-,
|-5 'signed int'
`-6 'signed int'
```
New AST:
```
{
|-var
`-,
|-{
| `-,
| | |-1 'signed int'
| | `-{
| | | |-::
| | | | |-a
| | | | `-b
| | | `-,
| | | | |-2 'signed int'
| | | | `-3 'signed int'
`-{
`-,
|-4 'signed int'
`-{
|-::
| |-a
| `-b
`-,
|-5 'signed int'
`-6 'signed int'
```
* Fix unit tests: missing ; after class, resulting in incorrectly being marked as cpp11init
Because of the missing `;` after the class declaration, it was marked as a cpp11init block.
Which it isn't, and which now throws an exception
* Fix cpp11init to let unit tests pass again
The following unit tests failed on the newly introduced throws, because the code for these tests incorrectly marked some tokens as cpp11init:
TestVarID::varid_cpp11initialization
TestTokenizer::checkRefQualifiers
* Fix typo
* Improve check for void trailing return type
Observation: the only function body _not_ containing a semicolon, is a void function: something like
auto make_zero(ini& i) -> void {
while(--i > 0) {}
}
Non-void function? Then it must return a value, and thus contain a semicolon, which is checked for a few lines later.
* Fix cpp11init with templated trailing return type
In the following example, vector was marked as cpp11init due to the mismatch of `%any% {`
auto f() -> std::vector<int> { return {}; }
I made the assumption that whenever "%any% {" matches, endtok must be set too.
If this assumtion doesn't hold (so "%any% {" matches, but endtok == nullptr), then the for-loop would search all the way to the end of stream. Which I guess was not the intention.
* Remove comments
Co-authored-by: Gerbo Engels <gerbo.engels@ortec-finance.com>
2022-10-19 07:25:15 +02:00
chrchr-github
5a8e55c083
Fix #11355 FN: arrayIndexOutOfBounds ( #4555 )
...
* Fix #11355 FN: arrayIndexOutOfBounds
* Fix
2022-10-18 07:24:24 +02:00
chrchr-github
c6c339a3e7
Fix #11351 Assert failure in templatesimplifier.cpp ( #4552 )
2022-10-16 19:34:25 +02:00
gerboengels
221873e69f
Fix #11319 ( #4549 )
...
In this example:
```
//template<std::same_as<int> T> // <= works
template<same_as<int> T> // <= didn't work
void f()
{}
```
the changed line used to match to `< same_as <`, therefore skip creating links.
The `%op% %name% <` already feels a bit like a workaround. So adding the condition that $op$ shouldn't be a comparison operator, but part of the template, seemed reasonable to me
Co-authored-by: Gerbo Engels <gerbo.engels@ortec-finance.com>
2022-10-16 19:33:44 +02:00
Oliver Stöneberg
2ac9fbc1bf
include all (internal non-generated) headers in clang-tidy checks ( #4100 )
2022-10-16 13:51:17 +02:00
chrchr-github
3273e51fd5
Fix #10412 FN useStlAlgorithm with iterators ( #4157 )
2022-10-16 13:46:26 +02:00
chrchr-github
6c24d2b865
Fix #11321 FP uninitvar for in-class member initialization ( #4547 )
2022-10-14 19:48:27 +02:00
Daniel Marjamäki
b8b6be48d9
Fixed #9926 (False positive assertWithSideEffects, calling method that has no side effects)
2022-10-12 07:51:50 +02:00
Daniel Marjamäki
2a81388c95
Fixed #11102 (False positive: unreadVariable when union in derived struct is used)
2022-10-11 20:47:07 +02:00
Daniel Marjamäki
584a428025
Fixed #10831 ("Analysis failed (lambda not recognized)" with lamba default parameter in lambda signature)
2022-10-10 21:05:48 +02:00
gerboengels
ed06e29f7a
Fix defaulted and deleted functions ( #4540 )
...
* Fix 9392, but for destructors: out-of-line defaulted destructors skipped everything after
Context:
```
struct S {
~S();
};
S::~S() = default;
void g() {
int j;
++j;
}
```
Everything after `S::~S() = default;` was skipped, so the uninitialized variables in g() weren't found.
Out-of-line destructors are useful e.g. when you have a forward declared unique_ptr in the .h,
and `= default` the destructor in the .cpp, so only the cpp needs to know the header for destructing
your unique_ptr (like in the pImpl-idiom)
* Fix unit test, by correctly fixing 10789
Previous commit broke this test, but also provided the tools for a cleaner fix
* Document current behaviour
* Rewrite control flow
* Fix deleted functions, which skipped everything after
`a::b f() = delete` triggered the final else in SymbolDatabase::addNewFunction,
which sets tok to nullptr, effectively skipping to the end of the stream.
* Remove troublesome nullptr, which skips every analysis afterwards
It was introduced in 0746c241
to fix a memory leak.
But setting tok to nullptr, effectively skipping to the end, seems not needed.
Previous commits fixes prevented some cases where you could enter the `else`.
This commit is more of a fall back.
* fixup! Fix deleted functions, which skipped everything after
`a::b f() = delete` triggered the final else in SymbolDatabase::addNewFunction,
which sets tok to nullptr, effectively skipping to the end of the stream.
* fixup! Fix deleted functions, which skipped everything after
`a::b f() = delete` triggered the final else in SymbolDatabase::addNewFunction,
which sets tok to nullptr, effectively skipping to the end of the stream.
* Make it heard when encountering unexpected syntax/tokens
Co-authored-by: Gerbo Engels <gerbo.engels@ortec-finance.com>
2022-10-10 20:17:33 +02:00
Daniel Marjamäki
65cd6ea7b4
Clarify knownConditionTrueFalse warnings
2022-10-10 13:45:30 +02:00
Paul Fultz II
bd22ea565f
Use return instead of condition for alwaysTrueFalse check ( #4446 )
2022-10-09 21:03:48 +02:00
Oliver Stöneberg
fa7e08a29f
optimized `CheckOther::checkDuplicateBranch()` a bit ( #4542 )
2022-10-09 20:48:54 +02:00
Oliver Stöneberg
d1bfae989e
fixed handling of incomplete char/string literals in `isPrefixStringCharLiteral()` - also optimized it a bit ( #4541 )
...
* fixed handling of incomplete char/string literals in `isPrefixStringCharLiteral()` - also optimized it a bit / added tests for `isStringLiteral()` and `isCharLiteral()`
* utils.h: early out in `isStringCharLiteral()` to avoid the loop
2022-10-09 11:19:19 +02:00
Oliver Stöneberg
9f7a725983
added environment variable `UNUSEDFUNCTION_ONLY` to make sure only the `unusedFunction` check is being executed ( #4362 )
2022-10-06 20:54:24 +02:00
Oliver Stöneberg
7ead32f96e
various optimizations ( #4535 )
...
* avoid potentially duplicated `strTolower()` call in `Path::getFilenameExtensionInLowerCase()`
* avoid unnecessary copies
* use `unordered_*` containers for faster lookups
* symboldatabase.cpp: do not perform call in `checkReturns()` until needed
* astutils.cpp: do not perform calls in `isVariableChangedByFunctionCall()` until necessary
* tokenize.cpp: small `hasIfDef()` optimization
* use `unordered_map` for `CheckUnusedFunctions::FunctionUsage::mFunctions` / adjusted test case
2022-10-06 20:12:07 +02:00
Daniel Marjamäki
ca32cf11ba
Fix handling of --performance-valueflow-max-time=T
2022-10-04 20:01:19 +02:00
Daniel Marjamäki
8686997292
Add experimental option --performance-valueflow-max-time=T
2022-10-04 14:02:55 +02:00
Oliver Stöneberg
ee124cd097
modernized `erase()` calls ( #4530 )
2022-10-02 07:13:31 +02: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
chrchr-github
586c29c772
Partial fix for #9157 False negative: stlOutOfBounds, cast ( #4527 )
...
* Fix leakNoVarFunctionCall FP
* Partial fix for #9157 False negative: stlOutOfBounds, cast
2022-09-30 14:43:21 +02:00
chrchr-github
4d13266e99
Fix #10083 FN unusedScopedObject: temporary lock 'std::lock_guard<std::mutex>(m)' ( #4522 )
...
* Fix #10083 FN unusedScopedObject: temporary lock 'std::lock_guard<std::mutex>(m)'
* Format
* Fix cppcheck-cfg.rng
* Format
2022-09-30 07:25:33 +02:00
Oliver Stöneberg
3dfdb409c6
fixed and enabled some Clang compiler warnings ( #4517 )
2022-09-29 21:59:02 +02:00
chrchr-github
6142ba542a
Fix leakNoVarFunctionCall FP ( #4523 )
2022-09-29 21:58:11 +02:00
chrchr-github
260a757791
Fix #10839 internalAstError with function returning a function ( #4514 )
2022-09-29 21:56:26 +02:00
Oliver Stöneberg
083efe6361
astutils.h: use pre-sized SmallVector in visitAstNodes() ( #3919 )
2022-09-29 21:52:42 +02:00
Oliver Stöneberg
eeb6db05f1
avoid some unnecessary object creations and copies ( #4493 )
2022-09-29 21:47:17 +02:00
Oliver Stöneberg
0481edf9c3
return `SmallVector` from `followAllReferences()` ( #3925 )
2022-09-29 21:41:32 +02:00
chrchr-github
b8b6b41833
Fix #10802 Broken AST lambda inside for loop ( #4520 )
...
* Fix #10802 Broken AST lambda inside for loop
* Add some boost and wxwidget defines (on behalf of "david ingamells")
2022-09-29 13:29:50 +02:00
chrchr-github
56e2af5dec
Fix #9653 FP leakReturnValNotUsed although (void) is specified ( #4431 )
2022-09-27 20:09:04 +02:00
Oliver Stöneberg
d6f1d7bb23
replaced `static const`/fixed `std::vector` containers with `std::array` ( #4440 )
2022-09-27 20:06:15 +02:00
Oliver Stöneberg
10426f6707
cppcheck.cpp: only call `getFileInfo()` if necessary ( #4510 )
2022-09-27 20:04:35 +02:00
Oliver Stöneberg
b9e07e918e
enabled and fixed `readability-named-parameter` clang-tidy warnings ( #4487 )
2022-09-27 20:03:25 +02:00
chrchr-github
cab4997b0b
Fix #11039 Empty AST with delete new / #11327 FP leakReturnValNotUsed with new and offset ( #4513 )
...
* Fix internalAstError with new
* Format
* nullptr check
* Add test for #11039
* Fix #11039 Empty AST with delete new / #11327 FP leakReturnValNotUsed with new and offset
2022-09-27 18:12:58 +02:00
Maksim Derbasov
c8b96c3a20
Typos fix ( #4509 )
2022-09-27 06:48:06 +02:00
chrchr-github
0f79f8bd70
Fix internalAstError with new ( #4508 )
...
* Fix internalAstError with new
* Format
* nullptr check
2022-09-26 22:05:58 +02:00
chrchr-github
64f3f85804
Fix #11332 Function::addArguments found argument 'b' with varid 0 wit… ( #4506 )
...
* Fix #11332 Function::addArguments found argument 'b' with varid 0 with lambda parameter
* Fix varid0 warning
2022-09-26 18:21:21 +02:00
Paul Fultz II
fc39a4d1bb
Fix 11171: False positive: missing return statement when std::enable_if_t is used ( #4504 )
...
* Fix 11171: False positive: missing return statement when std::enable_if_t is used
* Format
* Return false
* Workaround bug in cppcheck
2022-09-26 18:20:42 +02:00
Oliver Stöneberg
657d9143f7
cleaned up includes based on include-what-you-use ( #4502 )
...
* iwyu.yml: include internal check sources
* cleaned up includes based on include-what-you-use
2022-09-25 09:20:34 +02:00
Leila F. Rahman
70c844ddfb
Fix the release function in the ValuePtr class ( #4490 )
2022-09-24 13:25:06 +02:00
chrchr-github
2808fc615e
Fix #10057 "statement without effect" / #4779 FN unusedScopedObject does not work for classes in different namespace ( #4500 )
...
* Partial fix for #10057 unused variable without assignment not detected
* Add test for #9672
* Fix #4779 FN unusedScopedObject does not work for classes in different namespace
* Merge
* Fix #10057 "statement without effect" (unused variable without assignment) not detected
* Format
2022-09-24 12:49:37 +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
e8b9cd64fc
refs #10663 - only match start pattern in `Library::detectContainerInternal()` if necessary ( #4499 )
2022-09-23 20:19:56 +02:00
chrchr-github
d608bec414
Fix FP with std::array ( #4497 )
...
* Fix #1655 wrong usage of std::string in memcpy
* Fix memsetClass FP
* Fix #8619 FN memset on container containing structs with containers
* Token::Match
* Use AST
* simpleMatch
* Fix FP with std::array
* simpleMatch
2022-09-23 20:18:49 +02:00
chrchr-github
0bb82b70d9
Fix #11328 FN functionStatic, functionConst with this ( #4496 )
...
* Fix #11328 FN functionStatic, functionConst with this
* Fix FP
2022-09-23 08:46:31 +02:00
Jim Kuhn
f27fbdd8ab
Fix sense of test (.analyzerinfo files get placed in wrong directory) ( #4486 )
...
* Fix sense of test (.analyzerinfo files get placed in wrong directory)
* Update testanalyzerinformation.cpp
style (tabs -> spaces)
2022-09-21 17:38:23 +02:00
chrchr-github
3b07661fd3
Fix #11293 debug: CheckClass::isMemberVar found used member variable 'x' with varid 0 ( #4489 )
2022-09-21 17:35:10 +02:00
chrchr-github
2aca275e0c
Fix #8619 FN memset on container containing structs with containers ( #4491 )
...
* Fix #1655 wrong usage of std::string in memcpy
* Fix memsetClass FP
* Fix #8619 FN memset on container containing structs with containers
* Token::Match
* Use AST
* simpleMatch
2022-09-21 17:33:48 +02:00
chrchr-github
3644d79162
Fix duplicateConditionalAssign FP ( #4484 )
...
* Fix #9406 FN redundant assignment of Boolean variable
* Fix warning, refactor
* Update testcondition.cpp
* Fix duplicateConditionalAssign FP
* Format
2022-09-20 21:57:27 +02:00
chrchr-github
dcb332acb0
Fix #9406 FN redundant assignment of Boolean variable ( #4482 )
...
* Fix #9406 FN redundant assignment of Boolean variable
* Fix warning, refactor
* Update testcondition.cpp
2022-09-20 07:30:12 +02:00
chrchr-github
f274d499a1
Fix #11171 FP missing return statement when std::enable_if_t is used ( #4480 )
...
* Fix #11171 FP missing return statement when std::enable_if_t is used
* Add check
2022-09-19 12:47:58 +02:00
Daniel Marjamäki
8275f07692
dump: Add Token::isCast attribute
2022-09-18 12:42:58 +02:00
Paul Fultz II
09944c0b7e
Fix 11298: FP danglingTemporaryLifetime when constructing from const char* ( #4479 )
...
* Fix 11298: FP danglingTemporaryLifetime when constructing from const char*
* Format
2022-09-18 08:30:58 +02:00
Paul Fultz II
de7d02293f
Fix 11308: FP accessMoved with virtual function ( #4478 )
...
* Fix 11308: FP accessMoved with virtual function
* Format
2022-09-18 08:30:06 +02:00
Paul Fultz II
d34de745c0
Fix 11306: FP knownConditionTrueFalse with strlen() ( #4477 )
...
* Fix 11306: FP knownConditionTrueFalse with strlen()
* Add another test
2022-09-18 08:29:10 +02:00
chrchr-github
cb6f04a16c
Fix #11315 FP zerodivcond from enum definition / #11310 FP unassignedVariable with static variable ( #4476 )
...
* Fix #11315 FP zerodivcond from enum definition
* Simplify Boolean expression
* Fix #11310 FP unassignedVariable with static variable
2022-09-17 18:50:07 +02:00
Sergei Trofimovich
3b840e7ff1
lib/sourcelocation.h: add missing <cstdint> include ( #4474 )
...
Without the change build on upcoming gcc-13 fails as:
In file included from lib/symboldatabase.h:28,
from lib/astutils.h:36,
from test/testastutils.cpp:20:
lib/sourcelocation.h:52:10: error: 'uint_least32_t' in namespace 'std' does not name a type
52 | std::uint_least32_t m_line = 0;
| ^~~~~~~~~~~~~~
2022-09-16 21:36:37 +02:00
Oliver Stöneberg
897826006e
mitigated some clang-tidy warnings in headers ( #4472 )
...
* erroritem.h: avoid `performance-no-int-to-ptr` clang-tidy warning
* suppress `readability-inconsistent-declaration-parameter-name` clang-tidy warnings for Qt signals
* tokenlist.h: mitigated `readability-make-member-function-const` clang-tidy warnings
* fixed `modernize-use-override` clang-tidy warnings in headers
* fixed `modernize-pass-by-value` clang-tidy warnings in headers
* tokenize.cpp: avoid unnecessary copy
2022-09-16 18:59:15 +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
chrchr-github
45ccc9ba1e
Fix ctunullpointer FP ( #4471 )
2022-09-16 12:11:34 +02:00
Oliver Stöneberg
b3ec225480
iwyu.yml: use `debian:unstable` to always get latest include-what-you-use / cleaned up includes ( #4466 )
...
* iwyu.yml: use debian:unstable to always get latest include-what-you-use
* cleaned up includes based on include-what-you-use
* mitigated include-what-you-use false positives
2022-09-16 07:15:49 +02:00
chrchr-github
c9ade33298
Fix memsetClass FP ( #4465 )
2022-09-15 20:20:49 +02:00
Daniel Marjamäki
f1aa9eb48f
dump: add externLang attribute for tokens
2022-09-15 19:57:42 +02:00
chrchr-github
d1386a842a
Fix #11301 debug: constStatementError not handled. ( #4463 )
...
* Fix #11301 debug: constStatementError not handled.
* Use function
2022-09-14 23:57:02 +02:00
chrchr-github
266174ddc4
Fix #10993 danglingTemporaryLifetime reported in two different locati… ( #4462 )
...
* Fix #10993 danglingTemporaryLifetime reported in two different locations for std::string_view usage
* Missing include
* Add test
2022-09-14 07:28:04 +02:00
chrchr-github
07caf17eb3
Fix #1655 wrong usage of std::string in memcpy ( #4460 )
2022-09-13 15:14:25 +02:00
chrchr-github
e904f7341e
Fix ValueFlow crash ( #4461 )
2022-09-13 12:25:15 +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
Oliver Stöneberg
76d1b9f31a
avoid unnecessary copies with `emplace_back()` ( #4450 )
...
* avoid unnecessary copies with `emplace_back()`
* cmdlineparser.cpp: suppress `accessMoved` selfcheck false positives
2022-09-10 11:25:15 +02:00
Paul Fultz II
53820515c9
Set valueflow for container elements ( #4455 )
...
* Track elements to containers
* Format
* Handle other access methods
* Format
2022-09-10 09:26:44 +02:00
Oliver Stöneberg
433293b9ab
added missing version bumps to 2.10 ( #4420 )
2022-09-09 21:02:04 +02:00
Paul Fultz II
117a753b10
Partial fix 11154: FN: knownConditionTrueFalse ( #4453 )
...
* Partial fix 11154: FN: knownConditionTrueFalse
* Formay
* Add more tests
* FOrmat
* Fix FP
* Add test
* Check for side effects
* Format
* Update tests
* Format
2022-09-08 22:08:38 +02:00
Oliver Stöneberg
dbc05da356
fixed some clang-tidy warnings ( #4435 )
2022-09-08 20:01:41 +02:00
Paul Fultz II
7c986fbef1
Fix 11203: false positive: knownConditionTrueFalse 'always false' when comparing integer with floating-point ( #4350 )
2022-09-08 19:59:02 +02:00
Paul Fultz II
f83b8dd385
Fix 11194: FN: knownConditionTrueFalse ( #4452 )
...
* Fix 11194: FN: knownConditionTrueFalse
* Format
2022-09-08 18:51:44 +02:00
Daniel Marjamäki
92845295b8
Fix broken CI caused by my qt fix
2022-09-08 11:12:38 +02:00
Oliver Stöneberg
d46ea7ba86
avoid unnecessary copies with `push_back()` and `push_front()` ( #4451 )
2022-09-08 09:21:35 +02:00
Daniel Marjamäki
2e8d855b35
Tokenizer: Skip qt simplification if qt library is not loaded
2022-09-08 07:47:58 +02:00
Daniel Marjamäki
b99474fe13
Tokenizer: Remove redundant setVarId call
2022-09-08 07:46:19 +02:00
Oliver Stöneberg
847391ea2d
some minor optimizations ( #4449 )
...
* cppcheck.cpp: reduced scope of a variable
* cppcheck.cpp: removed unnecessary severity checks
* cppcheck.cpp: avoid unnecessary copy
* templatesimplifier.cpp: perform early exit in loop in `expandTemplate()`
2022-09-07 19:19:04 +02:00
Paul Fultz II
32d96104d6
Fix 6370: ValueFlow: array element with known value ( #4447 )
...
* Fix 6370: ValueFlow: array element with known value
* Format
* Move comment
2022-09-07 19:16:07 +02:00
Paul Fultz II
6543b429c5
Fix 11285: FN: zerodiv ( #4448 )
...
* Fix 11285: FN: zerodiv
* Format
2022-09-07 19:15:37 +02:00
chrchr-github
6960332f8a
Fix #11294 FP arrayIndexOutOfBoundsCond with extra parentheses ( #4442 )
2022-09-06 21:21:06 +02:00
Oliver Stöneberg
b3762cd76a
actually perform system tinyxml2 build on macos / fixed system tinyxml2 include ( #4445 )
...
* lib/CMakeLists.txt: removed unnecessary external include
* look up tinyxml2 include dir when using system one and specify it
* lib/CMakeLists.txt: do not treat bundled headers as system ones
* CI-unixish.yml: actually perform system tinyxml2 build on macos
2022-09-06 18:30:59 +02:00
Paul Fultz II
2d37a77281
Fix 11296: FN: knownConditionTrueFalse ( a !=0 && b != 0 && a == 0) ( #4444 )
2022-09-06 07:31:48 +02:00
Paul Fultz II
016793f258
Fix 11295: Regression FP: knownConditionTrueFalse ( #4443 )
2022-09-06 07:31:38 +02:00
Oliver Stöneberg
436b8bd3f1
optimized `isSameConstantValue()` a bit ( #4441 )
2022-09-05 21:36:26 +02:00
chrchr-github
31118fdce5
Fix noreturn FP with while() ( #4429 )
...
* Fix checkLibraryFunction FPs
* Fix FP with fclose()
* Format
* Fix FP with reinterpret_cast
* Fix noreturn FP with while()
2022-09-04 10:26:31 +02:00
Paul Fultz II
6ce5c24f21
Refactor knownConditionTrueFalse check and isUsedAsBool function ( #4432 )
...
* Refactor knownConditionTrueFalse check and isUsedAsBool function
* Format1
* Format
* Skip assign
2022-09-04 10:24:45 +02:00
Maksim Derbasov
f93b588603
New check: use memcpy/memset instead of loop ( #4257 )
2022-09-03 23:29:06 +02:00
Daniel Marjamäki
9306c6f329
dump: Add Function::isAttributeNoreturn info
2022-09-03 12:09:20 +02:00
chrchr-github
cf52ee098a
Fix checkLibraryFunction FPs ( #4423 )
...
* Fix checkLibraryFunction FPs
* Fix FP with fclose()
* Format
* Fix FP with reinterpret_cast
2022-09-02 07:51:10 +02:00
chrchr-github
79daad8ff4
Fix #11020 FP arrayIndexOutOfBounds if string literals are assigned conditionally ( #4428 )
2022-09-01 22:59:46 +02:00
Daniel Marjamäki
4779f0e172
TemplateSimplifier: Fixed instantiation when template parameters are A<..>, B<..>
2022-09-01 20:24:01 +02:00
chrchr-github
5804cc44e7
Fix FP bufferAccessOutOfBounds ( #4427 )
...
* Fix FN with buffer size 1
* Fix FP bufferAccessOutOfBounds
2022-08-31 19:31:37 +02:00
chrchr-github
3925a27182
Fix FP knowConditionTrueFalse ( #4419 )
...
* Fix #10426 FN (style) Condition 's.empty()' is always false
* Fix test
* Fix FP knowConditionTrueFalse
* Check for casts
* Fix FP for user-defined functions
* Adjust condition detection
* Tweaks
2022-08-30 18:08:24 +02:00
chrchr-github
9ab4f9976d
Fix #10426 FN (style) Condition 's.empty()' is always false ( #4414 )
...
* Fix #10426 FN (style) Condition 's.empty()' is always false
* Fix test
2022-08-29 12:25:10 +02:00
chrchr-github
1e14e360cb
Fix #8295 FN (error) Buffer is accessed out of bounds (wcpncpy, wcsncpy) ( #4412 )
...
* Fix #8295 FN (error) Buffer is accessed out of bounds (wcpncpy, wcsncpy)
* Fix cfg, validation
* Fix validation
2022-08-29 12:24:58 +02:00
chrchr-github
df704361f6
Fix FN with buffer size 1 ( #4410 )
2022-08-29 12:24:44 +02:00
Daniel Marjamäki
a400c94230
Update Copyrights
2022-08-28 14:22:12 +02:00
Daniel Marjamäki
5e0fc24bb7
Fixed #11232 (Syntax Error: AST broken, binary operator '!=' doesn't have two operands)
2022-08-27 18:02:19 +02:00
chrchr-github
7156afe003
Fix #5140 FN (error) buffer access out of bounds - known argument ( #4402 )
...
* Fix #5140 FN (error) buffer access out of bounds - known argument const char* argv[]
* Format
2022-08-26 17:27:54 +02:00
chrchr-github
917496a844
Fix #5678 FN destructor with no definition hide mismatching alloc/dealloc ( #4401 )
...
* Fix #5678 FN destructor with no definition hide mismatching allocation / deallocation
* Format
* Fix test
* Format
2022-08-25 22:52:51 +02:00
chrchr-github
456c6b410e
Fix #2304 FN known strcpy parameter ( #4396 )
...
* Fix #2304 FN known strcpy parameter
* Parentheses
* Format
2022-08-24 21:23:45 +02:00
Oliver Stöneberg
467648bec6
fixed #11249 (potential hang with -j and --showtime= when using threads) - synchronized access to `TimerResults::mResults` / added TSAN to CI ( #4355 )
2022-08-23 20:30:45 +02:00
chrchr-github
13e8d5220c
Fix another c_strParam regression ( #4394 )
2022-08-23 20:26:36 +02:00
Daniel Marjamäki
a2454ecbca
cli import cppcheck project with premium options
2022-08-23 20:13:03 +02:00
chrchr-github
4be7f689d7
Fix c_strParam regression ( #4393 )
...
* Fix #7515 New check: Not needed c_str() operation
* Comment
* Detect more instances of c_str() misuse
* Fix bad merge
* Check for data() also
* Fix
* Format
* Format
* Fix c_strParam regression
2022-08-23 15:00:27 +02:00
Daniel Marjamäki
5d267000e2
GUI: configuration of premium features
2022-08-22 21:11:28 +02:00
chrchr-github
66fca7ba91
Detect more instances of c_str() misuse ( #4392 )
...
* Fix #7515 New check: Not needed c_str() operation
* Comment
* Detect more instances of c_str() misuse
* Fix bad merge
* Check for data() also
* Fix
* Format
* Format
2022-08-22 14:06:10 +02:00
Oliver Stöneberg
9b4973d711
astutils.cpp: some small optimizations ( #4378 )
2022-08-21 17:39:21 +02:00
Daniel Marjamäki
c820d2ba97
refactoring
2022-08-21 17:33:43 +02:00
PKEuS
d81a758850
LCppC backports: Refactorizations/Optimizations ( #4204 )
2022-08-21 17:21:02 +02:00
Oliver Stöneberg
0e1cd8b2ac
do not do C++ processing for C code in `parsedecl()` ( #4304 )
2022-08-21 17:11:22 +02:00
Oliver Stöneberg
670b872f30
implemented move constructor for `TemplateSimplifier::TokenAndName` ( #4390 )
2022-08-21 17:02:03 +02:00
chrchr-github
d351a97a0f
Fix #8336 FN stlcstrParam ( #4389 )
...
* Fix #7515 New check: Not needed c_str() operation
* Comment
* Fix error messages
* Handle more complex string expressions
* Fix #8336 FN stlcstrParam
* Handle iterators
* Format
* Format
* Parentheses
2022-08-21 13:04:43 +02:00
Oliver Stöneberg
1202efb438
some `--exception-handling` related improvements ( #4368 )
2022-08-20 20:54:31 +02:00
chrchr-github
b04bf7396f
Fix #7515 New check: Not needed c_str() operation ( #4371 )
2022-08-20 20:52:10 +02:00
Oliver Stöneberg
d73a33d17e
avoid redundant `Token::declEndToken()` calls ( #4363 )
2022-08-20 20:50:14 +02:00
Oliver Stöneberg
2afd5f80e7
smallvector.h: bake `reserve()` into the non-boost `SmallVector` implementation ( #4385 )
2022-08-20 20:44:26 +02:00
Oliver Stöneberg
1d95d1908d
refs #10663 - sped up `Library::detectContainerOrIterator()` by iterating the containers only once ( #4380 )
2022-08-20 12:14:55 +02:00
chrchr-github
2ab8de2650
Fix #11145 FP negativeMemoryAllocationSize with possible value ( #4387 )
2022-08-20 07:56:31 +02:00
Oliver Stöneberg
f138df2909
mathlib.h: replaced slow `std::ostringstream` with `std::to_string()` in `MathLib::toString()` ( #4382 )
2022-08-19 20:44:24 +02:00
chrchr-github
80a486dda0
Fix #11167 FP virtual call in destructor even though class is final / Delete 'final' from specializations ( #4383 )
...
* Add 'final' keyword
* Delete 'final' from specializations
* Fix #11167 FP virtual call in destructor even though class is final
* Fix test
2022-08-19 18:26:00 +02:00
Oliver Stöneberg
16f598c409
added missing `sstream` includes ( #4381 )
2022-08-19 10:16:23 +02:00
chrchr-github
1aa259569e
Fix #10138 syntax error : int (operator"" _ii)(unsigned long long v) … ( #4374 )
...
* Fix #10138 syntax error : int (operator"" _ii)(unsigned long long v) { return v; }
* Format
2022-08-18 23:38:45 +02:00
Oliver Stöneberg
e09f5f0db7
refs # 11106 (optimize CheckUnusedVar::checkStructMemberUsage()) - added missing loop breaks ( #4376 )
2022-08-18 23:36:21 +02:00
chrchr-github
6a0c254d1f
Fix #9931 FP zerodiv (daca@home) ( #4379 )
...
* Fix #9931 FP zerodiv (daca@home)
* Format
* Parentheses
* clang-tidy
2022-08-18 20:38:36 +02:00
chrchr-github
4a64e20592
unusedScopedObject: Don't warn for void statements ( #4370 )
...
* Fix unusedScopedObject FPs
* Simplify
* Simplify
* Fix test
* Don't warn for void statements
* Format
2022-08-17 19:45:46 +02:00
Oliver Stöneberg
0f0c4061ff
astutils.cpp: avoid redundant callback invocation in `isExpressionChangedAt()` ( #4369 )
2022-08-17 13:50:39 +02:00
Oliver Stöneberg
5f171b9673
fixed some `modernize-use-emplace` false negatives with `std::stack` / removed `internalStlUsage` check ( #4346 )
2022-08-17 09:50:14 +02:00
chrchr-github
5b4c6c1e73
Fix #11026 FP pointerOutOfBounds with strlen() ( #4366 )
2022-08-17 09:45:07 +02:00
chrchr-github
1a95515e47
Fix unusedScopedObject FPs ( #4364 )
2022-08-17 09:11:23 +02:00
Oliver Stöneberg
98b9f2cbf1
reduced scope of some variables and avoided some copies ( #4328 )
2022-08-16 22:28:39 +02:00
chrchr-github
3dc2c0bd42
Fix #11257 FN constStatement with misused comma ( #4365 )
2022-08-16 22:10:58 +02:00
Oliver Stöneberg
31d704e4bc
cppcheckexecutor.cpp: extracted platform-dependent code into separate files ( #4359 )
2022-08-16 22:03:44 +02:00
Paul Fultz II
72c764b034
Expose exprId to addon ( #4354 )
2022-08-16 22:00:31 +02:00
Oliver Stöneberg
38c7d0a5f8
config.h: implemented `NORETURN` for GCC < 5 ( #4361 )
2022-08-16 06:52:54 +02:00
Oliver Stöneberg
4bf5dcd29f
cleaned up includes based on include-what-you-use ( #4358 )
...
* cleaned up includes based on include-what-you-use
* testlibrary.cpp: no need for `empyString` optimization
2022-08-14 12:44:19 +02:00
Oliver Stöneberg
f7caf7dc93
avoid some unnecessary `std::string()` construction in comparisons ( #4357 )
...
* avoid unnecessary string wrapping
* consistently use `strcmp()`
2022-08-14 12:44:09 +02:00
chrchr-github
afef71f6b6
Partial fix for #10057 unused variable without assignment not detected ( #4348 )
...
* Partial fix for #10057 unused variable without assignment not detected
* Add test for #9672
2022-08-13 08:29:06 +02:00
Oliver Stöneberg
c54b3f4de0
removed leftover bughunting GUI related fields from `ErrorMessage` ( #4351 )
2022-08-13 08:27:52 +02:00
Paul Fultz II
bfd9470600
Fix 11158: FP zerodiv in loop ( #4356 )
...
* Fix 11158: FP zerodiv in loop
* Format
* Add another test
* Format
* Fix FP
* Format
2022-08-13 08:27:20 +02:00
chrchr-github
bdbd84ba98
#11238 : Fix regression ( #4349 )
...
* Fix #11238 FP knownConditionTrueFalse with constexpr?
* Modify isConstVarExpression()
* Use predicate
* Format
* #11238 : Fix regression
2022-08-09 13:13:16 +02:00
chrchr-github
974e34490f
Fix #9282 FP Unused private function ( #4327 )
2022-08-07 20:06:32 +02:00
Oliver Stöneberg
156323c95e
avoid unnecessary copies with `insert()` ( #4323 )
2022-08-07 19:31:16 +02:00
chrchr-github
078a6d7804
Fix #11238 FP knownConditionTrueFalse with constexpr? ( #4341 )
2022-08-07 19:06:19 +02:00
chrchr-github
d5a0dfda00
Fix #11239 checkLibraryCheckType with asm goto() (invalid varid), add test for #8666 ( #4340 )
...
* Add test for #6541 , avoid duplicate warning
* Add test for #5475
* Fix test
* Merge
* Add test for #8666
* Fix #11239 checkLibraryCheckType with asm goto() (invalid varid)
* Format
2022-08-04 21:35:18 +02:00
umanamente
460f63558d
Fixed typo in checkautovariables.cpp: getPointerDepth() ( #4329 )
2022-08-04 07:52:10 +02:00
Paul Fultz II
c0f55a2b85
Fix 11142: FP nullPointer before assignment ( #4319 )
...
* Fix 11142: FP nullPointer before assignment
* Format
* Use simpleMatch
2022-08-03 19:05:07 +02:00
Paul Fultz II
6cb3a79a64
Fix 11147: FP invalidContainer with substr() ( #4333 )
...
* Fix 11147: FP invalidContainer with substr()
* Format
2022-08-03 19:04:44 +02:00
chrchr-github
dd927aab9b
Fix #11237 checkLibraryNoReturn with unassigned object ( #4338 )
...
* Handle float values
* Fix #11237 checkLibraryNoReturn with unassigned object
2022-08-03 19:04:10 +02:00
chrchr-github
a62c3ea90e
Fix #11234 Broken AST with auto**, FP constStatement ( #4339 )
2022-08-03 19:03:38 +02:00
chrchr-github
0eabe0505b
Handle float values ( #4336 )
2022-08-02 22:11:31 +02:00
chrchr-github
71f9a7269f
Add test for #6541 , #5475 , avoid duplicate warning ( #4335 )
...
* Add test for #6541 , avoid duplicate warning
* Add test for #5475
* Fix test
2022-08-02 21:43:18 +02:00
chrchr-github
bc409776e3
Fix #10320 Wrong redundant condition: misleading/wrong message ( #4334 )
...
* Fix #10320 Wrong redundant condition: misleading/wrong message
* Use expressionString()
* Clarify condition
* Update testcondition.cpp
* Trigger CI
2022-08-02 18:31:02 +02:00
chrchr-github
92d569afb6
#11233 FP: knownConditionTrueFalse (wrong message text) ( #4330 )
...
* #11233 FP: knownConditionTrueFalse (wrong message text)
* Format
* Update testcondition.cpp
* Trigger CI
2022-08-02 18:18:46 +02:00
chrchr-github
38fdbe0890
Fix #9716 Syntax error for function-try-block in global scope ( #4305 )
...
* Fix #9716 Syntax error for function-try-block in global scope
* static through instance
* Handle multiple catch blocks
* Add test
* Fix skip logic
* Handle init lists in simplifyFunctionTryCatch()
2022-07-31 14:49:50 +02:00
Oliver Stöneberg
efaaa58896
fixed some `modernize-use-emplace` false negatives and some `bugprone-assignment-in-if-condition` warnings ( #4311 )
2022-07-28 22:53:59 +02:00
Oliver Stöneberg
b65b47d3a8
enabled and fixed `modernize-pass-by-value` clang-tidy warnings ( #4169 )
2022-07-28 22:51:45 +02:00
chrchr-github
304e448749
Fix #8476 --check-library reports missing configuration for static_assert ( #4314 )
2022-07-28 22:47:15 +02:00
chrchr-github
c340b6ae6c
Fix #11191 FP moduloofone with pow() ( #4312 )
2022-07-28 22:11:23 +02:00
Daniel Marjamäki
898ad314ab
badBitmaskCheck: Avoid FP when there is #ifdef in expression
2022-07-28 21:56:05 +02:00
Oliver Stöneberg
d6eb3a8f40
some changes for clang/clang-tidy 15 ( #4310 )
2022-07-26 15:30:53 +02:00
Oliver Stöneberg
887463855b
mitigated most clang-tidy warnings in headers ( #4175 )
2022-07-26 11:10:03 +02:00
chrchr-github
58d7185d64
Fix #10077 FP functionConst when overloaded operator ++ is used ( #4309 )
2022-07-26 08:30:59 +02:00
Oliver Stöneberg
0005be1dbf
some cleanups ( #4308 )
2022-07-26 08:28:55 +02:00
chrchr-github
15f8c71ec3
Fix #9946 FP: unassignedVariable when operator() is called subsequently ( #4303 )
2022-07-24 17:52:14 +02:00
chrchr-github
479533a80a
Rework fix for #11008 ( #4296 )
2022-07-24 12:15:04 +02:00
chrchr-github
1aceded300
Fix #10977 FP noExplicitConstructor with variadic template ( #4301 )
2022-07-24 10:18:19 +02:00
Oliver Stöneberg
b2f15fdbb1
reduced padding in some classes/structs ( #4295 )
2022-07-24 10:17:11 +02:00
Daniel Marjamäki
894975f845
SymbolDatabase: Add Function::access info for methods
2022-07-22 10:37:00 +02:00
chrchr-github
0d72216cca
Fix BufferOverrun TODO ( #4300 )
...
* Fix BufferOverrun TODO
* clang-tidy
2022-07-22 07:24:34 +02:00
chrchr-github
79f091c59a
Fix uselessCallsConstructor TODOs ( #4299 )
...
* Fix uselessCallsConstructor TODOs
* Format
2022-07-21 22:15:16 +02:00
Daniel Marjamäki
a7afaba21d
SymbolDatabase: add BaseInfo::nameTok to dumpfile
2022-07-21 15:57:41 +02:00
chrchr-github
5342e2cd03
Fix #11037 FP knownConditionTrueFalse with dynamic_cast ( #4297 )
2022-07-20 20:48:17 +02:00
Oliver Stöneberg
4316884123
valueflow.cpp: avoid some copies related to `ErrorPath` ( #4160 )
2022-07-20 10:57:49 +02:00
Daniel Marjamäki
ebe8dc2cf3
SymbolDatabase: Extended dumpfiles. Scope: derivedFrom types. Function: overridden function.
2022-07-20 07:24:27 +02:00
chrchr-github
457a0cff87
Fix #11016 FP unusedStructMember when used through iterator (regression) ( #4289 )
...
* Format
* Fix #11016 FP unusedStructMember when used through iterator (regression)
* Format
* Fix test
* Format
* Nullptr check
2022-07-19 20:42:54 +02:00
Oliver Stöneberg
f644938eb0
fixed Cppcheck version ( #4292 )
2022-07-19 20:42:19 +02:00
chrchr-github
5e537a666f
Fix --check-library warning for int(i) ( #4293 )
2022-07-19 20:41:18 +02:00
chrchr-github
c736fe8787
Fix #11008 FP doubleFree with pointer in struct ( #4294 )
2022-07-19 20:41:08 +02:00
Daniel Marjamäki
db155a59c1
Tokenizer: remove simplifyTokenList2
2022-07-18 16:20:36 +02:00
chrchr-github
b08aabefee
Fix #9877 FP unreadVariable (incomplete code; missing macro definition) ( #4278 )
2022-07-17 19:40:39 +02:00
chrchr-github
4894cdab8f
Fix #11108 FP unreadVariable with unique_ptr and unknown c'tor ( #4284 )
...
* Fix #11108 FP unreadVariable with unique_ptr and unknown c'tor
* Fix test
2022-07-16 23:46:55 +02:00
chrchr-github
b16d12b5fb
Improve check for wchar_t ( #4285 )
2022-07-16 23:46:10 +02:00
chrchr-github
109a031ec7
Fix #11195 Add redundantContinue check ( #4283 )
2022-07-16 16:02:58 +02:00
chrchr-github
9e74da6126
Fix #11098 FP compare with negated constant ( #4282 )
2022-07-16 07:28:15 +02:00
chrchr-github
53cd3dc665
Fix #10661 FP extern function reported as unused ( #4279 )
2022-07-14 20:59:58 +02:00
chrchr-github
2543dc97d2
Fix FP bitwiseOnBoolean ( #4280 )
2022-07-14 20:59:39 +02:00
chrchr-github
2c7d98626a
Fix FP leakNoVarFunctionCall with Qt object ( #4272 )
...
* Add missing <leak-ignore/>, test
* Fix qt.cfg, format
* Fix FP leakNoVarFunctionCall
* Format
* Delete memory, rule of five
* Missing include
* Avoid dependency
* explicit
* Fix Qt test case
* Fix typo
* Fix
* Add Q_OBJECT
2022-07-13 21:09:53 +02:00
chrchr-github
6eab3cb8bd
Fix #9788 ctu: false negative array index out of bounds for array arguments ( #4277 )
2022-07-13 21:08:51 +02:00
chrchr-github
49117f5aeb
Fix #7375 static_assert shouldn't be reported by --check-library ( #4276 )
...
* No need to check smart pointers, since they take template arguments
* Fix #7375 static_assert shouldn't be reported by --check-library
2022-07-13 21:08:43 +02:00
chrchr-github
21d992cc00
Fix crash on Windows with -j option ( #4229 )
...
* Fix crash on Windows with -j option
* Disable CI-cygwin workflow
* Update CI-cygwin.yml
* Update CI-cygwin.yml
* Update CI-cygwin.yml
* Try to fix Cygwin build
* Update CI-cygwin.yml
* Update CI-cygwin.yml
* Update CI-cygwin.yml
* Update CI-cygwin.yml
* Update CI-cygwin.yml
* Update CI-cygwin.yml
* Update CI-cygwin.yml
* Update CI-cygwin.yml
* Update CI-cygwin.yml
* Update CI-cygwin.yml
* Update CI-cygwin.yml
* Update CI-cygwin.yml
* Update CI-cygwin.yml
* Update CI-cygwin.yml
* Update CI-cygwin.yml
* Update CI-cygwin.yml
* Update CI-cygwin.yml
* Update CI-cygwin.yml
* Update CI-cygwin.yml
* Update CI-cygwin.yml
* Update CI-cygwin.yml
* Update CI-cygwin.yml
* Update CI-cygwin.yml
* Update CI-cygwin.yml
* Update CI-cygwin.yml
* Update CI-cygwin.yml
* Cygwin uses THREADING_MODEL_FORK
* Restore workflows
* Remove comment
* Fix dmake
* Fix #11179 FP invalidFunctionArgStr
* Revert "Fix #11179 FP invalidFunctionArgStr"
This reverts commit dd5d3e67c6
.
2022-07-13 13:46:03 +02:00
Daniel Marjamäki
b387ae80f1
Fixed whole program analysis
2022-07-12 22:58:52 +02:00
PKEuS
f3565e1056
Improvement: Support member variables in CheckOther::checkIncompleteArrayFill() ( #4205 )
...
Merged from LCppC.
2022-07-12 19:43:48 +02:00
chrchr-github
381c38b2f5
Improve check: uselessCallsConstructor ( #4270 )
2022-07-12 17:40:14 +02:00
Oliver Stöneberg
22be5f29aa
fixed #11183 (checkLibraryFunction with parameter to "std::string()") / added rudimentary tests for `CheckFunctions::checkLibraryMatchFunctions()` / added test for #10105 ( #4265 )
2022-07-12 17:39:01 +02:00