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
Daniel Marjamäki
9d8f798aca
Fixed #8951 (false postive: (style) The class 'x' does not have a constructor although it has private member variables.)
2019-02-02 18:25:26 +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
Lauri Nurmi
f267900257
Fix spelling of "overridden" in function names.
...
One 'd' was missing.
2019-01-15 06:22:14 +01:00
Daniel Marjamäki
43035ff186
Remove inline suppression. The Cppcheck warning was a true positive.
2019-01-13 08:42:48 +01:00
Daniel Marjamäki
e6edd74099
Temporarily suppress Cppcheck false positives
2019-01-12 19:11:44 +01:00
Daniel Marjamäki
8509159d1a
Uninitialized Member variable: Fixed FP when delegate constructor is used
2019-01-10 20:13:37 +01:00
Daniel Marjamäki
e4525d56a0
Fixed #8111 (performance warning - member variable at constructor)
2019-01-07 21:26:58 +01:00
Daniel Marjamäki
7ef8f60b07
Fixed #8817 (Change wording in performance/functionStatic)
2018-12-03 18:30:54 +01:00
Daniel Marjamäki
2b09354b05
Refactoring; use visitAstNodes
2018-11-23 20:33:31 +01:00
rikardfalkeborn
a3e717bea9
Use functions instead of comparing with enum ( #1471 )
...
* Use isComparisonOp() instead of enum
* Use isAssignmentOp() instead of enum
2018-11-09 06:30:41 +01:00
IOBYTE
c966f31183
Fixed #8835 (friend class and non-empty constructor: Uninitialized members not reported) ( #1466 )
2018-11-06 06:44:08 +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
Daniel Marjamäki
a31db92918
Fixed #8669 (operator>> causes wrong style message)
2018-10-03 13:00:11 +02:00
Daniel Marjamäki
de621eab99
Refactoring; use range for loop
2018-10-03 12:54:59 +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
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
4429ee55c3
Refactoring; Use range for loop
2018-07-14 07:55:18 +02:00
Daniel Marjamäki
1dd647ae84
Refactoring; Use range for loop
2018-07-14 07:49:04 +02:00
Daniel Marjamäki
d759015d99
Refactoring; Use range for loops
2018-07-13 23:51:22 +02:00
Daniel Marjamäki
594e07acaa
Refactoring; Use range for loop
2018-07-13 23:45:34 +02:00
Daniel Marjamäki
58ac8a9982
Refactoring; Use range for loops
2018-07-13 23:43:03 +02:00
Daniel Marjamäki
ed76f06ca7
Refactoring; use range for loop
2018-07-13 23:32:49 +02:00
Daniel Marjamäki
b2403c36cd
Refactoring; Use Token::isUnaryOp() to clarify code
2018-07-13 23:17:24 +02:00
Daniel Marjamäki
60ac463a79
CheckClass: Restore a few warnings about member initialization of classes
2018-06-29 22:54:12 +02:00
Daniel Marjamäki
61c56eda44
Tweak the CheckClass::constructors() check
2018-06-27 14:02:57 +02:00
Daniel Marjamäki
79664abf2a
Refactoring: Use range for loop
2018-06-27 09:14:03 +02:00
Daniel Marjamäki
3155f15325
CheckClass: Use Variable::valueType()
2018-06-24 16:14:11 +02:00
Daniel Marjamäki
9fab15bb53
CheckClass: Use Variable::valueType() instead of Variable::typeStartToken
2018-06-24 15:41:16 +02:00
Daniel Marjamäki
e90c04cff9
Rename private member variable
2018-06-17 18:43:54 +02:00
Daniel Marjamäki
79ffe1d4fc
Rename _tokenizer, _settings, _errorLogger
2018-06-16 16:10:28 +02:00
Daniel Marjamäki
45379a3aa6
Updated copyright year for modified files
...
[ci skip]
2018-06-10 22:07:21 +02:00
Daniel Marjamäki
3029606342
CheckClass: Fix Cppcheck warning about mismatching function parameters
2018-06-10 22:04:22 +02:00
Daniel Marjamäki
1abc9008d8
Fixed #8573 (FP noCopyConstructor - derive from noncopyable class)
2018-06-06 16:02:25 +02:00
orbitcowboy
33777c5b72
Improved const correcntess of local variables.
2018-05-29 13:24:48 +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
PKEuS
20b2574da8
Fixed false positive unusedPrivateFunction caused by recent commit
2018-05-14 16:20:46 +02:00
PKEuS
090a178ed6
Refactorization in SymbolDatabase: Do not redundantly store name in FriendInfo, and store FriendInfo in vector instead of list
2018-05-14 12:18:59 +02:00
Daniel Marjamäki
3b8a3aa4ba
Fixed crashes in daca
2018-05-06 09:52:04 +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
31148fdfed
Fixed #8523 (Clarify warning: noConstructor)
2018-05-01 15:50:03 +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
eb1571af81
Refactoring: use range for
2018-04-30 22:10:54 +02:00
Daniel Marjamäki
ca8e19c96d
SymbolDatabase: Refactor SymbolDatabase: variable list
2018-04-28 09:38: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
c80c44ab20
Refactoring: use range for loop, early continue
2018-04-27 23:04:48 +02:00
Daniel Marjamäki
f336c2efe7
Refactoring; Renamed Scope::classStart and Scope::classEnd
2018-04-27 22:36:30 +02:00
Daniel Marjamäki
ed79f300f0
Refactoring; use range for loop, use early continue/break
2018-04-27 22:18:26 +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
c3cb0ddf8c
Refactoring; use range for loops
2018-04-24 11:13:19 +02:00
Daniel Marjamäki
22963f3ed8
Refactoring; use range for loop
2018-04-24 11:04:47 +02:00
Daniel Marjamäki
42c54f12fe
Refactoring: Use range for loops in CheckClass
2018-04-23 07:51:28 +02:00
Daniel Marjamäki
7b10375683
Try to make Travis happy
2018-04-22 14:00:03 +02:00
Daniel Marjamäki
0263452f5d
CheckClass: Use isLikelyStreamRead
2018-04-22 07:45:36 +02:00
Daniel Marjamäki
be48de1be9
CheckClass: Use isLikelyStreamRead
2018-04-22 07:40:11 +02:00
PKEuS
d2146844dd
Refactorizations:
...
- Replace several push_back-calls by emplace_back
- Replace some x = x.substr(0, y) calls by x.erase(y)
2018-04-11 09:44:35 +02:00
PKEuS
b15cc3f236
Refactorization: Replace several push_back-sequences by initializer lists
2018-04-09 09:54:39 +02:00
Daniel Marjamäki
a0906140a6
Suppressions: New extensible Suppressions xml format that allow more attributes. To start with it also allows symbolName.
2018-04-09 06:43:48 +02:00
PKEuS
e2002db78d
Replaced make_container by C++11 initializer lists
2018-04-08 23:03:44 +02:00
jrp2014
043b64467b
Refactor lib/checkclass.cpp
2018-04-05 15:48:23 +02:00
jrp2014
b6504c70ca
Improve constness
2018-04-04 21:51:31 +02:00
Daniel Marjamäki
0d434efc15
virtualCallInConstructor: Clarify warning message
2018-04-04 13:04:40 +02:00
Daniel Marjamäki
b3b364b42f
virtualCallInConstructor: Updated warning message
2018-04-04 12:52:58 +02:00
Daniel Marjamäki
ee22a325c7
virtual function call in constructor: don't warn about explicit scoped call
2018-04-03 14:02:59 +02:00
Daniel Marjamäki
1046ca2120
Improve check: Warn about virtual function calls in constructor/destructor
2018-04-02 15:31:47 +02:00
Daniel Marjamäki
e492932f19
Improve check: Variable is not initialized in private constructor (C++11 or later)
2018-04-02 15:26:15 +02:00
Daniel Marjamäki
c4caee6b18
Updated copyright year
2018-01-14 15:37:52 +01:00
Daniel Marjamäki
91839c2534
Fixed #7987 (FP copyCtorAndEqOperator - class with a move constructor and move assignment operator)
2017-12-23 10:35:14 +01:00
Daniel Marjamäki
526d8b76a6
Fixed #8271 (FP uninitMemberVar: Handle method call in middle of statement)
2017-11-11 21:28:24 +01:00
Daniel Marjamäki
4cb3548e2b
unsafeClassDivZero: change severity to style
2017-10-21 21:51:58 +02:00
Daniel Marjamäki
5de3c43209
changed id for new checker to unsafeClassDivZero
2017-10-21 21:45:04 +02:00
Daniel Marjamäki
15d814e609
classPublicInterfaceDivZero: Try to make the error message a bit better. Added variable name and what the bad input value is.
2017-10-21 13:00:52 +02:00
Daniel Marjamäki
7a67bced71
classPublicInterfaceDivZero: extend bailout
2017-10-21 12:40:20 +02:00
Daniel Marjamäki
299835da2f
classPublicInterfaceDivZero: don't warn in overloaded operators. It is normal behaviour that these are not protected.
2017-10-21 08:56:23 +02:00
Daniel Marjamäki
8a7411abdb
CheckClass: Fix wrong 'public interface' warnings
2017-10-20 22:10:55 +02:00
Daniel Marjamäki
86c84029e3
New check: Check public interface of classes ( #8248 )
2017-10-20 02:02:51 +02:00
Florin Iucha
6e737082da
Store the defined types in a map, for faster lookup
2017-10-17 09:00:14 +02:00
Ayaz Salikhov
be2c65eb58
Simplify int vs bool
2017-10-08 07:54:39 +02:00
Dmitry-Me
7e823e6d8e
Extract repeating checks, break loop early
2017-09-05 00:04:48 +03:00
Dmitry-Me
79f74fc4d3
Break loop early
2017-09-05 00:00:02 +03:00
Dmitry-Me
7c8cb29d14
Extract repeating checks
2017-09-04 23:58:14 +03:00
Dmitry-Me
5885988b1f
Cache and reuse value
2017-09-04 23:33:52 +03:00
Dmitry-Me
aece2254d7
Put faster checks first
2017-09-04 23:33:14 +03:00
Dmitry-Me
f7ab8c5ebb
Drop unneeded parentheses
...
Those are a misleading leftover from old code
2017-09-04 22:49:05 +03:00
Dmitry-Me
6303437163
Resolve C4800
2017-08-15 17:42:56 +03:00
Dmitry-Me
b995e59ff2
No need for counting here
2017-08-14 18:06:23 +03:00
Ayaz Salikhov
b8cd7dbb5c
Use nullptr instead of 0 or NULL ( #936 )
2017-08-09 20:00:26 +02:00
Robert Reif
f5044bb65f
Fixed #8142 (false positive: The class 'B' has 'copy constructor' but lack of 'operator='.)
...
Do not count static member variables when trying to figure out if
'operator =' is needed.
2017-08-01 19:52:41 -04:00
Daniel Marjamäki
01f023dc0a
CheckClass: Refactor hasAssignSelf to use AST
2017-07-28 23:49:11 +02:00
orbitcowboy
0e575ce12c
Modernize: make use of 'nullptr' and added a rule-file for finding non-nullptr (zero) initializations.
2017-07-28 15:20:43 +02:00
Daniel Marjamäki
a3916c501c
Refactor loop, use continue
2017-07-26 22:03:55 +02:00
Steve Browne
b58562fc7d
Added test cases for catching when assignment comes after an operator, compound assignment, or comparison for ticket #7429 and fixed the tests.
2017-05-28 16:00:06 +02:00
Ayaz Salikhov
28aa939d69
iwyu - include what you use
2017-05-27 04:33:47 +02:00
PKEuS
b1f4bd7504
Refactorization: Reimplemented Settings::_enabled as a bitfeld instead of std::set ( #7995 )
2017-04-11 11:49:26 +02:00
Daniel Marjamäki
1faca91c1d
Added 'endsWith' utility function. This will make compiling the democlient easier.
2017-04-01 18:14:18 +02:00
PKEuS
ea215c3b7b
Fixed false positives in CheckClass::checkConst() due to unmatched function overloads
...
Fixed function matching if constness mismatches
2017-04-01 10:19:32 +02:00
Alexander Alekseev
abba762d42
New check: checking for copy ctor and eq operator co-existence
2017-03-24 12:00:20 +01:00
PKEuS
996501a449
Fixed false positive #7953 : Support type conversion operators returning pointers
2017-03-23 18:12:46 +01:00
PKEuS
2f0db369f0
Refactorization: Avoid construction of empty strings by using emptyString
2017-03-01 10:50:50 +01:00
Matthias Krüger
6f1e7e897d
simplify if(tok && Token::{simple,}Match) to if(Token::{simple,}Match).
2017-02-06 15:37:12 +01:00
Matthias Krüger
01e5f14bf8
CheckClass::virtualDestructorError and a variation of CheckNullPointer::nullPointerError would print inconclusive,warning messages altough no --enable=warning was given. Fix.
2016-11-23 00:13:09 +01:00
PKEuS
02d8f691f8
Fixed false positive: Do not show useInitializationList message for enums
2016-11-22 12:09:30 +01:00
Harald Scheidl
0de47f709e
Fixed #7755 (false positive: member variable is not initialized in the constructor)
2016-10-26 10:39:53 +02:00
Dmitry-Me
d2e667ae7b
Put apostrophes consistent with other similar messages
2016-10-18 15:45:08 +03:00
Simon Martin
dc61b6342d
Ticket #7068 : Treat "memset(&this->member, ..." as member initialization.
2016-10-01 13:46:58 +02:00
Daniel Marjamäki
4d22ada078
Fixed #5839 (False positive: Function can be const, if this is passed to functor)
2016-09-04 16:36:04 +02:00
Daniel Marjamäki
ce7bfba416
Refactoring CheckClass::checkConst. Use continue.
2016-09-04 16:06:54 +02:00
Daniel Marjamäki
54db79305b
Redo refactoring of CheckClass::checkConst.
2016-09-04 16:02:59 +02:00