Commit Graph

3782 Commits

Author SHA1 Message Date
PKEuS dd5e9aa454 Make use of recently implemented Token::type() functionality 2012-04-25 09:56:07 +02:00
Daniel Marjamäki fb6c7f33f0 Fixed #3707 (Uninitialized variable with operator >> and templates) 2012-04-24 19:50:54 +02:00
PKEuS e0a3ca0845 Refactorizations in class Token: changed handling of different types of tokens.
- Replace _isNumber, _isName, _isBoolean attributes by a single _type attribute (enum Token::Type), because not two of the old booleans could be true at the same time.
-> Add support for lots of different other kinds of tokens. (More precise checking of token type possible)
-> Replaced instant checking of type for Operators, etc. by a value calculated at creation time. (Faster checking)
2012-04-23 21:05:26 +02: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 6ae135124e Tokenizer::setVarId: better handling of initializer lists 2012-04-23 18:26:27 +02:00
PKEuS 5086ae7c31 Refactorizations in CheckMemoryLeakInClass::variable
- Bailout for functions that are not implemented (should fix performance downgrade introduced in fb4709f)
- Jump behind arguments
- Removed unnecessary pop_back operations - container gets destroyed after it.
2012-04-23 15:23:01 +02:00
Daniel Marjamäki 706631f527 Fixed #3748 (False positive out of bounds with postincrement) 2012-04-22 12:22:49 +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
Daniel Marjamäki 8c8c9d5e5b Tokenizer::setVarIdNew: don't treat '(sizeof *p)' as a variable declaration 2012-04-22 11:06:56 +02:00
Daniel Marjamäki d63093d9bb Tokenizer::setVarIdNew: Fixed issue found through TestUnusedVar tests 2012-04-22 10:59:58 +02:00
Daniel Marjamäki 871823e9c6 Tokenizer::setVarId: fixed problem for classes with inheritance 2012-04-22 10:38:06 +02:00
Daniel Marjamäki e39b7f1bfd Tokenizer::setVarIdNew: Fixed TestTokenizer::varid38 2012-04-22 10:24:19 +02:00
Daniel Marjamäki e745d971c8 Tokenizer::setVarIdNew: Fixed test case TestTokenizer::varid27 2012-04-22 10:19:29 +02:00
Daniel Marjamäki b4ffb5e0cf Tokenizer::setVarIdNew: Fixed TestTokenizer::varid39 test case 2012-04-22 09:51:00 +02:00
Daniel Marjamäki ed6673a9aa Tokenizer::setVarIdNew: Fixed TestTokenizer::varid44 2012-04-22 09:18:27 +02:00
Daniel Marjamäki 71050bc586 Tokenizer::setVarIdNew: fixed TestTokenizer::varid_in_class2 test case 2012-04-22 08:51:19 +02:00
Ahti Legonkov 79af6f65d7 Fixed #3699 (cppcheck hangs with 100% cpu load on parsing preprocessor code) 2012-04-22 06:49:42 +02:00
Edoardo Prezioso be5a61b794 Fixed ticket #3721 (false positive: syntax error on valid C code ( K&R function style )). 2012-04-22 01:56:40 +02:00
PKEuS 710fefeef0 Refactorizations:
- Replaced some indendation counters by Token::link() or usage of symbolDatabase
- Use Token::nextArgument() to jump to target parameter
2012-04-21 23:05:37 +02:00
Daniel Marjamäki 6d9b4a8032 Tokenizer::setVarIdNew: Fixed TestTokenizer::varid_operator test case 2012-04-21 19:29:24 +02:00
Daniel Marjamäki 1cc256339c Tokenizer::setVarIdNew: Fixed TestTokenizer::varid19 test case 2012-04-21 18:22:18 +02:00
Daniel Marjamäki 42a95c9202 Tokenizer::setVarIdNew: Fixed segfault when using new setVarId on invalid code 2012-04-21 18:02:26 +02:00
Daniel Marjamäki bd60dd46d0 Tokenizer::setVarIdNew: handle special case when there is an unknown macro. Ticket #2638 2012-04-21 17:57:20 +02:00
Daniel Marjamäki b86295fbcd Tokenizer::setVarIdNew: Improved C++ handling. All the TestTokenizer::varidclass?? tests pass now. 2012-04-21 17:25:44 +02:00
Daniel Marjamäki 6071a5afc3 Tokenizer::setVarIdNew: Fixed varidclass9 2012-04-21 13:39:43 +02:00
Daniel Marjamäki 85b470c41b Tokenizer::setVarIdNew: Better C++ handling (varidclass5 and varidclass13) 2012-04-21 13:11:30 +02:00
Daniel Marjamäki 1492d8990f Tokenizer::setVarId: better C++ handling 2012-04-19 20:58:52 +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
PKEuS 6a37c36ee8 Fixed #3741
Removed redundant nullpointer check (cppcheck catch)
2012-04-18 16:35:04 +02:00
PKEuS cb7537418a Make use of Token::findClosingBracket in templatesimplifier.cpp 2012-04-18 16:16:06 +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 1793bf8928 Fixed false positive in stlBoundries check (#3740) 2012-04-18 10:08:59 +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
Daniel Marjamäki bb4184ca03 Tokenizer::setVarIdNew: better handling of class variables 2012-04-17 19:06:00 +02:00
PKEuS 8e5949c6ce Added several C++11 algorithms and containers to CheckStl
Added pattern "> %varid%" to CheckStl::stlBoundries()
Fixed message in checkOther (#1320)
2012-04-17 12:54:01 +02:00
PKEuS 82cd022646 Refactorized CheckStl::mismatchingContainersError:
- Improved error message
- Made patterns more generic by using Token::nextArgument()
2012-04-17 12:21:41 +02:00
Ettl Martin 09d41b2f84 ticket 2669: added todo testcase 2012-04-17 00:31:32 +02:00
Reijo Tomperi 4e2946a8d0 Fix spelling error: unecessary unnecessary 2012-04-16 21:33:16 +03:00
PKEuS bac8ed7127 Refactorized stringification of tokens:
- Function that stringifies one token: Token::stringify()
- Functions that stringify a list of tokens: Token::stringifyList()
-- Single and powerful "base" function, used by several "light" functions
Refactorized
- testtokenize.cpp and testsimplifytokens.cpp: Use improved stringification functions instead of several local implementations
- Avoided redundand creation of std::string when using TestTokenizer::tokenizeAndStringify and in cmdlineparser.cpp
2012-04-16 19:51:07 +02:00
Daniel Marjamäki 5ad1840120 Tokenizer::setVarIdNew: Copied code from Tokenizer::setVarIdOld that sets varid in member functions 2012-04-16 19:48:58 +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
PKEuS 8cb904feaa Refactorizations in class Token:
- Added support for < and > in nextArgument()
- Made isStandardType inline by writing its implementation to token.h (like other bool is*() functions)
- Made firstWordEquals return bool instead of integer (only 0 and 1 were returned)
- Use std::string::empty() instead of operator==(""); Use character literals instead of string literals for single characters printed.
2012-04-16 15:28:38 +02:00
PKEuS 66d947675f Refactorizations in tokenize.cpp:
- Removed a few indendation counters
- Removed unnecessary pattern "- >" because this code is simplified to "." before.
- Generalized pattern of simplifyFunctionReturn()
- Simplified removeExeptionSpecification, no longer recursive (-> #3385)
2012-04-16 10:49:09 +02:00
Daniel Marjamäki 8f866c6e4c Tokenizer::setVarIdNew: handle c++ keyword 'using' 2012-04-15 18:29:35 +02:00
Daniel Marjamäki c58d02f146 Tokenizer::setVarIdNew: in C code, allow that variable declaration starts with delete and throw 2012-04-15 18:23:12 +02:00
Daniel Marjamäki ea148173bb TemplateSimplifier: Allow that template parameter starts with :: 2012-04-15 18:15:36 +02:00
Daniel Marjamäki b0dc708b4d Tokenizer::setVarIdNew: variable declarations dont start with NOT/goto/return/delete/etc 2012-04-15 18:02:49 +02:00
Daniel Marjamäki 46bfe27831 Tokenizer::setVarIdNew: Better handling of function calls 2012-04-15 17:44:51 +02:00
Daniel Marjamäki 31f8a71f84 Tokenizer::setVarIdNew: Better handling for catch-exception-by-reference 2012-04-15 17:39:22 +02:00
Daniel Marjamäki 3c1dfc658c Tokenizer::setVarIdNew: use the new setVarId with a few more test cases. Improved setVarId: references in executable scopes must be initialized. 2012-04-15 14:32:47 +02:00
Daniel Marjamäki 27c37896a0 Tokenizer::setVarIdNew : use new setVarId function in TestTokenizer::varidReturn2. 2012-04-15 14:19:17 +02:00
Daniel Marjamäki 95dafd30dd Tokenizer::setVarIdNew : enable more testcases. better handling of unions and struct members. 2012-04-15 13:42:13 +02:00
PKEuS a420a36606 Removed deprecated cmdline options -s, --style, -a, --all, --auto-dealloc, --test-2-pass 2012-04-15 13:10:41 +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
PKEuS f1692cdefe Set version to "1.55 dev" 2012-04-15 11:40:14 +02:00
Daniel Marjamäki 3ddbcc7fbe 1.54: updated version numbers 2012-04-15 07:23:26 +02:00
Daniel Marjamäki c6ba3ba3ca Fixed #3714 (segmentation fault of cppcheck checking libtiff) 2012-04-14 18:36:19 +02:00
PKEuS 9f054fbb3c Fixed crash when "-rp=" or "--relative-paths=" is given - print Error. 2012-04-14 14:44:15 +02:00
PKEuS 62d5069387 Fixed #3722: Handle associative law correctly for operator* 2012-04-13 11:55:09 +02:00
PKEuS 05a6638468 Removed code that became unnecessary after 7be01da8e9.
Fixed wrong comment in cli/pathmatch.h (doxygen warning)
2012-04-13 11:08:46 +02:00
Edoardo Prezioso 51789d8e20 Fixed ticket #3712 (false positive: syntax error on valid C code ( K&R function style )) 2012-04-13 00:39:40 +02:00
Ettl Martin 7be01da8e9 fixed ticket 3693. Added modulus operator to Mathlib + unittests. Added a test to checkother to ensure the testcase of ticket 3693 does not trigger an error message. 2012-04-12 14:02:09 +02:00
Daniel Marjamäki 8e3f1702fd Reverted 81318b3f to get rid of #3669 false positives 2012-04-10 13:58:59 +02:00
Daniel Marjamäki 23c71daf37 astyle formatting 2012-04-10 13:45:56 +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 6bae724cb6 Fixed #3705 (cppcheck crash (null pointer exception)) 2012-04-09 15:06:06 +02:00
Daniel Marjamäki bbdeebafda Fixed #3700 (false positive: (style) Variable 'H' is not assigned a value) 2012-04-09 12:55:26 +02:00
Daniel Marjamäki 26a9a1b571 Fixed #3661 (False positive: unusedPrivateFunction) 2012-04-09 11:19:19 +02:00
PKEuS c12d82aeb9 Fixed false negative in unused functions check when function returns reference
Removed some unnecessary loops
2012-04-09 11:00:31 +02:00
Daniel Marjamäki b8d233f1a2 false poitive - invalid iterator after break 2012-04-09 07:19:39 +02:00
Daniel Marjamäki 66227c4da0 Fixed #3609 (clarifyCondition delivers false positives when using Windows-Traits as a template) 2012-04-08 18:07:11 +02:00
PKEuS 772108374e Removed unused variable CppCheck::_errout. 2012-04-08 14:18:13 +02:00
Daniel Marjamäki 6360afdcfa CheckOther: Use reportInconclusiveError to report inconclusive error 2012-04-08 10:47:01 +02:00
Simon Martin 3ccdd16b01 Avoid clang warning. 2012-04-07 15:36:45 +02:00
PKEuS 7de545f0fe Refactorizations:
- Added forgotten initialization of Settings::_relativePaths
- Some PCRE-Rules specific code hidden behind HAVE_RULES
- Use initialization list in ErrorLogger::ErrorMessage::ErrorMessage() and CppCheck::CppCheck
- Avoided unnecessary copies of std::strings in cppcheck.cpp
- Moved "// Alert only about unique errors"-code to make it work in debugFalsePositive mode
2012-04-06 18:16:59 +02:00
PKEuS 6643e14d3c Avoid copying Settings in CppCheckExecutor 2012-04-06 14:19:26 +02:00
PKEuS 25167b58a9 Implemented #2990: Print relative paths if -rp or --relative-paths is given 2012-04-06 10:49:21 +02:00
PKEuS b0f571b25c Fixed #3383: If there is an empty line between subsequent break statements, only issue a message for inconclusive checking 2012-04-05 10:38:29 +02:00
PKEuS 425cbea6b1 Improvements in checkclass.cpp:
- Generalized CheckClass::noMemset:
-- Checking for all three mem...-functions for all patterns, generalized them so that we need less patterns
-- Use nextArgument() to jump over irrelevant arguments
- Replaced CheckClass::hasDeallocation by CheckClass::hasAllocation:
-- Reduced number of false negatives by returning also true whenever a member variable is allocated (also without previous deallocation)
-- Reduced code duplication
- Removed indendation counter and redundant variable in CheckClass::initializeVarList
2012-04-05 09:43:40 +02:00
Daniel Marjamäki 823fc9ac04 Fixed #3650 (Variable declaration: Doesn't handle template usage well) 2012-04-05 08:53:10 +02:00
Stefan Weil 37b98c2a56 Fix compiler warning
gcc warning:
lib/checkclass.cpp: In member function ‘void CheckClass::checkConst()’:
lib/checkclass.cpp:1197: warning: declaration of ‘name’ shadows a member of 'this'

Rename local variable 'name' to 's'.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2012-04-04 20:39:11 +02:00
PKEuS d6cfbc6483 Improved checks in CheckStl:
- Generalized check for inefficient emptiness check to detect !%var%.size() calls also outside of if and while; detect it also for %var%.size() when linked with && or ||.
Refactorizations in CheckStl:
- Removed an indendation counter and an offset variable
- Reduced distance given to tokAt calls in CheckStl::redundantCondition
- Rearranged code in CheckStl::missingComparison to use more efficient comparision of varIds instead of variable names. Use varId in pattern instead of variable name.
2012-04-04 19:44:57 +02:00
PKEuS bef2caf489 Improved checks in CheckStl:
- Improved message of stlIfStrFind according to discussion on github (77d9ed1877)
- Generalized pattern for substr in CheckStl::uselessCalls; added check for substr calls like ".substr(%any%,0)" which result in an empty string.
2012-04-04 19:40:28 +02:00
Edoardo Prezioso b90d9c8a19 Make 'const' the new variable 'funcName'. 2012-04-03 22:51:56 +02:00
PKEuS 77d9ed1877 Fixed #3162: Check whole condition for suspicious find calls. 2012-04-03 20:59:45 +02:00
Edoardo Prezioso ecc5dea113 Fixed ticket #3703 (false positive: syntax error on valid C-code ( K&R - style )). 2012-04-03 20:12:34 +02:00
Edoardo Prezioso 5d91ef76fe Fixed ticket #3701 (false positive: syntax error on valid C code ( K&R function style ). 2012-04-03 19:49:58 +02:00
PKEuS c1fc7a2218 Improved CheckOther::checkComparisonOfBoolWithInt and CheckOther::checkComparisonOfBoolExpressionWithInt:
- Added support for comparision of bool constant with number constant (-> fixed #1877) and integer variable with boolean expression
- Moved a check from checkComparisonOfBoolWithInt to checkComparisonOfBoolExpressionWithInt
- Generalized some patterns
- Made error message more accurate concnerning the "neither 0 nor 1" part.
- Reduced number of Token::Match calls
2012-04-02 15:45:51 +02:00
PKEuS fc8749e952 Improved nullpointer check:
- Fixed #3673
- Fixed potential issue with constructor calls (like #3697)
- Added support for operator+ on std::string
2012-04-02 12:12:02 +02:00
PKEuS 033e4a2c1f Fixed #3676. 2012-04-02 11:21:04 +02:00
PKEuS 8492685531 Fixed #3697. 2012-04-02 11:02:41 +02:00
Edoardo Prezioso af02908d42 Fixed ticket #3580 (syntax error in multi variable declaration header). 2012-03-31 18:45:29 +02:00
PKEuS 8949464ed6 Fixed another memory leak in executionpath.cpp 2012-03-31 15:03:11 +02:00
Pierre Schweitzer 72c2f400b1 Fix a memory leak and a performance issue in checkExecutionPaths() 2012-03-31 13:14:24 +02:00
Daniel Marjamäki 68e6511c87 Fixed #3532 (false positive : missing constructor) 2012-03-31 11:30:26 +02:00
Daniel Marjamäki 1309825bf1 Merge pull request #91 from HeisSpiter/e46c7eb32033b520374e9df8c13bc8589c0602d0
Handle Rtl memory functions in Tokenizer::simplifyMicrosoftMemoryFunctions()
2012-03-28 09:43:14 -07:00
Daniel Marjamäki e6dc901761 Fixed #3574 (false positive: check sign of unsigned variable (type cast)) 2012-03-28 18:33:34 +02:00
Daniel Marjamäki abcbe2e49f Fixed #3594 (false positive: returning reference to auto variable) 2012-03-28 18:21:06 +02:00
PKEuS 4f1f6e1824 Improved simplification of calculations:
- Use more generic patterns
- Look on operator precedence more consequently
-> Made a TODO test case from a test case that worked previously, because the calculation is simplified so that the problem isn't detected any more.
Changed comment "Coding style checks" to "Checks", because it didn't fit
2012-03-27 21:29:50 +02:00
Pierre Schweitzer e46c7eb320 Add the RTL memory functions for the simplifications on Windows code. 2012-03-27 21:24:46 +02:00
PKEuS b37cf11d20 Refactorizations:
- Increased encapsulation by making some functions private
- Removed redundant function CheckBufferOverrun::ArrayInfo::declare
- Avoided copy of ArrayInfo object
- Removed unnecessary and suspicious "if(sizeof(int) == 4)"
2012-03-27 19:40:39 +02:00
Daniel Marjamäki 01ddfb6f80 Fixed #3534 (Broken support for dollar signs in identifiers) 2012-03-27 19:35:41 +02:00
PKEuS 782cd5d228 Fixed #3687: Don't treat catched variables as local ones. 2012-03-26 21:19:42 +02:00
Daniel Marjamäki c07044b3d3 Fixed #3573 (Preprocessor: handle '!(X)' the same as '!X') 2012-03-26 19:01:45 +02:00
PKEuS 989ac449e4 Made invalidPointerCast message inconclusive for casting from floating point type* to char* (Fixed #3639) 2012-03-25 12:55:39 +02:00
Daniel Marjamäki 4773384ff4 xml: Add attribute 'inconclusive' to the xml (format version 2) 2012-03-25 11:59:30 +02:00
Daniel Marjamäki 1d95416840 astyle formatting 2012-03-25 11:51:59 +02:00
Daniel Marjamäki ca6a93816b Merge pull request #89 from HeisSpiter/master
Merged two checks to get a better one regarding sizeof
2012-03-25 02:38:04 -07:00
PKEuS e4d92055e7 Improved sizeofCalculation check:
- Bailout on expanded macros for conclusive checking
- Support for more operators
- Removed indendation counter
Improved checkSignOfUnsignedVariable:
- Made the patterns more generic
- Improved verbose error message (-> Fixed #3080)
2012-03-25 11:32:00 +02:00
August Sodora fe9d491aae 3619 Check that tok2->next() exists before using 2012-03-25 10:24:29 +02:00
Edoardo Prezioso 28431da0ae Nitpicky style change: use 'for(;;)' construct instead of 'while(true)' in the code. 2012-03-24 21:50:09 +01:00
PKEuS e6bcab7c35 Fixed #3360: "type const* var;" is now recognized as variable declaration. 2012-03-24 15:10:06 +01:00
PKEuS b964551424 Fixed #3252
Make use of std::isupper instead of custom implementation
2012-03-24 13:48:33 +01:00
PKEuS 8c657872d1 Check for unused private functions now handles overloads - removed redundant and less powerful duplicate of CheckClass::isVirtualFunc.
CheckClass::initializerList does now also check copy constructors
Started fix for #3682: use reportInconclusiveError
2012-03-24 10:50:19 +01:00
Daniel Marjamäki 4076c46a33 Merge pull request #88 from leg0/ticket_3675
Fixed ticket #3675.
2012-03-24 00:36:37 -07:00
Pierre Schweitzer 2b5ddb7858 Merge the strncmp & malloc sizeof checks into a more generic test that handles several cases where sizeof is misused, or could be misused 2012-03-23 21:47:13 +01: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
Ahti Legonkov 780481e82a Fixed ticket #3675. 2012-03-23 01:45:47 +02:00
Daniel Marjamäki d04698df13 Merge pull request #87 from HeisSpiter/master
Fix a bug introduced with a previous commit and add a new check
2012-03-21 13:20:39 -07:00
Pierre Schweitzer ec44967e13 Add a new test to check improper sizeof usage. It's for the moment limited to malloc calls. 2012-03-21 21:13:09 +01:00
PKEuS 002389f836 Fixed #3677
Added forgotten testcase for #3672
2012-03-21 18:40:32 +01:00
Pierre Schweitzer 9d002916f4 Fix line number displayed on leakNoVarr error 2012-03-20 22:28:56 +01:00
Daniel Marjamäki a2351ba44f Fixed #3648 (Internal error: Token::Match called with varid 0) 2012-03-20 19:05:24 +01: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 7055526f4a Fixed #3672: bitwise and operator in if/while does no longer confuse setVarId code
Improvements to CheckUnusedVar:
- Improved handling of arrays of struct/class instances
- Differ between addressof and bitwise-and operator
- Made some members private to improve encapsulation
- Replaced some simple patterns by direct function calls
- Removed an unnecessary condition
2012-03-19 17:41:16 +01:00
Pierre Schweitzer 544a1f714e Updated error message about not taking return value from function that returns allocated memory 2012-03-18 13:45:50 +01:00
Daniel Marjamäki 1e125dc017 Fixed #3671 (False positive: Resource leak: fd) 2012-03-18 11:54:09 +01:00
Daniel Marjamäki 29063098bf Fixed #3670 (false positive: Allocation with open never assigned) 2012-03-18 07:49:22 +01:00
PKEuS e3b3b7b62f Refactorizations on buffer overrun check:
- Replaced a few indendation counters by smaller and faster code
- Make use of safer nextArgument() function instead of some local implementations
- Replaced some simple patterns by direct function calls
- Made a strncpy/strncat search pattern more generic
- Replaced offset variable by incrementation of Token* to avoid subsequent calls to tokAt
- Increased data encapsulation in header
2012-03-17 21:55:08 +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 60cc8296c3 Fixed crash in checkmemoryleak.cpp reported by HeisSpiter 2012-03-17 11:34:27 +01:00
PKEuS fb4709f1be Refactorizations in checkmemoryleak:
- Replaced two indendation counters and one variable storage by symboldatabase functions
- Removed zero-element at end of two static arrays
- More accurate algorithm for finding a parameter by varid
- Replaced some simple tokens by direct string comparision
- Made some functions in checkmemoryleak.h private to improve encapsulation
2012-03-16 19:52:18 +01:00
Daniel Marjamäki 2757229064 Fixed #3666 (False positive: Uninitialized variable (taking address)) 2012-03-16 17:28:05 +01:00
PKEuS 0340764726 Improved nullpointer check: Detect dereferences by streams (#410)
Refactorizations:
- Replaced || by %oror% in Token::Match patterns
- Replaced some simple patterns by direct comparisions, replaced Match call with simpleMatch
- Increased data encapsulation by making more members private in CheckNullpointer
2012-03-16 17:24:03 +01:00
PKEuS 4587a1a06c Fixed recently introduced assertion failure in debug mode 2012-03-15 21:06:24 +01:00
PKEuS b6057a1148 Improved CheckOther::checkIncorrectLogicOperator:
- Added a lot of additional pattern
- Rewrote error messages to make them more understandable and better fitting to the situation. (Fixed #3664)
- Cleanup in unit tests
Improved message of static string comparision check
2012-03-15 20:38:28 +01:00
Daniel Marjamäki fc84f55f80 Fixed #3536 (Preprocessor #if fails to correctly compare two #defined values) 2012-03-15 20:04:34 +01:00
Daniel Marjamäki 813a193bb6 Merge pull request #84 from HeisSpiter/master
Fix for bug #3439
2012-03-15 11:37:42 -07:00
Daniel Marjamäki 555e8c6efc Fixed #36221 (Input streams: Wrong token list simplification) 2012-03-15 19:09:36 +01:00
Pierre Schweitzer e9a696f70e Set back getErrorMessages() as private 2012-03-15 18:52:51 +01:00
Pierre Schweitzer f3b1c46c7d Define error messages for --errorlist for CheckMemoryLeakNoVar class 2012-03-14 23:44:04 +01:00
Pierre Schweitzer 81318b3f4a Detect and display an error on leaks due to return of a function that allocates something is ignored.
This fixes #3439
2012-03-14 22:24:43 +01:00
Daniel Marjamäki 45759f6f7d CheckMemoryLeak: report debug warning when variable id is 0. Ticket #3527 2012-03-14 18:54:34 +01:00
Daniel Marjamäki 4f3878eb1e Fixed #3569 (false negative: buffer access out of bounds) 2012-03-13 21:30:03 +01:00
Daniel Marjamäki a9480ca0c1 CheckBufferOverrun: move condition before loop 2012-03-13 21:19:10 +01:00
PKEuS 7cfffc9c9d Improved CheckOther::checkIncorrectLogicOperator:
- Implemented automatic swapping of conditions and operands
- Added several patterns
- Added support for conditions outside of if/while
2012-03-12 19:06:30 +01:00
Daniel Marjamäki a9d56f2738 Tokenizer: simplify known variable value inside conditional block 2012-03-12 17:32:30 +01:00
PKEuS 533db6421f Renamed ID uninitialized member variables in constructors to "uninitMemberVar" to avoid ambiguity (#2715)
Refactorizations:
- Replaced another single-token-pattern
- Replaced a "continue" with a "break" statement, because its safe to assume that only one variable with a specific ID can exist in a scope
2012-03-11 14:29:00 +01:00
PKEuS 6f164de609 Improved static string comparision check: Implemented #3214
Fixed false negative on argument count of fnprintf/snprintf when first variable argument is a string. (#3655)
Uncommented call of virtualDestructorError in getErrorMessages in checkclass.h
Refactorizations:
- Rearranged code in checkother.h to make ordering more consistent and to increase encapsulation of private data
- Replaced some single-token-patterns
2012-03-11 11:01:39 +01:00
Daniel Marjamäki 3f1ab5af9b charvar: dont write warning about char type array index when array is small and the full valid range is accessible with the char type. If there are out of bounds access then, it is not because the type of the variable. 2012-03-10 12:19:28 +01:00
Simon Martin 190cba519d Fixed shadowing warning 2012-03-09 08:06:58 +01:00
August Sodora e0bee0e037 Fixed #3567 (False positives in boolean expressions) 2012-03-07 20:31:23 +01:00
Daniel Marjamäki 680883a6a7 fixed #3649 (False Positive: Uninitialized variable using operator assignment) 2012-03-06 18:51:50 +01:00
PKEuS ef6e381d47 Improved bitwise on boolean check to make it working on more code patterns
Refactorizations in checkother.cpp:
- Make use of symboldabase instead of: indentation counters, manual detection of variable declarations
- Removed some indexing variables to reduce calls to tokAt and the numbers given to this function
- Use tok->nextArgument() to jump to a specific argument
2012-03-03 21:14:20 +01:00
Stefan Weil 2ce5b80599 Fix compilation with HAVE_RULES=yes
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2012-03-01 20:07:00 +01:00
PKEuS 1ef99e2f21 Improved checkautovariables:
- Added support for checking a few more code patterns
- Simplified code by using more information from the symboldatabase
- Moved redundant part of c_str-check to checkstl
Two fixes according to output of pvs studio in testsimplifytokens.cpp
2012-03-01 18:38:20 +01:00
PKEuS c61762f454 Refactorized doAssignement:
- Enhanced performance by directly iterating through the token list instead of index access
- Added more allocation functions
- Simplified code
Replaced avoidable strlen call in cppcheckexecutor.cpp
2012-02-29 20:57:48 +01:00
Daniel Marjamäki db1205cdb3 Preprocessor: better handling of '#if A==1' 2012-02-29 19:08:01 +01:00
Daniel Marjamäki 527d3791e6 Fixed #3596 (memory leak false positive on libedit sources) 2012-02-27 18:55:36 +01:00
Ettl Martin 2ac907b40a fixed compiler warning (gcc-4.6.1) 2012-02-27 14:13:34 +01:00
Ettl Martin 013ef6157d fixed regression 2012-02-26 13:35:35 +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
Daniel Marjamäki 385c9d341d Fixed #3633 (False positive: struct array not assigned a value) 2012-02-26 08:29:02 +01:00
Edoardo Prezioso 4d3013d43d Improve 'Tokenizer::elseif' code in order to not touch 'else if' inside a macro parenthesis. 2012-02-26 02:50:48 +01:00
Daniel Marjamäki bbfae8e3ae Fixed #3583 (False positive Variable X is assigned a value that is never used) 2012-02-25 12:56:33 +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 9f42ce91a1 Refactored STL container usage in CLI.
Pathmatcher masks are converted to lowercase only once when instance is created
2012-02-19 17:22:59 +01:00
Daniel Marjamäki 39b0f1ba95 Fixed #3608 (unreadVariable when variable used in inline assembly) 2012-02-19 16:04:35 +01:00
Daniel Marjamäki 69d03bac34 Fixed #3603 (False Positive: Variable is assigned a value that is never used) 2012-02-19 15:25:46 +01:00
PKEuS b1ff900aaa Some refactorizations 2012-02-18 23:43:51 +01:00
Edoardo Prezioso d7a918e549 Fixed ticket #3616 (segmentation fault of cppcheck). 2012-02-18 17:58:50 +01:00
Daniel Marjamäki a118f82ca7 Tokenizer::simplifyVarDecl: Don't simplify inside parenhteses 2012-02-18 15:05:29 +01:00
PKEuS 4b52df675a Some refactorizations 2012-02-18 14:44:04 +01:00
Daniel Marjamäki 0705dbd34a Tokenizer::simplifyCasts: don't simplify 'f((double)(v1)*v2)' to 'f(*v2)' 2012-02-18 14:26:00 +01:00
PKEuS 2ba2a4e6ae Some refactorizations 2012-02-18 11:55:05 +01:00
Daniel Marjamäki bfb4dd6425 Fixed #3529 (False 'Boolean result is used in bitwise operation' in a template) 2012-02-18 08:51:09 +01:00
Edoardo Prezioso a08dab3776 Fixed warning about order of variable initialisations in Settings constructor. 2012-02-17 21:22:42 +01:00
Edoardo Prezioso 17cd5ec906 Fixed ticket #3604 (cppcheck(1.53) crash). 2012-02-17 21:14:38 +01:00
PKEuS 485e836535 Refactorizations in MathLib.
Fixed recently introduced bug on floating point numbers with multiple preceding zeros (for example 004.123)
2012-02-17 19:54:53 +01:00
PKEuS 8ea5df62c4 - Improved support for numbers in code:
-- Use MathLib::toLongNumber for conversion in tokenizer (Fix #3610)
-- Handle octal numbers in tokenizer
- Refactorizations in MathLib::toLongNumber and Settings
2012-02-17 15:47:08 +01:00
Zachary Blair 9d75641ef8 Fixed #3598 (false positive: (error) Memory pointed to by 'a' is freed twice.) 2012-02-16 21:03:38 -08:00
Ettl Martin d8c24c3afc fixed wrong spelled word. 2012-02-15 22:57:20 +01:00
Daniel Marjamäki 04e4b5d14d lib: fix for my previous commit. If there are no dependencies then don't insert dependencies 2012-02-15 08:13:42 +01:00
Daniel Marjamäki 8f3d511871 lib: allow that file dependencies are taken from Cppcheck after a check 2012-02-15 08:08:28 +01:00
PKEuS 2e13a51d08 Fixed #3591 2012-02-13 19:46:45 +01:00
PKEuS df0cb89a40 Fixed compiler error 2012-02-13 18:48:44 +01:00
PKEuS bb319c1c96 Improved Tokens and Tokenizer:
- Better handling of deleteThis() as last element of token list
- Code simplified
2012-02-13 17:44:08 +01:00
Daniel Marjamäki da8abeb63c Fixed #3584 (2 internal errors : Token::Match called with varid 0) 2012-02-12 17:30:47 +01:00
Erik Lax f1dbd1a89a Fixed #3518 (False negative: Possible null pointer dereference (in the same condition)) 2012-02-11 16:15:38 +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
Daniel Marjamäki c33dbb80fb 1.53: Updated version info 2012-02-11 08:17:07 +01:00
Daniel Marjamäki 4511d0fe5f fixed cppcheck inconclusive warning, possible null pointer dereference otherwise condition is redundant 2012-02-11 08:07:19 +01:00
Daniel Marjamäki bbb707c460 Fixed #3587 (Wrong tokenizer simplification - variable assigned by operator>>) 2012-02-07 08:05:50 +01:00
Daniel Marjamäki 47c7e346aa Uninitialized variables: Another fix for false positives when it's known that inner conditions are true 2012-02-06 19:26:28 +01:00
Daniel Marjamäki d6a887e1f9 Uninitialized variables: Fixed false positives when goto is simplified and inner condition is known to be true/false 2012-02-06 07:32:29 +01:00
Daniel Marjamaki fbb5ebe3c6 Fixed #3577 (Preprocessor: Defines given on command line are not used in the code) 2012-02-05 20:48:28 +01:00
Zachary Blair 8f827aa65f FIxed #3581 (double free false positive when exception rethrown) 2012-02-04 11:24:40 -08: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
Daniel Marjamäki 2be85e9d37 Fixed #3538 (false positive caused by bad tokenizer simplification) 2012-02-01 21:13:26 +01:00
Daniel Marjamäki 036b2a84bf Fixed #3570 (False Postive for 'nullPointer' check) 2012-02-01 20:38:47 +01:00
Edoardo Prezioso f9ade9562c Fixed ticket #3572 (segmentation fault). 2012-01-31 22:32:28 +01:00
Edoardo Prezioso bc034095f1 Fixed ticket #3543 (segmentation fault of cppcheck). 2012-01-31 19:34:55 +01:00
Edoardo Prezioso 66e1761ffe Fixed ticket #3571 (segmentation fault of cppcheck while scanning gcc-testsuite). 2012-01-31 18:42:19 +01:00
PKEuS 22c1ce8a68 Fixes for #3480 and #3568. 2012-01-31 15:49:34 +01:00
Edoardo Prezioso 9f81b48dc1 Fixed ticket #3558 (Tokenizer: improve simplifyVarDecl to take count of undefined size VLA's). 2012-01-30 23:41:43 +01:00
Edoardo Prezioso 0fd7504295 Related to ticket #3560 (conditional pointer user): remove also dead code in the lower scope if the actual scope isn't special. 2012-01-30 21:43:23 +01:00
Edoardo Prezioso 11e724df46 Tokenizer::simplifyTypedef: some optimizations on new code. 2012-01-30 17:08:35 +01:00
Edoardo Prezioso 7cd36f44b6 Tokenizer::simplifyTypedef: 'tokAt(offset)=>tokOffset': finished. 2012-01-30 16:38:04 +01:00
Edoardo Prezioso 67d095a10e Tokenizer::simplifyTypedef: 'tokAt(offset)=>tokOffset': work in progress.. 2012-01-30 16:20:15 +01:00
Edoardo Prezioso 7c596a2b90 Tokenizer::simplifyTypedef: 'tokAt(offset)=>tokOffset': work in progress.. 2012-01-30 16:18:42 +01:00
Edoardo Prezioso 187c463475 Tokenizer::simplifyTypedef: 'tokAt(offset)=>tokOffset': work in progress.. 2012-01-30 16:17:57 +01:00
Edoardo Prezioso b366bf69ad Tokenizer::simplifyTypedef: 'tokAt(offset)=>tokOffset': work in progress.. 2012-01-30 16:16:08 +01:00
Edoardo Prezioso fa077ede94 Tokenizer::simplifyTypedef: 'tokAt(offset)=>tokOffset': work in progress.. 2012-01-30 15:08:01 +01:00
Edoardo Prezioso 9438d1c2d0 Tokenizer::simplifyTypedef: 'tokAt(offset)=>tokOffset': work in progress.. 2012-01-30 15:04:41 +01:00
Edoardo Prezioso fe3fd1a073 Tokenizer::simplifyTypedef: redundant assignment to 'offset'. 2012-01-30 13:33:27 +01:00
Edoardo Prezioso 5a1585dcfb Tokenizer::simplifyTypedef: 'tokAt(offset)=>tokOffset': work in progress.. 2012-01-30 13:24:31 +01:00
Edoardo Prezioso d9e9c0aceb Tokenizer::simplifyTypedef: 'tokAt(offset)=>tokOffset': in progress.. 2012-01-30 13:15:25 +01:00
Edoardo Prezioso 017f0090fa Tokenizer::simplifyTypedef: 'tokAt(offset)=>tokOffset': begin conversion. 2012-01-30 13:10:50 +01:00
Edoardo Prezioso e530d770e1 Tokenizer::simplifyTypedef: to be sure there are no problems, promote to 'int' the variable 'offset'. 2012-01-30 13:04:10 +01:00
Edoardo Prezioso a93af0dba6 Tokenizer:: Use 'link' instead of 'parens' variable. 2012-01-30 12:22:37 +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 415aaca6dd Merge branch 'master' of git://github.com/danmar/cppcheck 2012-01-28 20:59:51 -05: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 697af4f7be Improve 'CheckMemoryLeakInClass::check'. 2012-01-28 23:24:00 +01:00
Edoardo Prezioso fa77f98b1c Tokenizer: it's possible to set null lower bound for eraseDeadCode when used inside simplifyFlowControl.
Remove now unused 'beginindent' and moved 'goto' simplification together with 'return' group.
2012-01-28 21:37:30 +01:00
Edoardo Prezioso bb703f4d0b Fixed: (warning) Found simple pattern inside Token::Match() call. 2012-01-28 20:31:12 +01:00
PKEuS 91a01a0a0d - checkUnsignedDivision checks for variable/variable (inconclusive). General bailout for if-statements.
- Make use of recently implemented symboldatabase functions (catch-support, reference-support)
- Other refactorizations
2012-01-28 12:32:28 +01:00
Daniel Marjamäki 46b8dc5e16 Fixed #3527 (Internal error. Token::Match called with varid 0. Please report this to Cppcheck developers) 2012-01-28 10:00:41 +01:00
Daniel Marjamäki 01f6bbda62 Null pointers: fixed false positive when '?' is used in return statement. Ticket: #3560 2012-01-28 08:06:03 +01:00
Robert Reif 42afd2d63a fix #3561 (SymbolDatabase: throw foo; creates a variable with type throw) 2012-01-27 19:24:01 -05:00
Edoardo Prezioso 8289e2428d Tokenizer: Stylish change to condition. 2012-01-27 17:12:28 +01:00
Edoardo Prezioso 0dd4b9ad3a Temporary workaround to ticket #3459 (Simplify goto before loop) :
don't simplify code which contains the label pointed by 'goto'.
2012-01-27 16:56:12 +01:00
Edoardo Prezioso 6314d04a04 Tokenizer: Add 'BOOST_FOREACH' pattern where it was missing. 2012-01-27 16:47:26 +01: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 421ae9df03 simplifyCondition: handle also '( a || true || b)' -> '(true)' and '( a && false && b)' -> '(false)'.
Clarify a comment about previous commit.
2012-01-26 23:14:44 +01:00
Edoardo Prezioso 0f1f3c0f5f Tokenizer::removeRedundantCondition: refactoring due to various reasons.
1) Remove the dead code with 'eraseDeadCode', not with 'eraseTokens' because of the possible presence of labels.
2) It's impossible that in tokenizer there is pattern like 'if (true|false) {code;} else if (cond) {code_cond;}' because the function 'Tokenizer::elseif' adds '{' between 'else' and 'if', hence a code path is redundant, so it's removed from code.
2012-01-26 22:32:11 +01:00
Edoardo Prezioso b6763313c5 Tokenizer::simplifyQuestionMark: use links instead of indentation level number. 2012-01-26 17:55:22 +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
PKEuS 6906001366 Added support for references to symboldatabase 2012-01-26 17:04:25 +01:00
PKEuS 5c2af0b2e3 - initialising std::string with 0 in initialisation list is partially detected in nullpointer check (#3520)
- executionpath checking makes use of symboldatabase
- CheckExceptionSafety::checkRethrowCopy makes use of symboldatabase
2012-01-26 16:50:59 +01:00
Edoardo Prezioso f428a29d8e Improve simplifyReturnStrncat when each argument is not composed by one token. 2012-01-26 16:09:32 +01:00
Edoardo Prezioso 20372eecfa Fixed gcc warning: variable which shadows a member of 'this'. 2012-01-26 15:20:20 +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
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