Commit Graph

526 Commits

Author SHA1 Message Date
Daniel Marjamäki 7d63bdee6f astyle formatting
[ci skip]
2019-09-02 06:59:07 +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 41f8c1b281 Fixed #9271 (Safe classes: Class that store references) 2019-08-13 20:40:48 +02:00
Rikard Falkeborn f6726b76ae Fix 9215 (add tilde for missing destructor override warning) (#2057) 2019-08-01 10:43:45 +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
IOBYTE 5642778206 Fixed #9193 (functionStatic false positive (inconclusive)) (#1943) 2019-07-02 11:40:57 +02:00
Scott Furry a195477470 Correct Zero/Null as pointer constant (#1938)
Building with enhanced clang warnings indicated a large number of
instances with the warning:

`warning: zero as null pointer constant`

Recommended practice in C++11 is to use `nullptr` as value for
a NULL or empty pointer value. All instances where this warning
was encountered were corrected in this commit.

Where warning was encountered in dependency code (i.e. external library)
no chnages were made. Patching will be offered upstream.
2019-06-30 21:39:22 +02:00
Daniel Marjamäki 29e5992e51 Fixed #9045 (FP operatorEqRetRefThis - recent regression) 2019-05-20 21:30:20 +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
rikardfalkeborn aa730f45c6 Add regression test for #7714 (#1648)
Ticket #7714 was fixed in ea215c3b7b.
Add a regression test to make sure it stays fixed.
2019-02-07 08:49:55 +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
Lauri Nurmi 3bbd9fc9a4 Replace "virtual method" with "virtual function" in messages.
The term "method" is not really a part of C++ terminology.
2019-01-15 06:22:14 +01:00
amai2012 738fef6c27 Run astyle 2019-01-12 21:51:39 +01:00
Daniel Marjamäki 8dd641b8be Use OVERRIDE in test 2019-01-12 15:45:25 +01:00
Daniel Marjamäki e4525d56a0 Fixed #8111 (performance warning - member variable at constructor) 2019-01-07 21:26:58 +01:00
IOBYTE 0f83aff3b8 Improve trailing return type support. (#1520)
* Improve trailing return type support.

* Partial fix for #8889 (varid on function when using trailing return type)

* Handle operators in templates.
2018-12-13 06:34:10 +01:00
Daniel Marjamäki 7c47283e6d Fix testrunner 2018-12-04 17:17:07 +01:00
IOBYTE 2275f05f65 Fixed #8833 (false negative: No 'return' statement in non-void function causes undefined behavior.) (#1463) 2018-11-05 06:55:30 +01:00
IOBYTE 0a30768b59 Fixed #8693 (Template specialization: Constructor detected as normal … (#1418)
* Fixed #8693 (Template specialization: Constructor detected as normal function (functionStatic error))

Refactor template simplifier to remove the existing full specialization
function expandSpecialized and allow full specializations to use the
existing function expandTemplate.  The function expandTemplate was
modified to either expand the template like it originally did by copying
it or to modify the template in place.  Both instantiated and
uninstantiated full specializations are modified in place.  This also
fixes #8692 and probably other related tickets as well.

The function simplifyTemplates now tries twice to simplify templates so
more templates can be simplified.  We should try as many times as
necessary to find all possible templates.  We can't do that now because
uninstantiated templates are left unchanged.  It is relatively straight
forward to have the new code also expand in place uninstantiated
templates with their symbolic types but namespaces are not handled
properly (ticket #8671) and it would introduce regressions.

* Fix travis warnings.
2018-10-14 16:57:07 +02:00
Daniel Marjamäki a31db92918 Fixed #8669 (operator>> causes wrong style message) 2018-10-03 13:00:11 +02:00
rikardfalkeborn 5e120b567c isVariableDeclaration: Handle pointer to const pointer (#1395)
isVariableDeclaration did not handle pointer to const pointer, or
pointer to volatile pointer. This resulted in FPs in examples like the
following:

    class Fred {
        public:
        const char *const *data;
        const char *const *getData() { return data; };
    }

where cppcheck would say getData could be static, since it didn't
recognize const char *const *data as a variable declaration.
2018-09-25 06:19:26 +02:00
Daniel Marjamäki 738fb1b23a Disabled CheckClass::checkCopyCtorAndEqOperator because of FP (#8388) 2018-09-08 09:14:02 +02:00
Daniel Marjamäki 4d78a2e178 Fixed #7790 (Wrong order of <location> XML-elements for error duplInheritedMember) 2018-08-19 14:13:58 +02:00
Sylvain Joubert 13617375df missingOverride: False positive with cv-ref mismatch (#1340) 2018-08-17 08:42:22 +02:00
Daniel Marjamäki 78df7f98dd Fixed #8674 (False positive: Method that returns const should not be const) 2018-08-07 18:06:14 +02:00
Daniel Marjamäki 54e2726bf3 Fixed #8636 (Misleading verbose message if virtual method called from destructor) 2018-07-26 09:16:17 +02:00
Daniel Marjamäki 1abc9008d8 Fixed #8573 (FP noCopyConstructor - derive from noncopyable class) 2018-06-06 16:02:25 +02:00
IOBYTE 36f7585798 Fixed #8600 (false-positive/regression: confusion between copy constructors of internal classes and lack of explicit keyword) (#1266) 2018-05-27 10:53:34 +02:00
IOBYTE ce50df8047 Fix override warnings. (#1234) 2018-05-15 16:37:40 +02:00
Daniel Marjamäki f7746e4fb6 Revert "Missing override specifier warning on a pure virtual function makes no sense. (#1230)"
This reverts commit 348eb1c5c9.
2018-05-15 10:48:34 +02:00
IOBYTE 348eb1c5c9 Missing override specifier warning on a pure virtual function makes no sense. (#1230)
This fixes a large number of false positives for cppcheck source code.
2018-05-14 23:08:40 +02:00
Daniel Marjamäki 64b85b474c Fixed #8542 (False positive: noOperatorEq) 2018-05-05 07:46:58 +02:00
Daniel Marjamäki 7fb28b05f6 Check Class: Try to clarify the warnings for noCopyConstructor/noOperatorEq/noDestructor. 2018-05-04 15:39:23 +02:00
Daniel Marjamäki 99003c2084 CheckClass: Better handling of defaulted and deleted functions in the noCopyConstructor/noOperatorEq/noDestructor 2018-05-04 14:58:38 +02:00
Daniel Marjamäki 40b6f6b3dd CheckClass: Fix the noDestructor warning 2018-05-01 15:31:13 +02:00
Daniel Marjamäki 9710e819be CheckClass: Disable noDestructor for now, we need to handle new better 2018-05-01 09:26:03 +02:00
Daniel Marjamäki 42100fdf11 CheckClass: Better handling of non-copyable classes in the noCopyConstructor check 2018-05-01 08:33:23 +02:00
Daniel Marjamäki 73b41455dd CheckClass: If class has memory management it should have copy constructor, operator= and destructor 2018-04-30 23:13:33 +02:00
Daniel Marjamäki 1a9e8c158d CheckClass::copyconstructors: Use library to determine if function is a allocation function 2018-04-27 23:20:04 +02:00
Daniel Marjamäki 25599a76a7 Handle 'final' specifier better. 2018-04-27 14:57:43 +02:00
Daniel Marjamäki b830f462e6 Added missingOverride checker; Function 'f' overrides function in base class but does not have the 'override' keyword. 2018-04-27 11:12:09 +02:00
Daniel Marjamäki deaafd59d7 CheckClass: Undo the rule of 3 checker to avoid some warnings 2018-04-24 22:42:25 +02:00
Daniel Marjamäki 485d3e0229 CheckClass: Tweak rule of 3 checker 2018-04-24 21:45:30 +02:00
Daniel Marjamäki 6fb25dcaa4 CheckClass: Changed checker for 'copy constructor' and 'operator=' to a 'rule of 3' checker 2018-04-24 16:07:58 +02:00
Daniel Marjamäki 0d434efc15 virtualCallInConstructor: Clarify warning message 2018-04-04 13:04:40 +02:00