Commit Graph

594 Commits

Author SHA1 Message Date
Oliver Stöneberg b70e1d5461
avoid some unchecked pointer dereferences () 2023-03-02 22:05:41 +01:00
chrchr-github 215124461e
Fix FN functionConst with operator usage () 2023-03-02 21:51:58 +01:00
Oliver Stöneberg 3ec4da0f8a
improved library loading in tests () 2023-03-02 21:10:51 +01:00
Daniel Marjamäki 464fbe8d53 Update copyright year 2023-01-28 10:16:34 +01:00
Oliver Stöneberg a09667a6d9
removed unused error messages () 2023-01-07 10:35:39 +01:00
Oliver Stöneberg 1cfe49e340
use `const_iterator` where possible () 2022-12-30 15:13:47 +01:00
gerboengels ed06e29f7a
Fix defaulted and deleted functions ()
* 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 ()
* 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 6142ba542a
Fix leakNoVarFunctionCall FP () 2022-09-29 21:58:11 +02:00
chrchr-github 56e2af5dec
Fix FP leakReturnValNotUsed although (void) is specified () 2022-09-27 20:09:04 +02:00
chrchr-github 917496a844
Fix FN destructor with no definition hide mismatching alloc/dealloc ()
* Fix  FN destructor with no definition hide mismatching allocation / deallocation

* Format

* Fix test

* Format
2022-08-25 22:52:51 +02:00
PKEuS d81a758850
LCppC backports: Refactorizations/Optimizations () 2022-08-21 17:21:02 +02:00
Oliver Stöneberg 98b9f2cbf1
reduced scope of some variables and avoided some copies () 2022-08-16 22:28:39 +02:00
Oliver Stöneberg 4bf5dcd29f
cleaned up includes based on include-what-you-use ()
* cleaned up includes based on include-what-you-use

* testlibrary.cpp: no need for `empyString` optimization
2022-08-14 12:44:19 +02:00
chrchr-github 2c7d98626a
Fix FP leakNoVarFunctionCall with Qt object ()
* 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 d8e64b4cbb
Fix FP leakNoVarFunctionCall ()
* Fix  FN: leakNoVarFunctionCall

* Fix TODO

* Fix  FN: leakNoVarFunctionCall (if ( b && malloc ) )

*  FN: leakNoVarFunctionCall (ternary operator)

* Fix  FN: leakNoVarFunctionCall (switch condition)

* Fix FN constStatement

* Fix FP leakNoVarFunctionCall

* Fix FP leakNoVarFunctionCall

* Format

* Fix FP leakNoVarFunctionCall with unknown function

* Fix FP leakNoVarFunctionCall
2022-06-30 13:05:28 +02:00
chrchr-github 06b408ea20
Fix FP leakNoVarFunctionCall with unknown function ()
* Fix  FN: leakNoVarFunctionCall

* Fix TODO

* Fix  FN: leakNoVarFunctionCall (if ( b && malloc ) )

*  FN: leakNoVarFunctionCall (ternary operator)

* Fix  FN: leakNoVarFunctionCall (switch condition)

* Fix FN constStatement

* Fix FP leakNoVarFunctionCall

* Fix FP leakNoVarFunctionCall

* Format

* Fix FP leakNoVarFunctionCall with unknown function
2022-06-29 13:43:17 +02:00
chrchr-github b90a726441
Fix FP leakNoVarFunctionCall ()
* Fix  FN: leakNoVarFunctionCall

* Fix TODO

* Fix  FN: leakNoVarFunctionCall (if ( b && malloc ) )

*  FN: leakNoVarFunctionCall (ternary operator)

* Fix  FN: leakNoVarFunctionCall (switch condition)

* Fix FN constStatement

* Fix FP leakNoVarFunctionCall

* Fix FP leakNoVarFunctionCall

* Format
2022-06-29 07:22:26 +02:00
chrchr-github 2223cd24b9
Fix FN: leakNoVarFunctionCall (switch condition) ()
* Fix  FN: leakNoVarFunctionCall

* Fix TODO

* Fix  FN: leakNoVarFunctionCall (if ( b && malloc ) )

*  FN: leakNoVarFunctionCall (ternary operator)

* Fix  FN: leakNoVarFunctionCall (switch condition)

* Fix FN constStatement

* Fix FP leakNoVarFunctionCall
2022-06-28 14:02:02 +02:00
chrchr-github cdeebc15ea
Fix FN: leakNoVarFunctionCall (ternary operator) ()
* Fix  FN: leakNoVarFunctionCall

* Fix TODO

* Fix  FN: leakNoVarFunctionCall (if ( b && malloc ) )

*  FN: leakNoVarFunctionCall (ternary operator)
2022-06-27 20:55:09 +02:00
chrchr-github e7e23e87c2
Fix FN: leakNoVarFunctionCall (if ( b && malloc ) ) ()
* Fix  FN: leakNoVarFunctionCall

* Fix TODO

* Fix  FN: leakNoVarFunctionCall (if ( b && malloc ) )
2022-06-27 19:35:22 +02:00
chrchr-github 88bf11abba
Fix FN: leakNoVarFunctionCall ()
* Fix  FN: leakNoVarFunctionCall

