Commit Graph

1238 Commits

Author SHA1 Message Date
chrchr-github 3ccc0adbca
Fix #11182 checkLibraryFunction with overloaded method / #11198 inconsistent reporting of checkLibraryNoReturn (#4740) 2023-01-26 22:29:49 +01:00
chrchr-github b5a06d045e
Fix #11497 debug: CheckClass::isMemberVar found used member variable 'x' with varid 0 (inconclusive) (#4736) 2023-01-26 22:19:51 +01:00
chrchr-github a0f51d1e21
Improve <type-checks><unusedvar> error message (#4735) 2023-01-26 22:18:55 +01:00
chrchr-github 3a8d9b8c87
Fix #11510 FP CastIntegerToAddressAtReturn with ternary operator (#4732) 2023-01-26 22:09:55 +01:00
chrchr-github 50d297b309
Enable useStlAlgorithm in selfcheck (#4725) 2023-01-17 20:48:26 +01:00
chrchr-github 7bbdc95f25
Fix #11473 FP constVariable / #11448 FP constParameter / #11188 FP danglingTempReference (#4680)
* Fix #11473 FP constVariable with range-based for / #11448 FP constParameter with unused non-const range loop variable

* Fix ValueType / #11188 FP danglingTempReference with auto

* Fix ValueType in range-based for

* Update symboldatabase.cpp
2023-01-11 22:04:06 +01:00
chrchr-github 4c1c506d21
#11472 FP returnTempReference with cast and scope operator (#4676) 2023-01-02 22:13:56 +01:00
chrchr-github f793b7dd35
Fix #11460 unintvar false positive (#4674)
* Fix #11460 unintvar false positive

* Format
2023-01-02 17:44:52 +01:00
Oliver Stöneberg 1cfe49e340
use `const_iterator` where possible (#4662) 2022-12-30 15:13:47 +01:00
Oliver Stöneberg 3c68b9b29f
use `cbegin()` and `cend()` with `const_ierator` loops (#4658) 2022-12-20 20:32:16 +01:00
chrchr-github ad858e92dc
Partial fix for #11444 cppcheckError: Analysis failed (function not recognized) (#4656) 2022-12-19 22:29:43 +01:00
chrchr-github 76c28073aa
Revert fix for #10831 (#4631) 2022-12-18 16:55:55 +01:00
gerboengels 63e30d1b8c
Fix syntaxError on lambda inside decltype (#4650)
Use case where it gave an issue:

using customComparator = decltype([] (const X& lhs, const X& rhs) { return lhs.CompareTo(rhs); });
std::map<X, int, costomComparator> m;

Co-authored-by: Gerbo Engels <gerbo.engels@ortec-finance.com>
2022-12-18 16:46:04 +01:00
Paul Fultz II 90898945c1
Fix 10532: False negative: dangling string_view when using ternary operator (#4638)
* Fix 10532: False negative: dangling string_view when using ternary operator

* Format

* Update
2022-12-15 18:34:43 +01:00
chrchr-github 665e4230f2
Fix #11406 FP returnDanglingLifetime, std::unique_ptr and implicit conversion to bool (#4600) 2022-11-27 09:24:19 +01:00
chrchr-github 4ce76d0b58
Fix #11385 debug: SymbolDatabase::findFunction found '>' without link. (#4583) 2022-11-14 21:08:15 +01:00
Daniel Marjamäki 8fb8e06003 SymbolDatabase: Set valuetype for this 2022-11-12 22:23:42 +01:00
Daniel Marjamäki e45e5f9f15 SymbolDatabase: fix ValueType for '&array[x]' 2022-11-05 21:22:08 +01:00
Daniel Marjamäki ecb2938e7e SymbolDatabase: Set correct ValueType when there is array-to-pointer decay 2022-11-05 17:38:31 +01:00
chrchr-github 3273e51fd5
Fix #10412 FN useStlAlgorithm with iterators (#4157) 2022-10-16 13:46:26 +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
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
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
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
Oliver Stöneberg eeb6db05f1
avoid some unnecessary object creations and copies (#4493) 2022-09-29 21:47:17 +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 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
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
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 9306c6f329 dump: Add Function::isAttributeNoreturn info 2022-09-03 12:09:20 +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
chrchr-github b04bf7396f
Fix #7515 New check: Not needed c_str() operation (#4371) 2022-08-20 20:52:10 +02:00
Oliver Stöneberg 16f598c409
added missing `sstream` includes (#4381) 2022-08-19 10:16:23 +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
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 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
Daniel Marjamäki a7afaba21d SymbolDatabase: add BaseInfo::nameTok to dumpfile 2022-07-21 15:57:41 +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
chrchr-github 53cd3dc665
Fix #10661 FP extern function reported as unused (#4279) 2022-07-14 20:59:58 +02:00
chrchr-github f5c4a21eae
Fix #10704 FN redundantCopyLocalConst (#4115) 2022-07-10 11:33:24 +02:00
Oliver Stöneberg c9c1f83a69
use `emptyString` more consistently (#4034) 2022-07-10 10:57:29 +02:00
chrchr-github bd92e7411c
Fix #11163 Hang on smart pointer with auto type deduction (#4250)
* Fix #11163 Hang on smart pointer with auto type deduction

* Format

* Format
2022-07-08 12:37:53 +02:00
Paul Fultz II 46fcdca5ee
Add debug_valuetype intrinsic (#4210) 2022-06-15 21:25:55 +02:00
chrchr-github 829ca9ab7f
Fix #10935 FP: compareBoolExpressionWithInt with enum and template parameter (#4193) 2022-06-10 20:40:37 +02:00
PKEuS 1275b5275e
LCppC backport: Various optimizations (#4182)
* Optimization: Use Token::eIncDecOp instead of expensive Token::Match calls

Merged from LCppC.

* Small Optimizations: - Moved a std::set that is only need during initialization of SymbolDatabase to function scope - Use std::vector instead of std::list

Merged from LCppC.

* Optimization: Refactorized various Token::Match calls and surrounding conditions

Merged from LCppC.

* Refactorization: Cleanup usage of std::multimap

Merged from LCppC.
2022-06-08 16:58:57 +02:00
chrchr-github e6f2929fac
Fix #11085 FN constVariable with range-based for (#4118) 2022-06-03 19:24:59 +02:00