Commit Graph

733 Commits

Author SHA1 Message Date
Daniel Marjamäki 3f8218af1b Removed CheckClass::operatorEq: does not 'belong' 2020-06-17 20:35:43 +02:00
Oliver Stöneberg 4f68d85633
optimized non-matchcompiled Token::simpleMatch() a bit (#2640) 2020-05-26 20:13:56 +02:00
Oliver Stöneberg 37bc0483a4
made check.h less heavy (#2633) 2020-05-23 07:16:49 +02:00
Daniel Marjamäki 08ddd84780 Update copyright year 2020-05-10 11:16:32 +02:00
Daniel Marjamäki 3e0218299b Revert "Update copyright year"
This reverts commit 6eec6c4bd5.
2020-05-10 11:13:05 +02:00
Daniel Marjamäki 6eec6c4bd5 Update copyright year 2020-05-10 11:11:34 +02:00
Daniel Marjamäki 2e369cc842 astyle formatting
[ci skip]
2020-04-27 17:35:52 +02:00
Lionel Gimbert ad6be7b122
Enforcing CppCoreGuideline C.35 on virtual class destructor (#2572)
* Enforcing CppCoreGuideline C.35
A base class destructor should be either public and virtual, or protected and non-virtual

https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Rc-dtor-virtual

* Protected destructor of ciurtual class can be virtual
2020-04-27 09:22:42 +02:00
Daniel Marjamäki aa1bbf2e62 Fixed #9679 (False positive: use this after free (lambda not executed directly)) 2020-04-17 20:20:45 +02:00
Oliver Stöneberg 2c1e36e63e
cleaned up includes based on include-what-you-use (#2600)
* cleaned up includes based on include-what-you-use

* check.h: trying to work around Visual Studio 2012 bug

* fixed Visual Studio compilation
2020-04-13 13:44:48 +02:00
Daniel Marjamäki 32bf53eeda Fixed #9221 (False positive when using an array of lists) 2020-04-10 14:01:15 +02:00
Daniel Marjamäki eff225a09c Use 'static' instead of unnamed namespace for variables 2020-04-10 13:48:38 +02:00
Daniel Marjamäki afb5590741 New check: delete 'self pointer' that might be used as 'this' and then use some member/method 2020-02-18 18:24:18 +01:00
Daniel Marjamäki 332279326f checkVirtualFunctionCallInConstructor; Check should be 'style' since there is no UB. Disabled the check temporarily, it should use CTU to determine if the class is a base class 2020-02-14 17:10:12 +01:00
Maksim Derbasov 872d531568 Removing check hidingInheritedPublic (#2482) 2020-01-09 06:53:08 +01:00
Maksim Derbasov a3ed9116e5 Clarify error msg for hidingInheritedPublic (#2474) 2020-01-05 09:32:39 +01:00
orbitcowboy 1e0f8ae9b4 Running astyle [ci skip]. 2020-01-04 00:06:27 +01:00
Maksim Derbasov fc5fd3c40c Check that virtual function non-narrow access modifier in derived class (#2229)
* Check that virtual function has not narrowed access in derived class

* motivation info added

* error reporting moved to func

* added suppression for CI
2020-01-01 16:09:43 +01:00
Dmitry-Me 1a2b770bfd Break the loop once a match is found 2019-12-31 18:32:45 +03:00
Daniel Marjamäki eaa5bfcadd Remove 'unsafeClassDivZero' warning. The software verification will cover this better. 2019-11-10 16:49:34 +01:00
Dmitry-Me f2cf71f6e9 Fix typo 2019-11-01 18:39:53 +03:00
Daniel Marjamäki c04e25e936 Revert "#9391 Detecting uninited member variables with default ctor (#2249)"
This reverts commit 08bc369296.
2019-10-09 08:17:47 +02:00
blacktea 08bc369296 #9391 Detecting uninited member variables with default ctor (#2249) 2019-10-08 19:33:07 +02:00
Daniel Marjamäki 7f64faae99 Virtual Destructors: Base class must have virtual destructor no matter if derived class has a destructor or not. There is UB according to paragraph 3 in [expr.delete]. 2019-09-27 09:55:56 +02:00
Oliver Stöneberg de9f489b08 use range loops / constness (#2181)
* use range loops / constness

* platform.cpp: avoid shadowed variable
2019-09-19 20:29:33 +02:00
Ken-Patrick d918f76a0d Remove useless check introduced by 717aa826d8 (#2130)
I was confused by the naming in the forum entry (this/that). This would
be a pointer, there's no point checking for it there.
2019-09-01 09:53:45 +02:00
Ken-Patrick 717aa826d8 Fix false positive in initializationListUsage (#2128)
https://sourceforge.net/p/cppcheck/discussion/general/thread/d5b690ef19/
Check that we warn only about using the initializer list when we assign
the object being constructed.
2019-08-31 12:27:07 +02:00
Daniel Marjamäki d4549217d0 Renamed safeClassRefMember => unsafeClassRefMember 2019-08-13 20:58:31 +02:00
Daniel Marjamäki ed7edc6d2a Improve warning message 2019-08-13 20:42:25 +02:00
Daniel Marjamäki 41f8c1b281 Fixed #9271 (Safe classes: Class that store references) 2019-08-13 20:40:48 +02:00
amai2012 f02636e995 Refactoring: Convert enums to enum classes 2019-08-02 21:14:29 +02:00
Rikard Falkeborn f6726b76ae Fix 9215 (add tilde for missing destructor override warning) (#2057) 2019-08-01 10:43:45 +02:00
Daniel Marjamäki 4fb6c27276 Modernize: Use enum class 2019-07-23 14:29:02 +02:00
Daniel Marjamäki 2afd5f5dd0 Modernize: Use enum class 2019-07-17 10:39:06 +02:00
Daniel Marjamäki 3637c486c4 Replace 'unsigned' with 'nonneg' in checkclass 2019-07-16 09:03:45 +02:00
IOBYTE 9700490e51 fix lib/checkclass.cpp:51:12: warning: enumeration value ‘eLambda’ not handled in switch [-Wswitch] (#1978) 2019-07-11 08:25:25 +02:00
Rikard Falkeborn 839fcddd8a Fix #6115 (Add support to realloc to cfg files) (#1953)
* Allow to configure realloc like functions

* memleakonrealloc: Bring back tests.

The old memleak checker was removed, and the tests for it was removed in
commit 9765a2dfab. This also removed the
tests for memleakOnRealloc. Bring back those tests, somewhat modified
since the checker no longer checks for memory leaks.

* Add realloc to mem leak check

* Add tests of realloc buffer size

* Configure realloc functions

* Add test of freopen

* Allow to configure which element is realloc argument

* Fix wrong close in test

cppcheck now warns for this

* Update manual

* Update docs

* Rename alloc/dalloc/realloc functions

Naming the member function realloc caused problems on appveyor. Rename
the alloc and dealloc functions as well for consistency.

* Change comparisson order

* Remove variable and use function call directly

* Create temporary variable to simplify

* Throw mismatchError on mismatching allocation/reallocation

* Refactor to separate function

* Fix potential nullptr dereference

As pointed out by cppcheck.
2019-07-05 12:44:52 +02:00
shaneasd 7e54f989f9 Update symbol database such that the override keyword implies that the function is also virtual (#1907)
* Update symbol database such that the override keyword implies that the function is also virtual

* Add test case for implicit override

* change isVirtual to hasVirtualSpecifier

* fix method documentation for getVirtualFunctionCalls and getFirstVirtualFunctionCallStack

* Fix isImplicitlyVirtual to consider the override keyword and document logic

* Fix getFirstVirtualFunctionCallStack and getVirtualFunctionCalls to use isImplicitlyVirtual instead of isVirtual so new test case passes
2019-07-04 12:32:32 +02:00
Daniel Marjamäki c98ceb6e14 Tweak bailout so it's only used in unused template classes 2019-06-20 14:00:44 +02:00
Daniel Marjamäki cf79830afd Revert "Remove bailout. It hides lots of warnings for real code to avoid FP in unused templates."
This reverts commit 2a4be5ae1c.

When I look at daca@home now there are still lots of false negatives. So this bailout did not cause as much false negatives as I thought.
2019-06-19 22:29:00 +02:00
Daniel Marjamäki 2a4be5ae1c Remove bailout. It hides lots of warnings for real code to avoid FP in unused templates. 2019-06-16 19:01:45 +02:00
Daniel Marjamäki 29e5992e51 Fixed #9045 (FP operatorEqRetRefThis - recent regression) 2019-05-20 21:30:20 +02:00
Paul Fultz II cf3515ee61 Fix issue 7372: False positive uninitMemberVar - on template specialization
This fixes the issue by skipping diagnostics when the symbols are incomplete in the constructor.
2019-05-17 20:24:41 +02:00
Daniel Marjamäki 2513c1499b Library: Added <smart-pointer> element 2019-04-24 13:06:58 +02:00
Nicodemes 272760f9ca Fix explicit constructor with default arguments check bug
Before this fix, the code:
```
class A {
    A(int, int x=3){
        x;
    }
};
```
Was considered OK.
But explicit keyword is still needed

I'm still new to open-source contributions, so I will gladly take advice.
2019-04-23 10:46:22 +02:00
Daniel Marjamäki 761f18c75c Fixed #8988 (False positive: using memset on struct) 2019-04-01 19:32:03 +02:00
Daniel Marjamäki ad37664e86 Changed severities 2019-03-06 19:00:58 +01:00
Daniel Marjamäki bd7790fd8c Update copyright year 2019-02-09 07:24:06 +01:00
Daniel Marjamäki 14a312e310 useInitializationList: Skip warning when rhs is a multi line lambda. For readability it might be better to have assignments in constructor in this case. 2019-02-05 19:53:10 +01:00
Daniel Marjamäki 4457faa26b Fixed #8850 (Array in-class initialization for private member considered uninitialized) 2019-02-02 18:34:41 +01:00