Commit Graph

184 Commits

Author SHA1 Message Date
PKEuS 35d94c26d5 Changed creation of SymbolDatabase. Database always created after Tokenizer::tokenize() and Tokenizer::simplifyTokenList() instead of on-demand creation by Tokenizer::getSymbolDatabase.
-> With Token::scope() it is possible to access the symboldatabase without having to call getSymbolDatabase(). The change increases safety because it is guaranteed that the database is available in all checks, even if the specific check doesn't call getSymbolDatabase
- Tokenizer::_symbolDatabase does no longer have to be mutable -> Increased const correctness

The change above required two additional changes:
- A bug causing a debug message was fixed in the symboldatabase that became visible in the test suite by the change above.
- Simplify expressions like "struct struct Foo" which might be result of typedef instanciation.
2012-08-12 03:01:24 -07:00
PKEuS 2ab33ef21b Added Pointer to enclosing scope to class Token (Only available when symboldatabase is created). 2012-08-11 11:47:11 -07:00
Daniel Marjamäki 0254344df5 Tokenizer::simplifyEnum: Reverted refactorings/optimisations as there were regressions (#3949, #3950, #4025) 2012-08-10 14:06:24 +02:00
PKEuS c8e40773f1 Fixed cppcheck messagesa about functions that can be const/static:
- Made Tokenizer::getErrorMessages static - Avoids creation of unnecessary instance of Tokenizer
- Changed Tokenizer::removeExceptionSpecifications to common style for simplification functions. In contrast to the comment, this function doesn't call itself recursivly - fixed comment.
- Made Tokenizer::IsScopeNoReturn static.
2012-08-01 12:04:47 -07:00
PKEuS e9182f1fcc Implemented support for 'using namespace std;': Add std:: prefix to names that are known to be in std namespace. Simplify namespace (std::)tr1:: if C++11 flag is set. 2012-07-15 02:05:19 -07:00
Daniel Marjamäki 42e68550fc fixed doxygen errors 2012-07-08 19:32:33 +02:00
Daniel Marjamäki 6ad5fc8456 Refactoring Tokenizer::simplifyEnum. The enum handling is now somewhat faster since all enum values of a enum are simplified at the same time. 2012-07-06 15:43:50 +02:00
Daniel Marjamäki bb9f114d84 Fixed #3924 (False positive: Uninitialized variable (const pointer)) 2012-06-30 12:12:36 +02:00
Daniel Marjamäki 8af044255d Tokenizer: Added new function isFunctionParameterPassedByValue that check if a parameter is passed by value 2012-06-24 13:40:09 +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 a9cfe2814a Made some functions const according to cppcheck results 2012-05-17 02:54:17 -07:00
PKEuS 4bb2a1b27b Made some functions static or const according to cppcheck results 2012-05-17 01:33:24 -07:00
PKEuS 1a5fbd61d2 Splitted class TokenList from Tokenizer 2012-05-05 09:33:26 -07:00
PKEuS 8cbed66089 Changed relationship between templatesimplifier and tokenizer:
- Pass a tokenizer to templatesimplifier to reduce code duplication (Make use of Tokenizer::reportError; remove redundant TemplateSimplifier::addtoken2) and amount of arguments passed to functions

Removed ctor and dtor implementation from TemplateSimplifier: This class shouldn't be instanciated.
2012-04-23 20:45:36 +02:00
Daniel Marjamäki d5f6cfcfa8 Tokenizer: Use new setVarId function. Removed the old one. 2012-04-22 11:36:31 +02:00
PKEuS 3d2b5a30fe Implemented generic reportError functions in tokenizer (similar to Check::reportError) to reduce code duplication 2012-04-22 11:28:46 +02:00
PKEuS 1c3c94dc67 New simplification: Remove 'extern "C"' from C++ code.
Refactorization in cppcheck.cpp: Catch exception as const reference instead of non-const reference.
2012-04-16 16:25:04 +02:00
Daniel Marjamäki 7669abb170 Tokenizer::setVarId : Starting to rewrite Tokenizer::setVarId. The purpose of the rewrite is to make this function faster. 2012-04-15 11:47:22 +02:00
Daniel Marjamäki c7093ca5d6 Tokenizer: allow that time is measured for certain slow simplifications 2012-04-10 13:45:34 +02:00
Daniel Marjamäki d6c8de104c Revert "Fixed #3648 (Internal error: Token::Match called with varid 0)"
This reverts commit 1fa1ddccba.
2012-03-20 19:00:16 +01:00
Daniel Marjamäki 1fa1ddccba Fixed #3648 (Internal error: Token::Match called with varid 0) 2012-03-20 18:58:27 +01:00
PKEuS cb2a754983 Implemented support for C++11 right angle brackets (>>)
Implemented support for linkage between < and > (Information: It is possible that under certain circumstances comparision operators are linked, since its sometimes difficult to separate between them.)
2012-03-19 18:45:47 +01:00
PKEuS 3af32b0da2 Refactorizations in tokenizer:
- getSourceFilePath returns a const reference now
- Replaced some simple patterns by string comparisions/direct function calls
- Replaced a few indendation counters by easier code
- Replaced one offset variable by token pointer to avoid subsequent calls to tokAt with the same number
2012-03-17 11:48:40 +01:00
PKEuS 1747813a8b Added check for invalid pointer casts (#1255)
Detect sign extension problems when variable is a reference (#3637)
Refactorizations:
- Tokenizer::getFiles returns a reference instead of a pointer, because its guaranteed that no nullpointer is returned
- Remove signed/unsigned in one step for "%type% signed|unsigned"
- Fixed recently introduced compiler warning in symboldatabase.cpp
2012-02-26 11:56:32 +01:00
PKEuS 9431fb1b7e Improved STL checks:
- Added performance checking for .c_str() for return values and function parameters (#1079)
- Added more containers (basic_string, C++11 containers) and more functions to checking (.at, .resize, .reserve, ...)
- Make use of symboldatabase in missingComparision check
2012-02-25 12:43:27 +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 b1ff900aaa Some refactorizations 2012-02-18 23:43:51 +01:00
Daniel Marjamäki 9df6088ddd Revert "really fix #3527 (Internal error. Token::Match called with varid 0. Please report this to Cppcheck developers)"
This reverts commit a37031944e.

I don't want this hard coding of macro names. Feel free to come with a more generic solution if you want.
2012-01-30 06:15:41 +01:00
Robert Reif a37031944e really fix #3527 (Internal error. Token::Match called with varid 0. Please report this to Cppcheck developers) 2012-01-28 20:58:51 -05:00
Edoardo Prezioso ca8e8d26c7 Tokenizer: extract realloc simplification and simplify also when each argument is done by more than one token.
Restyling of a comment in tokenize.h.
2012-01-27 13:56:06 +01:00
Edoardo Prezioso 6e164ae7ed Fixed ticket #3557 (Tokenizer: simplification of '[]' doesn't work well):
extract undefined size array simplification and handle multiple arrays and combos between pointers and arrays, don't handle the definitions as arguments of function.
2012-01-26 17:25:52 +01:00
Edoardo Prezioso b6a0896ce6 Change 'simplifyReturn' to 'simplifyReturnStrncat' because it's not clear what this function does. 2012-01-26 11:49:08 +01:00
Edoardo Prezioso 5953ed7318 Fixed ticket #3528 (Tokenizer: improve simplifyFunctionParameters to take count of square brackets) 2012-01-23 16:10:15 +01:00
Edoardo Prezioso b0dac2fa2e Tokenizer::copyTokens: add optional parameter which preserve the line number differences between tokens to be copied. 2012-01-21 17:18:16 +01:00
Reijo Tomperi be7691c7b4 Refactoring: Move rest of the template simplification into TemplateSimplifier
simplifyCalculations() was temporarily moved into TemplateSimplifier also, it should be moved to a better place.
2012-01-09 21:33:11 +02:00
Reijo Tomperi e91d239ea5 Refactor: Move file extension checks from Tokenizer to Path class. This has also functional change as now also file.JAVA is considered a Java file. 2012-01-06 21:56:28 +02:00
Daniel Marjamäki de4a64332e Refactoring: Copy FileLister::acceptFile to Path::acceptFile. Use Path::getFilenameExtension and Path::acceptFile in Tokenizer. Use Path::acceptFile in CppCheck::processFile instead of hardcoded handling. 2012-01-06 17:31:10 +01:00
Reijo Tomperi eda04ad906 Refactoring: Move template code into templatesimplifier: simplifyTemplatesExpandTemplate() 2012-01-05 22:45:19 +02:00
Edoardo Prezioso 75fbe310ff Extract various functions inside the Tokenizer class and fix tokenization of 'return __LINE__ ;'. 2012-01-04 12:57:58 +01:00
Reijo Tomperi 0369681a2c Refactoring: Move template code into templatesimplifier: simplifyTemplatesGetTemplateNamePosition() 2012-01-03 23:49:50 +02:00
Reijo Tomperi ac290b1a8a Refactoring: Move template code into templatesimplifier: simplifyTemplatesUseDefaultArgumentValues(), simplifyTemplatesInstantiateMatch() 2012-01-03 23:35:06 +02:00
Reijo Tomperi 16fb1801e1 Refactoring: Move template code into templatesimplifier: simplifyTemplatesGetTemplateDeclarations(), simplifyTemplatesGetTemplateInstantiations() 2012-01-02 23:05:27 +02:00
Reijo Tomperi 37269d0c28 Refactoring: Move template code into templatesimplifier: simplifyTemplatesExpandSpecialized() 2012-01-02 22:53:13 +02:00
Reijo Tomperi aa927d5aa3 Refactoring: Add new file lib/templatesimplifier.cpp
The plan is to move template simplification into this new class to take some lines from 10 000 line tokenizer.
2012-01-01 22:55:05 +02:00
Reijo Tomperi 8cae17fda8 Update year to 2012 2012-01-01 01:05:37 +02:00
Reijo Tomperi 90e1a397a2 Refactoring: Remove duplicate function from tokenizer: code_is_c() -> isC() 2011-12-29 00:36:16 +02:00
Edoardo Prezioso ec0badb651 By pressing request, extract method: simplifyJavaAndCSharp. 2011-12-28 22:44:53 +01:00
Jonathan Neuschäfer 7a5627029f tokenizer: proper checks for Java and C# 2011-12-27 18:01:39 +01:00
Jonathan Neuschäfer 103588c5bc Refactoring: tokenizer: factor out fileExtension 2011-12-27 18:01:39 +01:00
Daniel Marjamäki 91874214d8 Refactoring: Added utility function that determine if scope ends with a call to a noreturn function 2011-12-27 18:00:12 +01:00