Commit Graph

400 Commits

Author SHA1 Message Date
Daniel Marjamäki 77925dc629 Class checking: made 'technically function x can be const' inconclusive 2011-11-20 16:54:06 +01:00
Edoardo Prezioso a32b05197d Change every 'tokAt(1)' to 'next()' and every 'tokAt(-1)' to 'previous()'.
Added a safety check to ensure that a 'previous()' call doesn't crash (not sure if it's needed or not).
2011-11-20 15:59:37 +01:00
Edoardo Prezioso 11dd3c09ce Change every 'tokAt(1)->' to 'next()->' because 'tokAt(1) == 0' is equivalent to 'next() == 0', hence the equivalent cppcheck crash. 2011-11-20 15:09:57 +01:00
Edoardo Prezioso 42e369a4b4 Change every 'tokAt(..)->link()' to 'linkAt(..)'. 2011-11-20 14:24:27 +01:00
Edoardo Prezioso 2c64d299ca Change every 'tokAt(...)->str()' to 'strAt(...)'. 2011-11-13 13:10:59 +01:00
Daniel Marjamäki af7bf5c805 removed 'explicit constructors' check. see comments in pull request #51 for the reasons. 2011-11-02 17:12:46 +01:00
Edoardo Prezioso 9dd3360cd6 Fix some complainted choices made in my older commits.
Note: probably you should do 'make clean' before using 'make' to rebuild it again. Maybe it's me but 'make' reports various errors when linking.
2011-11-01 13:23:47 +01:00
Edoardo Prezioso 433f4640a9 Fix some GCC warnings regarding the sign conversion. 2011-10-30 18:34:49 +01:00
Edoardo Prezioso 4fc7e86d7d Fixed: with checkConst and checkVariableScope wanted still required "information" settings instead of "style". 2011-10-30 10:58:15 +01:00
Richard Quirk 2ca932a3ae Add checks for explicit constructors
Single-argument constructors should be explicit. Constructors with
multiple arguments should not be marked explicit.
2011-10-29 18:24:16 +02:00
Thomas Jarosch 434fb933a8 Implement Token::findsimplematch und use it for simple patterns 2011-10-27 15:59:22 +02:00
Thomas Jarosch 54adb910ec Use Token::simpleMatch instead of Token::Match for simple patterns 2011-10-27 15:59:22 +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 2670525b4f better fix for #3114 (infinite recursion when operator= is overloaded) 2011-09-14 19:58:11 -04:00
Robert Reif 2bc7da2c64 quick fix for #3114 (infinite recursion when operator= is overloaded) 2011-09-14 19:04:06 -04: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 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 e687ee9a9a assume all std::*::size() and std::*::empty() are const in CheckClass::checkConstFunc() 2011-07-30 10:30:31 -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 6eecab5d73 fix #2807 (Wrong handling of function references when prefixed with &) 2011-06-29 07:19:34 -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 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
Robert Reif 79e5d2db15 run astyle 2011-04-20 19:07:28 -04: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 77aebd357e Refactoring: add Token::isAssignmentOp and use it in CheckClass::checkConstFunc 2011-04-09 14:36:05 -04:00
Robert Reif a39444a40f change CheckClass::operatorEqToSelf to make better use of the symbol database 2011-03-31 19:53:35 -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 dd5e15b40c output a debug message when a member variable is used that has a varid of 0 2011-03-27 14:27:14 -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 c27ecf5aeb only break when we know we are inc/dec a member variable in CheckClass::checkConstFunc 2011-03-25 23:22:28 -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 ca50bc7850 move 2 CheckClass helper functions to follow externally called functions so code matches comments 2011-03-25 22:21:40 -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 14c07e988e fix pointer/reference check in CheckClass::noMemset symbol database conversion 2011-03-22 22:29:39 -04:00
Robert Reif 5314cc02b2 convert remainder of CheckClass::noMemset to use symbol database 2011-03-22 22:23:57 -04:00
Robert Reif 468a983db1 use the symbol database to look up base classes in CheckClass::noMemset check 2011-03-22 21:24:28 -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
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
Robert Reif 79f0fe7d1c refactor symbol database and checks to use list of Scope rather than list of Scope pointers 2011-03-10 19:43:29 -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 31a18b9b23 convert CheckClass::noMemset to use new variable lookup capability 2011-02-26 16:00:05 -05: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 ba6c2ca310 fix #2602 (segmentation fault of cppcheck ( class A {A& operator=(const A&); }; )) 2011-02-22 06:47:28 -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 537ac0cb34 use func->start rather than searching for '{' in CheckClass::privateFunctions 2011-02-20 08:36:06 -05:00
Robert Reif 7dd8a3283a fix comment in CheckClass::initializeVarList 2011-02-19 20:09:07 -05:00
Robert Reif fef1142997 fix #2592 (False positive: 'operator=' should return reference to self) 2011-02-19 20:02:16 -05:00
Daniel Marjamäki 227a6100f7 astyle formatting 2011-02-11 19:31:37 +01:00
Robert Reif b8c5426bb8 fix #2567 Unused private function when implemented in different file 2011-02-11 08:00:41 -05:00
Raphael Geissert f8e2d50e6f Use Token::simpleMatch where no special patterns are needed 2011-02-02 13:27:02 -06:00
Raphael Geissert 8d5863133c Use Token::simpleMatch where no patterns are used 2011-02-02 13:27:01 -06:00
Raphael Geissert cf2b6f7bc1 Remove useless spacing at the end of *Match strings 2011-02-02 13:27:01 -06:00
Greg Hewgill be195a72c9 initialise Check::_name in constructor rather than relying on virtual Check::name() 2011-02-02 22:58:25 +13:00
Daniel Marjamäki 524498e439 Tokenizer: collapse operator function names into a single token. ticket: #2519 2011-01-27 18:44:20 +01:00
Daniel Marjamäki 1e25d74ba4 Class: better check if there are friends. ticket: #2459 2011-01-22 17:35:54 +01:00
Daniel Marjamäki 9551332321 Fixed #2459 (False positive with unused private function and friend) 2011-01-22 13:00:03 +01:00
Robert Reif 767e01e24a Fixed #2478 (Crash when trying to analyze files (CheckClass::checkReturnPtrThis)) 2011-01-21 19:54:41 +01:00
Robert Reif d73709a620 Symbol database: rename variables. ticket: #2468 2011-01-21 07:42:41 +01:00
Pete Johns 94aafa482c Fixed #2480 (false positive on unused private function) 2011-01-19 20:32:08 +11:00
Pete Johns ea01c04108 Added parenths to fix build breakage. 2011-01-18 21:07:33 +11:00
Robert Reif 8631ee65a3 Fixed #2474 (false positive: Member variable 'A::m_SemVar' is not initialised in the constructor.) 2011-01-18 07:34:11 +01:00
Robert Reif c994508c3e Symbol database: Refactor the variables API. ticket: #2468 2011-01-18 07:32:06 +01:00
Robert Reif 959e10cee5 Symbol database: renamed classes. ticket: #2468 2011-01-17 18:29:19 +01:00
Robert Reif bf9528558e Symbol database: pulled out classes into global scope. ticket: #2468 2011-01-17 07:21:59 +01:00
Robert Reif d341b42b0c Symbol database: increased constness. ticket: #2468 2011-01-16 18:13:54 +01:00
Robert Reif 66be74a5af Symbol database: Refactorings. Move check-specific code to check. Ticket: #2468 2011-01-16 16:37:11 +01:00
Daniel Marjamäki a97e28491f Fixed #2407 (False positive: unused private function) 2011-01-16 12:16:31 +01:00
Robert Reif 0f6644e1ea Symbol database: Refactorings 2011-01-16 11:18:12 +01:00
Reijo Tomperi 226b605774 Change year 2010 -> 2011 in license texts. 2011-01-09 21:33:36 +02: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
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 b6acfa809b Symbol database: creates a single symbol database within Tokenizer on demand and changes all checks to use it 2010-12-07 07:08:49 +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 1bc8a2b6ba Fixed #2172 (False positive: struct is not initialized in constructor) 2010-12-02 07:35:01 +01:00
Kimmo Varis 1a3175741f Fixed #2268 ([GUI] Generic class name is shown for 'Message' while correct one for 'Summary') 2010-12-01 17:55:22 +02: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 1842a122da reuse symbol database in checkmemoryleak.cpp. ticket: #2219 2010-11-23 18:41:07 +01:00
Robert Reif 27cae2f0d7 Symbol database: add global space and add all global functions and variables to it. Ticket: #2198 2010-11-20 07:26:50 +01:00
Robert Reif 77a5d4e399 Fixed #2204 (False positive when using const class members) 2010-11-16 07:30:55 +01:00
Robert Reif 6a06970e1b CheckClass: Refactoring - organize each check so the check function comes first, any helper functions come second, and the message functions come last. Ticket: #2198 2010-11-14 06:50:33 +01:00
Robert Reif 894586f4dd Fixed #2198 (SymbolDatabase: separate SymbolDatabase from CheckClass) 2010-11-13 07:31:56 +01:00
Robert Reif 0fffa1f651 This patch fixes a bug I introduced in the previous patch. It also speeds up nested class parsing by skipping the entire class implementation using { link to jump to } rather than parsing for }. Ticket: #2172 2010-11-12 19:29:20 +01:00
Robert Reif 4ddf6f3b44 Symbol database: code cleanups 2010-11-10 16:52:52 +01:00
Daniel Marjamäki 508c171945 Symbol database: add support for class inline functions with classes 2010-11-09 17:06:07 +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 23b50a3d81 Symbol database: delay finding class variables until after all classes have been found. 2010-11-08 17:12:25 +01:00
Robert Reif 662cd27f87 Symbol database: fixed problem 2010-11-06 20:27:12 +01:00
Robert Reif 0205498a12 Symbol database: improved handling of out of line functions returning function pointers 2010-11-06 13:31:56 +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
Robert Reif 0fe72839d8 Symbol Database: Better handling of namespaces. Ticket: #2149 2010-11-02 18:30:57 +01:00
Daniel Marjamäki 9435fde551 Tokenizer: Added function for checking if code is Java/C# 2010-10-28 18:51:55 +02:00
Daniel Marjamäki fee20bafa0 Java: Removed bailout added in 120073f000 2010-10-28 18:01:51 +02:00
Robert Reif b6aca47e11 Fixed #1195 (Uninitialized member variable not detected 'std::vector<int> *ints;') 2010-10-27 19:28:15 +02:00
Robert Reif 5a8f490f07 Fixed #2135 (False positive 'Can be const') 2010-10-27 19:25:34 +02:00
Daniel Marjamäki cf86e11d05 Fixed #2111 (Class methods writing to a union are detected as 'can be const') 2010-10-24 16:43:10 +02:00
Daniel Marjamäki 120073f000 Java: fixed false positives about uninitialized variable 2010-10-23 10:56:30 +02:00
Daniel Marjamäki 6a66d32871 JAVA: better handling of java code 2010-10-20 22:15:35 +02:00
Ettl Martin 7d1995dfaa Merge branch 'master' of github.com:danmar/cppcheck 2010-10-17 21:56:05 +08:00
Daniel Marjamäki 92a1e9e76e Severities: Added 'warning' and 'performance' severities. No changes to the command line options nor to the XML format. Ticket: #2106 2010-10-17 14:41:00 +02:00
Ettl Martin f25f3c64b4 fixed style waring (You should use ++ and -- as prefix whenever possible as these are more efficient than postfix operators) in lib/checkclass.cpp 2010-10-17 20:15:29 +08:00
Robert Reif a58094e827 Fixed #2089 (False negative: Function can be const (calling const function)) 2010-10-13 07:26:41 +02:00
Robert Reif 907ed0ac6f Fixed #2085 (False negative: function can be const when member variable is compared) 2010-10-12 07:57:09 +02:00
Robert Reif a6e915f0cd Fixed #2081 (false negative: the function can be declared as const) 2010-10-11 17:43:36 +02:00
Daniel Marjamäki 14f12e0647 Fixed #2078 (false negative: member variable not intialized) 2010-10-10 07:57:26 +02:00
Daniel Marjamäki 6eeed00888 Fixed #2067 (Template methods do not 'use' private ones) 2010-09-30 21:22:49 +02:00
Daniel Marjamäki 21bf58f1ec Optimisation: small optimisation of CheckClass::privateFunctions 2010-09-20 19:43:03 +02:00
Daniel Marjamäki a7cf68b9ef Check Class: Removed the 'operator= should not return a const reference' 2010-09-18 20:05:34 +02:00
Robert Reif 0153dccb66 Symbol database: Skip bail out in constructors if a virtual function might be called because that would be undefined behaviour. Ticket: #1895 2010-09-14 07:16:53 +02:00
Robert Reif 6de1711515 Symbol database: reduce false negatives for 'uninitialized variable' when calling base class function. ticket: #1895 2010-09-12 22:40:51 +02:00
Robert Reif 69afc0a0db Symbol database: fixed false positive. ticket: #1895 2010-09-11 08:23:30 +02:00
Robert Reif 5a6eff90d1 Symbol database: Refactoring. ticket: #1895 2010-09-10 07:02:49 +02:00
Robert Reif 6d35396720 Symbol database: refactoring - differentiate between member data initialization and assignment and save the order of variable declarations. makes it possible to create some additional checks. ticket: #1895 2010-09-09 07:26:40 +02:00
Robert Reif c3762903a9 Symbol database: fixed false negative for uninitialized variable. ticket: #1895 2010-09-09 07:21:51 +02:00
Daniel Marjamäki 3a4cda0f0d Fixed #2034 (false positive: unused private function (Borland C++ __property)) 2010-09-07 18:37:43 +02:00
Robert Reif 28c5893ee0 const functions: fixed false negatives for the type P. ticket: #1884 2010-09-06 19:04:14 +02:00
Robert Reif 80fdf1ca51 Symbol database: Fixed false negatives for unused private functions. Ticket: #1895 2010-09-02 19:22:54 +02:00
Robert Reif cb318c21e3 Symbol database: adds support for inline functions returning function pointers and starts to convert privateFunctions over to the symbol database. Ticket: #1895 2010-09-02 07:40:20 +02:00
Robert Reif 4153b7d24b refactoring namespace handling. ticket: #2001 2010-09-01 16:47:53 +02:00
Robert Reif 7a8190e188 Fixed #2002 (Wrong operator() parsing) 2010-09-01 06:32:46 +02:00
Robert Reif 4463f650d0 Fixed #2003 (false positive in set functions) 2010-08-31 17:59:17 +02:00
Robert Reif 5aab602709 Fixed #2001 (No 'The function ... can be const' warnings when base class is in namespace.) 2010-08-31 17:57:42 +02:00