Commit Graph

636 Commits

Author SHA1 Message Date
chrchr-github a030970160
Fix #11531 FP constParameter with const/non-const overload / #8700 FP functionConst (#4802) 2023-02-24 07:05:18 +01:00
chrchr-github 1c11d3039d
Fix FP returnTempReference (#4793)
* Fix FP returnTempReference

* Fix mismatch between token and variable ValueType

* Format, clang-tidy

* Add test

* Format
2023-02-17 07:17:37 +01:00
Oliver Stöneberg 132a5a31cf
improved setting of platform in tests / also improved platform tests (#4787)
* fixture.h: added TODO

* TestPlatform: improved tests for built-in platforms

* TestPlatform: changed tests to TODO asserts

* testfilelister.cpp: added TODO

* fixture.h: added `PLATFORM` macro to load platform / use `PLATFORM` in tests

* platform.h: corrected capitalization in `Platform::platformString(PlatformType)` and bail on unknown type

* fixture.h: fixed `readability-redundant-string-cstr` clang-tidy warning

* testplatform.cpp: fixed `functionConst` selfcheck warnings
2023-02-11 10:44:56 +01:00
chrchr-github 55292d476a
Fix #11535 "debug: Executable scope 'x' with unknown function" (#4770) 2023-02-07 22:35:58 +01:00
chrchr-github 8af1026696
Set functions for calls through iterators (#4763) 2023-02-07 21:57:59 +01:00
chrchr-github a666e31801
Fix #11517 FP constVariable with dynamic_cast (#4753) 2023-02-06 22:05:07 +01:00
Daniel Marjamäki 464fbe8d53 Update copyright year 2023-01-28 10:16:34 +01:00
Oliver Stöneberg 1d3955bd92
renamed some files in the `test` folder (#4705) 2023-01-27 08:18:32 +01:00
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 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
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
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
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 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 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
Daniel Marjamäki 92845295b8 Fix broken CI caused by my qt fix 2022-09-08 11:12:38 +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 974e34490f
Fix #9282 FP Unused private function (#4327) 2022-08-07 20:06:32 +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 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
chrchr-github 90392faa2b
Fix crash on nullptr deref (#4189) 2022-06-09 18:25:17 +02:00
PKEuS 898a3a25a1
ValueType: Added additional unit test (#4185)
Removed unnecessary library export

Backported from LCppC.
2022-06-08 15:27:56 +02:00
chrchr-github e6f2929fac
Fix #11085 FN constVariable with range-based for (#4118) 2022-06-03 19:24:59 +02:00
chrchr-github 2ceaf308de
Fix #11084: ValueType for pointer typedef, don't warn for typedef'd pointers, improve error message (#4123)
* Fix ValueType for pointer typedef

* Add test

* Don't warn for typedef'd pointers, improve error message

* Fix tests

* Add TODO

* Fix test

* Set isSimplifiedTypedef() for more tokens, add test

* Add test
2022-05-24 10:09:48 +02:00
chrchr-github 2b723eafcb
Fix ValueType for references in range-based for loop (#4116)
* Fix ValueType for references in range-based for loop

* Format
2022-05-20 08:48:01 +02:00
chrchr-github 6b5df68677
Fix #11001 syntaxError for valid C code sizeof(enum ...) (#4045) 2022-04-26 07:22:53 +02:00
Oliver Stöneberg 45158ec064
cleaned up includes based on include-what-you-use (#4007)
* cleaned up includes based on include-what-you-use

* updated translations
2022-04-13 12:24:00 +02:00
Oliver Stöneberg 25ef9eeb26
use std::string::empty() (#3910) 2022-04-09 19:02:37 +02:00
chrchr-github 38bc0ad4c3
Fix regression: wrong member variable (#3987) 2022-04-08 08:23:10 +02:00
chrchr-github 4c375e7224
Fix #9815 FP redundantInitialization with lambda / #10864 debug: valueFlowConditionExpressions bailout (#3970)
* Fix #9815 FP redundantInitialization with lambda

* Fix #10864 debug: valueFlowConditionExpressions bailout

* Format
2022-04-05 23:19:17 +02:00
chrchr-github c4dcfef385
Fix #10260 debug: Executable scope 'x' with unknown function. (#3974)
* Fix #10174 debug: Executable scope 'x' with unknown function

* Format

* Add test for #10198

* Fix #10260 debug: Executable scope 'x' with unknown function.
2022-04-05 15:52:16 +02:00
chrchr-github 3ba6914563
Add test for #10198 (#3973)
* Fix #10174 debug: Executable scope 'x' with unknown function

* Format

* Add test for #10198
2022-04-05 13:04:20 +02:00
chrchr-github b79885c6af
Fix #10174 debug: Executable scope 'x' with unknown function (#3972)
* Fix #10174 debug: Executable scope 'x' with unknown function

* Format
2022-04-05 07:34:06 +02:00
Paul Fultz II 5bea50cd36
Fix 10908: FP: uninitvar after for-loop (#3942) 2022-03-31 21:24:20 +02:00
chrchr-github 6376bac5bb
Fix #10451 syntaxError with typedef and lambda (#3900)
* Fix #10451 syntaxError with typedef and lambda

* Don't insert union into template argument list, add test

* Format

* Revert "Format"

This reverts commit 8c52d49c8b.

* Format
2022-03-14 17:59:29 +01:00
Oliver Stöneberg f32583e097
removed OVERRIDE and FINAL defines and use the keywords directly (#3767) 2022-02-10 23:02:24 +01:00
Daniel Marjamäki 3989408738 Update copyright year 2022-02-05 11:45:17 +01:00
Oliver Stöneberg 171da2e6f9
avoid dependency on transitive includes - based on include-what-you-use (#3757) 2022-01-27 19:03:20 +01:00
Paul Fultz II 4af98f21d6
Fix 10588: crash (#3691) 2022-01-16 12:33:31 +01:00
Paul Fultz II 55ff010df3
Fix 10717: Crash in SymbolDatabase::setValueTypeInTokenList (#3710)
* Fix 10717: Crash in SymbolDatabase::setValueTypeInTokenList

* Format
2022-01-15 07:56:56 +01:00
shaneasd 8f7996211b
remove nullScope from TestSymbolDatabase (#3679) 2022-01-06 15:23:43 +01:00
Daniel Marjamäki e6ccf299b9 Fixed #10598 (SymbolDatabase: final class is not parsed properly) 2021-12-22 21:48:01 +01:00