Commit Graph

447 Commits

Author SHA1 Message Date
PKEuS b0c1c2c819 Don't suggest using initialization list for static variables (#4332) 2012-11-04 11:59:09 +01:00
Daniel Marjamäki e1dce66494 tweaked message 2012-10-28 13:03:40 +01:00
Alexander Mai 1881898e67 Added unit test for #4290 2012-10-19 20:04:43 +02:00
Daniel Marjamäki 3ff792560f Deactived bad message. Ticket #4154 2012-09-17 18:10:11 +02:00
Daniel Marjamäki 25befccb26 Revert "CheckClass::copyconstructors: Removed check. Because there is unfixed ticket #4154."
This reverts commit 066a1d48fe.
2012-09-17 17:59:35 +02:00
Daniel Marjamäki 066a1d48fe CheckClass::copyconstructors: Removed check. Because there is unfixed ticket #4154. 2012-09-17 16:18:27 +02:00
PKEuS 4e59e55229 Refactorization/Partial rewrite of CheckClass::copyconstructors():
- Reformatted check code and some test cases
- Fixed false positives #4148 (non-copyable/unknown base classes) and #4178 (copy ctor implementation not seen)
- Proper usage of STL containers
- Better support for initializer list
- Rephrased error messages
2012-09-10 13:31:30 +02:00
gaurav kaushik 9ad7dfd5fd Fixed #211 and #214 2012-09-05 12:58:09 +02:00
PKEuS 88e4794d6e Refactorized CheckClass::checkConst:
- Added checking for functions that can be even declared static (#1971. Removed fix for #1563)
- Consistent usage of Function::TokenDef to avoid problems with scope identifiers
- Rewrote parsing of function body making it more generic
- Removed three redundant tests
2012-08-01 10:24:38 -07:00
Ville Skyttä dce16a970d spelling fixes 2012-07-31 21:28:42 +02:00
PKEuS 9834888f19 Removed some duplicate tests and a redundant variable 2012-07-25 01:34:54 -07:00
PKEuS 5c0cab238f Fixed useInitializationList false positives (#3988) 2012-07-23 08:16:47 -07:00
PKEuS 2103811291 Refactorizations in testrunner:
- Removed unnecessary space characters
- Removed comments from test cases which are not preprocessed
2012-07-16 05:02:33 -07:00
PKEuS 639f15645a Message refactorization: checkbufferoverrun.cpp (2), checkclass.cpp, checkexceptionsafety.h 2012-07-09 02:11:05 -07:00
PKEuS 43c060b630 Removed preprocessor directives from tests that aren't preprocessed before being tokenized. 2012-07-07 11:21:08 -07:00
PKEuS 7c1b0a7602 Issue useInitializationList message only on variables of class types. 2012-06-06 03:03:51 -07:00
PKEuS f5ef6f255e Hande try and do in initialization list usage check (#3823) 2012-05-22 01:35:56 -07:00
PKEuS e77f348d82 New check: Suggest to use initialization list instead of assignment in constructor. (#489) 2012-05-18 07:54:58 -07:00
PKEuS 4825f78663 Fixed #2477 and #2669 2012-05-17 02:15:21 -07:00
PKEuS 3f5712bfb8 Fixed false positive "Function can be const" when 'this' is passed to a Memberfunction 2012-05-17 01:49:52 -07:00
PKEuS ea601ef2b0 Fixed false positives about const correctness caused by incorrect handling of default arguments 2012-05-17 01:05:36 -07:00
PKEuS 6a05ad1cf8 Improved fix for #2698 and added test case 2012-05-16 12:36:05 -07:00
PKEuS 77df633904 Improved handling of function calls in const correctness check: Fixed #2702, #2698, #2729. 2012-05-16 11:57:12 -07:00
PKEuS 4871cef351 Refactorized test cases for uninitMemberVar check:
- Moved all test cases to a single file (testconstructors.cpp)
- Removed some redundant test cases that became unnecessary after the symbolDatabase was established as independant from this check
2012-05-15 02:36:27 -07:00
PKEuS 42fd19fb37 Refactorization in checkclass.cpp:
- Improved handling of pointers and constants in constructor checking (-> Fixed #3801)
2012-05-14 12:50:23 -07:00
PKEuS ec00824fd3 Fixed #3357:
- Print "inconclusive" tag in cli
- Fixed inconclusive handling in checkbufferoverrun.cpp
- Merged reportInconclusiveError into reportError by adding an additional parameter "bool inconclusive" which is false per default
2012-05-06 10:37:41 -07:00
PKEuS 31a252b057 Fixed #3746: Issue operatorEqToSelf error only if the operator takes an object of the class as argument. 2012-04-25 20:25:51 +02:00
PKEuS af80344ab7 Refactorizations in checkclass.cpp:
- Removed local isVirtual implementation in checkclass.cpp, use Function::isImplicitlyVirtual instead
- Don't bailout when we see C++-style casts in checkConst
- Don't bailout for this pattern "any << member << any"
- Improved/Fixed some test cases (-> #1305)
2012-04-18 18:51:38 +02:00
Ettl Martin 09d41b2f84 ticket 2669: added todo testcase 2012-04-17 00:31:32 +02:00
PKEuS b964551424 Fixed #3252
Make use of std::isupper instead of custom implementation
2012-03-24 13:48:33 +01:00
PKEuS bf776044d8 Fixed compiler error 2012-02-17 16:09:24 +01:00
Kamil Dudka e09b0330e4 Class: Don't warn about uninitialized union members because they are often combined with a second variable 2012-01-08 12:17:55 +01:00
Reijo Tomperi 8cae17fda8 Update year to 2012 2012-01-01 01:05:37 +02:00
PKEuS dca03c3ce2 Remove unnecessary includes
Also add a unit test related to #3427
Also improve the description text in checkclass and remove unused variable.
2011-12-23 23:31:48 +02:00
PKEuS e5427fe487 Fixed #3048, further improvements to const correctness check. 2011-12-15 20:18:52 +01:00
PKEuS 00d6a0e877 refactorizations for CheckClass and for less false negatives related to derived classes 2011-12-14 21:11:40 +01:00
PKEuS 8ed8206b44 Fixed #3296 (false positive (inconclusive): 'C::operator=' should return 'C &') 2011-12-14 15:37:43 +01:00
Daniel Marjamäki 323019c48f Fixed #3355 (False positive: member variable initialization (::ZeroMemory)) 2011-11-30 21:28:16 +01:00
Thomas Jarosch 0722da026f Run astyle 2011-11-24 10:08:21 +01:00
Richard Quirk b0574cd02e Fix ticket #2233 (unused private static function) 2011-11-23 21:28:08 +01:00
Daniel Marjamäki 1b1fd9d39c Fixed #3196 (False positive: member variable not initialized in constructor (union)) 2011-11-22 19:26:00 +01:00
Daniel Marjamäki add2b3706b Fixed #3352 (False positive: member variable not initialized (3D array)) 2011-11-22 18:45:25 +01:00
Daniel Marjamäki 648fcb9e42 operator= should return reference: Made check inconclusive. See ticket #3296 2011-11-21 08:00:10 +01:00
Daniel Marjamäki 77925dc629 Class checking: made 'technically function x can be const' inconclusive 2011-11-20 16:54:06 +01:00
Edoardo Prezioso 68cb7a2731 Fix all the test failures caused by my previous commit. 2011-10-30 11:27:27 +01:00
Edoardo Prezioso 44a234f9b0 Fixed lots of test failures caused by my previous commit.
There are still some which I don't know how to fix.
2011-10-30 11:21:46 +01:00
Richard Quirk b88d61dcb4 Make single-argument test constructors explicit 2011-10-29 18:17:25 +02:00
Daniel Marjamäki 6f8e42a5af changed the astyle formatting flags 2011-10-13 20:53:06 +02:00
Kimmo Varis 3cfe7ca1a7 Move "information" errors to "style" errors.
"information" severity is documented in lib/errorlogger.h as:

  Checking information.
  Information message about the checking (process) itself. These
  messages inform about header files not found etc issues that are
  not errors in the code but something user needs to know.

It IS NOT for errors in the code. All the current "information"-
severity errors fit nicely into description of the "style"-
severity.

We definitely need to separate processing information and actual
errors in the code. It is highly confusing for users to mix these
two different things. Hence all current "information" code error
messages are moved to "style" category.

Ticket: #3165 (Stop misusing the 'information' error severity!)
2011-10-05 20:44:00 +03:00
Robert Reif 272783347b another variation of false negative from #3149 2011-09-30 16:26:08 -04:00
Robert Reif 1dcb8b2382 really fix #3149 (false negative: Technically the member function 'A::f' can be const.) 2011-09-30 11:16:34 -04:00
Robert Reif 556d523e4f fix #3149 (false negative: Technically the member function 'A::f' can be const.) 2011-09-29 20:16:52 -04:00
Robert Reif 540207533b fix #3008 (New check: Order of initialisation list) 2011-09-27 21:07:37 -04:00
Robert Reif 1717bda382 fix wrong information about constness of function 2011-09-16 18:07:25 -04:00
Robert Reif 2bc7da2c64 quick fix for #3114 (infinite recursion when operator= is overloaded) 2011-09-14 19:04:06 -04:00
Edoardo Prezioso 1ff7410f4f Fixed #3075 (False positive => Improve tokenizer: remove redundant code after a 'return' state) 2011-09-13 07:55:47 +02:00
Robert Reif 2d952c65e4 fix #3051 (False positive: operator= should return reference (when function takes pointer argument)) 2011-08-28 11:14:15 -04:00
Robert Reif 9a0d076295 fix #3052 (False Positive - Technically the member function 'Example::Clear' can be const.) 2011-08-28 09:21:00 -04:00
Robert Reif 1d7ab77251 fix #3043 (False Positive - Member variable 'ProgramRecPriorityInfo::profile' is not assigned a value in 'ProgramRecPriorityInfo::operator=') 2011-08-25 23:27:10 -04:00
Robert Reif dfe89f395a fix #3049 (False Positive - Technically the member function 'VideoOutputNull::SetupDeinterlace' can be const.) 2011-08-25 19:13:53 -04:00
Robert Reif c7cb38b0b5 fix #3040 (False positive - Technically the member function 'PSIPTable::SetSection' can be const.) 2011-08-22 20:34:00 -04:00
Kimmo Varis cfcfa3f000 Use "enabled" list for the style checking.
Settings-class currently enables style checking via dedicated
boolean attribute. All other CLI's enable-options are handled
through the enable-list. This commit moves style-check enabling
to use the enable-list.

Main advantage is the consistency how options are handled/stored
in the Settings class. Which also unifies using them for the other
code. You need to enable certain type of checks? Use the
addEnabled()-method. You want to check if certain type of checks
are enabled? Use the isEnabled()-method.
2011-08-07 10:28:52 +03:00
Robert Reif ac6d67dc4d add support for using global qualified :: memset on class and class member initialization 2011-08-04 20:37:27 -04:00
Robert Reif c6a804d306 add std::*.empty() to possible const functions in CheckClass::checkConstFunc 2011-07-30 09:44:20 -04:00
Robert Reif 74c1bdde77 fix #1593 (false negative: the function can be declared as const) 2011-07-30 08:48:11 -04:00
Robert Reif ca2e8b057b fix #2947 (False positive: member variable is not initialized (a[x::y] = 0;)) 2011-07-27 12:03:44 -04:00
Robert Reif 54141f2e7f fix #2943 (Symbol database: Wrong parsing of std::vector as base class.) 2011-07-27 11:23:22 -04:00
Robert Reif 77859b9a0f fix #2878 (derived global class not tokenized properly (class A : ::B { };)) 2011-06-30 07:25:36 -04:00
Robert Reif 443dd4c392 partial fix for #2867 handle derived class 2011-06-29 19:39:19 -04:00
Robert Reif f403de7bad partial fix for #2867 Tokenizer::removeRedundantAssignment didn't understand function local class and removed class variable 2011-06-28 19:48:28 -04:00
Robert Reif 0f6da27b9f fix #2795 (hash operator[] is not 'const') (original patch by Sebastien Debrard) (modified to use the symbol database) 2011-06-03 22:00:27 -04:00
Robert Reif 42316f3e0b fix #2792 (false positive: Member variable 'class::m_val' is not assigned a value in 'class::operator=') 2011-05-24 20:25:34 -04:00
Robert Reif bd03768415 move symbol database tests to testsymboldatabase.cpp 2011-04-28 21:03:57 -04:00
Robert Reif 6abf29bd22 fix spelling of initialized in checkclass messages 2011-04-26 20:37:16 -04:00
Greg Hewgill 3fc1db51d1 Change symbol database such that the typestart token skips over type modifiers (const/static/mutable).
This fixes checking for the case of a memset() on a static variable.
2011-04-23 01:13:23 +12:00
Daniel Marjamäki 061eab4d22 Virtual destructors: Enabled the check again. I think it is conclusive now. Ticket: #2728 2011-04-20 18:03:16 +02:00
Daniel Marjamäki e5d43d4ed2 Renamed Settings::stupid to Settings::experimental 2011-04-10 15:55:08 +02:00
Daniel Marjamäki 30ee9ba6e4 Added Settings::stupid flag that can be used to hide checking that generates false positives. 2011-04-10 13:23:45 +02:00
Robert Reif 3c8644fcf8 added tests for #2710 (False negative on uninitialized member variable in a ctor.) 2011-04-08 07:39:30 -04:00
Robert Reif cf65a73c47 fix CheckClass::operatorEq to check return type more closely (to match check description) 2011-03-31 19:40:28 -04:00
Robert Reif 1e1434e191 make member variable change detection simpler and more accurate for CheckClass::checkConst 2011-03-27 13:59:12 -04:00
Robert Reif 168db82fd6 better checking of assignment to array element in CheckClass::checkConstFunc 2011-03-25 23:02:13 -04:00
Robert Reif f8e1735b0f add support to CheckClass::checkConstFunc for ++/-- array elements 2011-03-25 22:37:32 -04:00
Robert Reif 6e6c86365f add some missing ; at end of class and struct definitions in checkclass tests 2011-03-25 07:58:51 -04:00
Robert Reif 61e720c82b fix #1288 (Use of memset on struct - nested structs not handled) 2011-03-23 21:58:58 -04:00
Robert Reif 7e3e5d628d better fix for #2672 (False positive: function can be const, nested classes declared in one line) 2011-03-23 20:19:32 -04:00
Robert Reif ac7f1f874e add some more CheckClass::noMemset tests 2011-03-22 22:45:19 -04:00
Robert Reif d36ed9aff1 fix #2670 (False positive: function can be const, overloaded functions) 2011-03-22 19:23:36 -04:00
Robert Reif 2277cb6965 fix #2663 (False negative: function can be const (changing unknown or uninitialised variable)) 2011-03-20 13:29:52 -04:00
Robert Reif 41d80b5c8d fix #2664 (False negative: function can be const (using type from another namespace)) 2011-03-20 12:53:37 -04:00
Robert Reif 1de35c168d fix #2657 (segmentation fault of cppcheck ( gcc-testsuite: return f(){} )) 2011-03-17 20:10:56 -04:00
Robert Reif 7e04ea0859 fix removal of throw() from const functions 2011-03-16 19:54:52 -04:00
Robert Reif 47531dd99c fix #2637 (segmentation fault of cppcheck ( {} const const )) 2011-03-15 22:33:14 -04:00
Greg Hewgill fa868e44ae Support use of 'this->' when checking operator=() return type 2011-03-15 20:19:30 +13:00
Robert Reif 27f4b8b88b Convert CheckClass::noMemset to use the symbol database to lookup types. This adds better support for namespaces and nested classes. 2011-03-12 22:41:21 -05:00
Greg Hewgill 1ec6a642dc Revert "Check for memset on nested structs (ticket #1288)"
Turns out this fix is incomplete.

This reverts commit a084697410.
2011-03-10 20:19:31 +13:00
Greg Hewgill a084697410 Check for memset on nested structs (ticket #1288) 2011-03-09 23:02:49 +13:00
Greg Hewgill 3883afcbf4 Check for memset on objects with virtual functions (ticket #607) 2011-03-09 22:10:39 +13:00
Greg Hewgill 70b4076111 refactor noMemset so it recursively checks parent classes for non-memset-compatible things 2011-03-09 21:29:30 +13:00
Robert Reif f596a6959e code cleanup and add more tests to CheckClass::noMemset() 2011-02-24 19:59:50 -05:00
Chuck Larson db7ce1c13c memset: using memset on struct/class that has std::string member variable. ticket: #1655 2011-02-24 18:38:45 +01:00
Robert Reif 5f84272a52 fix segfault: #2591 (cppcheck hangs with 100% cpu load ( class A : )) 2011-02-21 14:25:35 -05:00
Robert Reif 5984b6b53f fix #2595 (False positive Technically the member function 'A::foo' can be const) 2011-02-20 20:01:54 -05:00
Robert Reif fef1142997 fix #2592 (False positive: 'operator=' should return reference to self) 2011-02-19 20:02:16 -05:00
Robert Reif e6eb160395 fix [B#2589 (segmentation fault of cppcheck (struct B : A)) 2011-02-19 14:38:00 -05:00
Daniel Marjamäki 53aaf22633 CheckClass::noMemset: Added TODO test case 2011-02-16 21:31:35 +01:00
Robert Reif 2aefa5deb5 fix #2577 (segmentation fault of cppcheck) 2011-02-12 15:35:48 -05:00
Daniel Marjamäki 26f017e9c6 scripts: added tabs.pl - in my opinion it is bad to use tabs inside string constants. spaces or \t should be used instead. 2011-02-05 12:53:28 +01:00
Robert Reif c592ccd35d Fixed #2547 (segmentation fault of cppcheck) 2011-02-05 08:59:59 +01:00
Robert Reif f87056fca3 Fixed #2539 (segmentation fault of cppcheck) 2011-02-04 20:19:49 +01:00
Robert Reif 8288c28b3f Fixed #2537 (segmentation fault of cppcheck) 2011-02-03 07:57:10 +01:00
Pete Johns 098f0bf3e6 Fixed #2526 (Make TODO_ASSERT_EQUALS take three arguments (value, to_be, as_is)?...
Removed replaced EXPECTED with...

WANTED (to-be):     The future expected value.
CURRENT (as-is):    Documenting how cppcheck behaves now.

This removes the need for an ASSERT_EQUALS but enforces the check for every TODO_ASSERT_EQUALS.
2011-01-30 23:20:11 +11:00
Daniel Marjamäki 524498e439 Tokenizer: collapse operator function names into a single token. ticket: #2519 2011-01-27 18:44:20 +01:00
Robert Reif 767e01e24a Fixed #2478 (Crash when trying to analyze files (CheckClass::checkReturnPtrThis)) 2011-01-21 19:54:41 +01:00
Pete Johns 38c37ad2d8 Moved array declaration detection into isVariableDeclaration() 2011-01-17 08:36:52 +11:00
Robert Reif 0f6644e1ea Symbol database: Refactorings 2011-01-16 11:18:12 +01:00
Robert Reif 79b9939610 Fixed #2465 (False positive: not initialised variable, but there is default constructor for it.) 2011-01-15 07:59:37 +01:00
Reijo Tomperi 226b605774 Change year 2010 -> 2011 in license texts. 2011-01-09 21:33:36 +02:00
Robert Reif 5f078da7ad Fixed #2425 (segmentation fault of cppcheck) 2011-01-07 18:58:14 +01:00
Robert Reif 03a484554c Fixed #2415 (false positive: Member variable not initialized in constructor calling assignment operator) 2011-01-06 07:56:34 +01:00
Daniel Marjamäki 033e759c39 command line: added 'information' id to enable 2011-01-05 21:20:21 +01:00
Markus Elfring e459ed1de3 Fixed #2389 (mistakable warning from 'CheckClass::uninitVarError') 2011-01-03 19:03:42 +01:00
Daniel Marjamäki 3c238882a2 Fixed TODO testcase. Use symbol database instead of token list. Ticket: #2375 2011-01-01 17:54:37 +01:00
Pete Johns 502cfe7243 Fixed #2384 ("The function 's::f' can be const" reported for pointer-to-pointer)
Moved check for pointer variables into isVariableDeclaration()

Can now handle multiple scopes and multiple levels of indirection. Simplified check for strucs and unions, too, reducing the size of getVarList().

skipScopeIdentifiers() and skipPointers() should probably be methods on class Token.
2010-12-31 22:12:32 +11:00
Pete Johns 5d0ace3a50 Fixed #2377 (Technically the member function xxx can be const)
TODO: Add unit test for getVarList() and refactor variable check.

[Removed my testcase for #2377 and removed two TODOs.]
2010-12-30 17:56:28 +11:00
Ettl Martin ac42c0ba3b const correctness: added further testcases for increment/decrement member functions 2010-12-30 02:05:44 +01:00
Ettl Martin 7b92378c3a ticket 2377: added further testcases 2010-12-30 01:44:46 +01:00
Ettl Martin c29824fc49 added todo testcase for ticket 2377 Technically the member function xxx can be const 2010-12-30 01:29:09 +01:00
Robert Reif 3f1f50e970 simplifyTypedef: operator typedef. Ticket: #2375 2010-12-29 20:22:06 +01:00
Daniel Marjamäki 3853f93b34 TestClass: addon for 12f28507, fix a few more error messages. 2010-12-27 08:22:21 +01:00
Kimmo Varis 12f2850777 Improve the message about const function.
See discussion thread:
https://sourceforge.net/apps/phpbb/cppcheck/viewtopic.php?f=3&t=192
2010-12-26 23:44:03 +02:00
Daniel Marjamäki be46d453c4 Information: Added new severity 2010-12-22 19:53:17 +01:00
vBm 46a11183a5 Fixed some spelling mistakes 2010-12-15 18:45:53 +01:00
Robert Reif 980a90071c Fixed #2282 (Improve check: Function can be const) 2010-12-07 19:42:30 +01:00
Robert Reif c20b8831ee Fixed #2275 (False Positive: Member variable not initialized in the constructor) 2010-12-04 20:24:13 +01:00
Robert Reif 04b811b74f Fixed #2273 (False Positive: Member variable not initialized in the constructor) 2010-12-04 17:47:00 +01:00
Robert Reif 2cd8bc74cc Symbol database: The symbol database has a bug where it can find an out of line constructor when looking for a destructor. Ticket: #2272 2010-12-03 07:35:06 +01:00
Robert Reif 1bc8a2b6ba Fixed #2172 (False positive: struct is not initialized in constructor) 2010-12-02 07:35:01 +01:00
Robert Reif f12c0c7ada Tokenizer: add assert(_settings) to Tokenizer to insure the tokenizer always has settings. Ticket: #2219 2010-12-01 18:00:55 +01:00
Robert Reif 43dcc51752 Fixed #2252 (segmentation fault with enable=all) 2010-11-30 19:52:42 +01:00
Robert Reif f90236a183 Fixed #2252 (segmentation fault with enable=all) 2010-11-30 19:40:32 +01:00
Kimmo Varis 87b69a10fa Ticket #2240 (Improve no constructor-message).
Improve the message about missing constructor but having class
attributes. Have proper short and long messages.
2010-11-27 10:17:03 +02:00
Robert Reif 03b12c5494 Fixed #2230 (segmentation fault of cppcheck) 2010-11-25 07:43:39 +01:00
Robert Reif 08b86e0b7e Fixed #2228 (False positive: Claims function can be const when it can not be (shared_ptr)) 2010-11-25 07:15:33 +01:00
Robert Reif f1eef49fcb Fixed #2221 (segmentation fault of cppcheck) 2010-11-23 07:31:15 +01:00
Robert Reif 36b03bdd3e Fixed #2179 (Segmentation fault in assignment operator) 2010-11-09 06:58:19 +01:00
Daniel Marjamäki c2bf3647a4 Fixed #2178 (segmentation fault of cppcheck) 2010-11-08 19:47:19 +01:00
Robert Reif 662cd27f87 Symbol database: fixed problem 2010-11-06 20:27:12 +01:00
Robert Reif 003f99da82 Symbol database: Fixed bug. Ticket: #2149 2010-11-04 06:58:37 +01:00
Robert Reif cf0403434d Symbol database: Bug fix 2010-11-03 20:33:07 +01:00