Commit Graph

235 Commits

Author SHA1 Message Date
Robert Reif bbfd676b4e speed up checks by caching commonly looked up stuff in the symbol database 2012-10-10 20:42:07 +02:00
Robert Reif 8ccbde117a Fixed #4261 (CheckOther::checkComparisonOfFuncReturningBool using wrong function scope test) 2012-10-08 16:15:07 +02:00
XhmikosR 6e4e3dfbfb lib: tabs to spaces, remove trailing spaces and extra empty lines at the end of files 2012-09-17 13:51:23 +02:00
PKEuS 22a8e3f4e6 Replaced Tokenizer::getFunctionTokenByName() by SymbolDatabase::findFunctionByName(), which handles scopes slightly better. 2012-09-11 18:03:47 +02:00
PKEuS e9f13e1547 Fixed false positive #4163 2012-09-10 16:14:24 +02:00
PKEuS 8a474add19 Fixed compilation error - added missing function in symboldatabase. 2012-09-02 14:30:00 +02:00
Daniel Marjamäki d7e521845b SymbolDatabase: Made function static after self-check suggestion 2012-09-01 10:46:09 +02:00
Ettl Martin 98d608231d spelling fixes 2012-07-31 23:35:56 +02:00
Edoardo Prezioso fae40c4782 Change every C version of 'size_t' to C++ 'std::size_t'. 2012-07-09 13:30:18 +02:00
Daniel Marjamäki 8aba801360 Fixed #3800 (False negative: Self-assignement of variable declared as 'extern') 2012-06-22 11:23:50 +02:00
Edoardo Prezioso 57ade25099 Fixed checkio.cpp warning in #2123. 2012-06-18 13:08:01 +02:00
PKEuS 4b80e91145 Implemented support for building cppcheck lib into a dll
Updated VS9 solution
New VS10 solution that builds cppcheck into a dll used by cli and testrunner.
Functional changes and advantages of new solution:
- Share code between testrunner and cli; ability to share code with gui as well (not yet implemented)
- Files of /lib are no longer compiled twice (should improve build time on single core machines)
- Added configuration for building with PCRE support
- Executables are build into /bin (/bin/debug in debug mode) folder (Should no longer require rebuild when switching between debug and release)
- Completely x64 compatible (contains also x64-debug configuration now)
2012-06-10 05:19:09 -07:00
PKEuS e2bab4b6a3 Implemented Function::nestedIn to be able to identify the scope the function belongs to, even if Function::functionScope.functionOf is not available.
Refactorized usage of SymbolDatabase in checkOther:
- Don't copy Function instances in checkExpressionRange
- Simplifications by more accurate usage of information in database
2012-05-24 08:40:43 -07:00
PKEuS dc64ac2918 Removed unnecessary variable Function::start - The value is already stored in Function::functionScope->classStart. 2012-05-22 12:58:46 -07:00
PKEuS 26f5f08614 Initialize Function::start when the function is implemented, not when its defined. (Fixes #3826) 2012-05-22 12:30:10 -07:00
PKEuS de79a4c84f Fixed initialization list usage according to cppcheck results
Fixed comments mentioning nonexistent parameters
2012-05-18 07:57:11 -07:00
PKEuS 4bb2a1b27b Made some functions static or const according to cppcheck results 2012-05-17 01:33:24 -07:00
Edoardo Prezioso eacf74be8d Changed the order of some structures in order to improve, even if for a bit, their padding. 2012-05-14 20:49:03 +02:00
PKEuS 0452b03f53 Refactorizations in SymbolDatabase:
- Moved complete evaluation of variables type into one function executed when the variable is constructed
- Moved SymbolDatabase::ArrayDimensions to Variable::ArrayDimensions
2012-05-11 17:56:47 +02:00
PKEuS aec57db9b2 Fixed #3778: Added missing function Function::getArgumentVar 2012-05-03 13:29:41 +02:00
PKEuS a0d92f5ed9 Refactorizations in SymbolDatabase:
- Skip struct keywords in argument list so that Variables declared like "Struct Foo bar" get a type
- Remvoved redundant argument from Function::addArguments
- Set Function::functionScope for global functions
- Replaced some indendation counters by Token::findClosingBracket
2012-04-27 21:51:13 +02:00
PKEuS cb064dc20e Implemented generic mechanism for '<'-'>' "linkage" before link() works (Taken from Scope::findClosingBracket, but C++11 right angle bracket support added): Token::findClosingBracket
-> Replaced several indendation-counting mechanisms in tokenize.cpp

Fixed build failure in checkclass.cpp
2012-04-18 16:02:03 +02:00
PKEuS f6fd44910a Refactorizations in SymbolDatabase:
- Replaced Scope::access by a locally stored std::map, because its a temporary status variable that is only necessary when creating the symboldatabase
- Moved SymbolDatabase::argsMatch to Function::argsMatch, because its function specific
- Improved Scope::findClosingBracket: Improved reliability, made it static and faster
2012-04-18 13:00:34 +02:00
PKEuS c6f6194008 Added Function::isImplicitlyVirtual to symboldatabase.cpp
Made SymbolDatabase::argsMatch static because its possible and necessary for Function::isImplicitlyVirtual
2012-04-17 19:50:44 +02:00
PKEuS e938235385 Store functions which are declared but not implemented in the function list of the containing scope -> Fixed #3679
Refactorizations:
- Simplified some code
- Improved condition in findVariableType to reduce unnecessary comparisions of empty strings.
2012-03-23 17:59:51 +01:00
PKEuS 9a5f66030c Improved unused private function check:
- Fixed #3628
- Added support for friend
Improved symbol database:
- friend scopes are now set
- Added findScopeByName function
Refactorizations:
- Removed some unnecessary "virtual" keywords
- Removed unnecessary _filename member variable, pass it as argument instead
- Made CppCheck::replaceAll static, since it is independant from a specific CppCheck instance, Pass string to be modified by reference
2012-02-24 20:45:56 +01:00
PKEuS 42f418db54 - Improved nullpointer check: Fixed #1171
- Improved accuracy of function analysis in symboldatabase
- Code cleanups
2012-02-11 12:26:48 +01:00
PKEuS d5c2c7db88 - Moved checkCatchExceptionByValue from CheckOther to CheckExceptionSafety
- Fixed false positive: throw outerCatchVar; in inner catch is now correctly handled
- Added eTry and eCatch to Scope::isLocal -> Scopes inside catch are now detected by symbol database
2012-02-02 16:17:42 +01:00
PKEuS 6906001366 Added support for references to symboldatabase 2012-01-26 17:04:25 +01:00
Robert Reif 4d56395504 symbol database: add simple try/catch tests 2012-01-25 22:48:18 -05:00
Robert Reif 6b0aff487f symbol database: add preliminary support for throw/catch block scopes. Just like the rest of cppcheck, ... is not handled properly for variables. Deep namespaces are also not handled properly yet. This is not an issue because this new capability is not used by any checks so it should be harmless. 2012-01-25 22:05:29 -05:00
Daniel Marjamäki 56a5e08f6b Use symbol database dump code written by Robert Reif. The symbol database is dumped if --debug is used. 2012-01-05 18:22:54 +01:00
Reijo Tomperi 8cae17fda8 Update year to 2012 2012-01-01 01:05:37 +02:00
PKEuS f306246c7f Improved support for references and pointers in SymbolDatabase
Replaced several isPointer functions by Variable::isPointer function
Refactorizations & Make use of symbolDatabase more often
2011-12-17 19:04:03 +01:00
Daniel Marjamäki 2e08c8c5b1 DJGPP: Fixed a few compiler errors by using std::size_t instead of size_t 2011-11-22 21:14:14 +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
Daniel Marjamäki 4705026242 fixed a few doxygen warnings 2011-10-16 17:16:07 +02:00
Daniel Marjamäki 6f8e42a5af changed the astyle formatting flags 2011-10-13 20:53:06 +02:00
Robert Reif d749e28dc0 another partial fix for #3063 (false negative: multi dimensional arrays not well supported) 2011-09-02 21:07:29 -04:00
Robert Reif 7775934492 really fix multi-dimensional arrays with undefined size 2011-08-28 13:32:42 -04:00
Robert Reif 0c46f44e3d add array information to symbol database 2011-06-22 22:41:11 -04:00
Robert Reif 6750c7b492 don't debug warn about class function definitions without body having missing varid on function parameters 2011-04-22 21:41:55 -04:00
Robert Reif faaff942d2 symbol database: improve function argument count and default argument count 2011-03-30 21:59:43 -04:00
Robert Reif d17a204096 symbol database: get function argument count using argument list size rather than counting commas 2011-03-30 21:14:24 -04:00
Robert Reif d643918761 symbol database: add a link from a Function to its Function Scope namd make function parameters belong to Function Scope 2011-03-24 22:08:18 -04:00
Robert Reif 15fc071514 add virtual base class support to symbol database 2011-03-21 20:03:41 -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 47a90851f1 save pointer to Function info in function scope in symboldatabase 2011-03-13 21:18:49 -04:00
Robert Reif 836fadcb6a save location of using directive (not used yet) 2011-03-13 21:01:33 -04:00
Robert Reif 384bd96766 fix false negative introduced by fix for #2641 2011-03-12 11:42:58 -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
Daniel Marjamäki e26a7819d3 Symbol database: variable fix. ticket: #2629 2011-03-06 21:21:42 +01:00
Robert Reif c9b2ab3c26 add debug message for function argument missing varid 2011-03-02 21:08:27 -05:00
Robert Reif 962183f964 add an array flag to symbol database Variable class 2011-02-27 10:21:14 -05:00
Robert Reif b74ebbda02 fix potential null pointer dereference for unnamed function arguments 2011-02-26 18:34:17 -05:00
Robert Reif 8152cbbd1b add a varId to Variable lookup table and fill it in with all variables 2011-02-26 15:57:16 -05:00
Robert Reif 7638a4554e add local scopes to the symbol database 2011-02-26 15:53:57 -05:00
Robert Reif eda25f6502 add a list of function arguments to symbol database Function class 2011-02-26 15:51:12 -05:00
Robert Reif abbd37d380 extend symbol database Variable with more information 2011-02-26 09:08:59 -05:00
Robert Reif 597aea9f15 save start of function '{' and start of variable declaration in symbol database so checks don't have to find them 2011-02-20 08:25:42 -05:00
Robert Reif 8288c28b3f Fixed #2537 (segmentation fault of cppcheck) 2011-02-03 07:57:10 +01:00
Robert Reif 79862573ba Symbol database: better unit testing. ticket: #2468 2011-01-28 08:33:02 +01:00
Robert Reif d73709a620 Symbol database: rename variables. ticket: #2468 2011-01-21 07:42:41 +01:00
Daniel Marjamäki 856a631f35 Fixed #2483 (SymbolDatabase compiler warning (VS2008/VS2010)) 2011-01-19 07:33:38 +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
Pete Johns 7918c4b804 isVariableDeclaration() now detects template variables. 2011-01-17 08:36:53 +11:00
Pete Johns 38c37ad2d8 Moved array declaration detection into isVariableDeclaration() 2011-01-17 08:36:52 +11:00
Daniel Marjamäki 93d1313186 Refactoring: Check if type is class/struct through symbol database 2011-01-16 19:57:29 +01:00
Robert Reif 66be74a5af Symbol database: Refactorings. Move check-specific code to check. Ticket: #2468 2011-01-16 16:37:11 +01: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
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
Daniel Marjamäki f1f1a21c23 Borland C++: Fixed compiler errors 2010-12-31 10:24:51 +01:00
Daniel Marjamäki 68b9c6ec94 gcc: Fixed -Wconversion warnings in symbol database 2010-12-31 09:39:42 +01:00
Pete Johns 2e61736c73 Refactoring following #2377 (Technically the member function xxx can be const)
symboldatabase now recognises variables with arbitrarily many scopes.

Extracted method isVariableDeclaration()

Added unit tests for isVariableDeclaration in new file testsymboldatabase.cpp

Extracted givenACodeSampleToTokenize helper class into testutils.h to reduce duplication.
2010-12-30 19:46:44 +11:00
Robert Reif 244974a61a unused variables: fixed false negatives with the help of the symbol database. ticket: #2317 2010-12-21 08:13:40 +01:00
Robert Reif c6e67d4aad Symbol database: use symbol database in the memory leaks function checking. Ticket: #2219 2010-12-08 07:49:01 +01:00
Robert Reif 980a90071c Fixed #2282 (Improve check: Function can be const) 2010-12-07 19:42:30 +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 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
Daniel Marjamäki a06a1a6574 Symbol database: Added files 2010-11-13 08:08:45 +01:00