* Fix TODO
2022-06-27 14:19:19 +02:00
chrchr-github 423e67bd6a
Fix FP memleak () 2022-05-30 06:55:15 +02:00
chrchr-github 16af6561c2
Fix FP memleak with unknown ptr typedef ()
* Fix  FN memleak with redundant pointer op

* Style

* Fix  FN: Memory leak not detected on struct member

* Fix FP memleak with function call, fix cppcheckError

* Fix FP memleak with array

* Fix FPs memleak with array and ptr to ptr

* Fix FP memleak with unknown ptr typedef

* Format
2022-05-27 23:52:56 +02:00
chrchr-github 19dd59eae6
Fix FPs memleak with array and ptr to ptr ()
* Fix  FN memleak with redundant pointer op

* Style

* Fix  FN: Memory leak not detected on struct member

* Fix FP memleak with function call, fix cppcheckError

* Fix FP memleak with array

* Fix FPs memleak with array and ptr to ptr
2022-05-26 15:27:36 +02:00
chrchr-github 86763b7b0a
Fix FP memleak with array ()
* Fix  FN memleak with redundant pointer op

* Style

* Fix  FN: Memory leak not detected on struct member

* Fix FP memleak with function call, fix cppcheckError

* Fix FP memleak with array
2022-05-26 00:03:30 +02:00
chrchr-github 1ed280fe63
Fix FP memleak with function call, fix cppcheckError ()
* Fix  FN memleak with redundant pointer op

* Style

* Fix  FN: Memory leak not detected on struct member

* Fix FP memleak with function call, fix cppcheckError
2022-05-24 14:02:06 +02:00
chrchr-github 1ced94be43
Fix FN memleak with redundant pointer op / FN: Memory leak not detected on struct member ()
* Fix  FN memleak with redundant pointer op

* Style

* Fix  FN: Memory leak not detected on struct member
2022-05-23 23:21:36 +02:00
Daniel Marjamäki 8f386e15fd Remove bug hunting. This feature will be provided in Cppcheck premium. 2022-04-11 07:31:33 +02:00
chrchr-github c8936d04f6
Fix New Check : Return value of "new" ignored () 2022-04-09 19:06:32 +02:00
chrchr-github 907218254e
Fix previous commit ()
* Fix  unsafeClassCanLeak missing for array of pointers

*  Fix previous commit

* Format

* Format
2022-02-15 20:03:02 +01:00
chrchr-github e7e2439347
Fix unsafeClassCanLeak missing for array of pointers () 2022-02-15 14:28:19 +01:00
Oliver Stöneberg 6e57cc4323
small utils.h cleanup () 2022-02-11 19:44:08 +01:00
Daniel Marjamäki 3989408738 Update copyright year 2022-02-05 11:45:17 +01:00
chrchr-github 7f28edbe26
Fix Crash in CheckMemoryLeakInClass () 2022-02-04 19:32:23 +01:00
chrchr-github 94a1f76ec4
Fix 10158 FP memleak when pointer is stored in a sub-object () 2022-02-02 13:13:12 +01:00
Oliver Stöneberg 171da2e6f9
avoid dependency on transitive includes - based on include-what-you-use () 2022-01-27 19:03:20 +01:00
Rikard Falkeborn e106654993
Fix : Uncaughty exception in CheckMemoryLeak::getReallocationType() () 2022-01-18 20:50:06 +01:00
Oliver Stöneberg 0ba9cb4e64
fixed some unusedFunction warnings () 2022-01-04 15:48:08 +01:00
Paul Fultz II 853a1f6d54
Fix 10631: FP, Regression: error: Return value of allocation function 'makeThing' is not stored. () 2021-11-29 07:06:43 +01:00
Paul Fultz II 7f358b2bed
Format with uncrustify () 2021-08-07 20:51:18 +02:00
keinflue bfa26b5a72
Fix FP leakNoVarFunctionCall with passthrough returns () 2021-05-08 10:26:10 +02:00
Daniel Marjamäki d2d2124238 Revert "Clang import; This experimental feature didn't "take off" much. After a lot of work we are still far fram the goal. I remove it now but don't rule out completely that it could ever be added again."
This reverts commit 207361b174.
2021-04-30 16:47:02 +02:00
Daniel Marjamäki 207361b174 Clang import; This experimental feature didn't "take off" much. After a lot of work we are still far fram the goal. I remove it now but don't rule out completely that it could ever be added again. 2021-04-21 18:59:48 +02:00
Oliver Stöneberg 6397e29f84
cleaned up includes based on include-what-you-use () 2021-04-03 21:30:50 +02:00
Daniel Marjamäki 42437277dc Update Copyright year 2021-03-21 20:58:32 +01:00
PKEuS 141d2ac215 Refactorization: Improved internal implementation of severity and certainty levels
Backported from LCppC.
2021-02-24 22:00:06 +01:00
Oliver Stöneberg 7aa85aa408
Use std::unordered_* containers for faster lookups () 2021-01-16 13:52:09 +01:00
Ken-Patrick Lehrmann 56124f0c5d
Skip calculateWarningHash if we are not in bugHunting () 2021-01-13 18:38:00 +01:00
Rikard Falkeborn 791051ced0 Fix (FN common realloc mistake with assignment of NULL)
Do not match for assignments with NULL.
2020-09-13 21:49:49 +02:00