Commit Graph

3542 Commits

Author SHA1 Message Date
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