Commit Graph

853 Commits

Author SHA1 Message Date
PKEuS 6395cb9b95 Syntax error on invalid enum (#5600) 2014-03-22 19:31:01 +01:00
PKEuS a3f5beb75d Fixed problems with code "enum class { };" (which is valid C) 2014-03-18 16:23:30 +01:00
Lucas Manuel Rodriguez 9a08da17be Fixed #4928 (C++ operator aliases result in false 'assigned a value that is never used' warning) 2014-03-16 14:51:05 -03:00
PKEuS e05fb847df Fixed #3852: Support simplification of C++11 "enum class", fixed existing simplifications 2014-03-16 18:24:46 +01:00
Frank Zingsheim b1dc51ba9c Fixed #4796 (Missing semicolon after simplified template class) 2014-03-12 06:09:45 +01:00
Daniel Marjamäki fd3a8a2a18 Update copyright 2014-02-15 07:45:39 +01:00
Daniel Marjamäki 43db1ee797 value flow: use more specific bailouts when analysing value flow after assignment 2014-01-22 06:38:25 +01:00
Daniel Marjamäki 0203a4a6f5 Tokenizer: Removed simplifyGoto as it's the cause of various FPs I see 2014-01-17 17:36:45 +01:00
Daniel Marjamäki 4eb746d7cc Tokenizer: Removed simplifyComparisonOrder 2014-01-17 17:25:56 +01:00
Heinrich Schuchardt f6510a6b45 Fixed #5339 (Tokenizer::setVarId : function-pointer function argument not getting variable id, causing FP) 2014-01-12 15:15:09 +01:00
Graham Whitted 86201c13cb Fixed #5097 (TemplateSimplifier::expandTemplate assertion failure) 2014-01-05 19:19:52 +01:00
PKEuS 4f0121ee2f Splitted simplification out of tokenize() 2013-12-30 17:45:28 +01:00
Daniel Marjamäki 41e4194573 Tokenizer: set links for <> in 'a=new b<c>;' code 2013-12-29 15:37:27 +01:00
Daniel Marjamäki 762806499f Fixed #5182 (Tokenizer::simplifyEnum: template function call as enum value) 2013-12-16 07:07:00 +01:00
Daniel Marjamäki 7938692b01 Fixed #5212 (Tokenizer::simplifyEnum bad simplification of enum value (1<<0)|(1<<1)) 2013-12-15 07:47:04 +01:00
Daniel Marjamäki f599e3184c Fixed #5174 (Tokenizer: member function 'abort' returns) 2013-12-14 11:12:48 +01:00
Alexander Mai 38b2f6b9b0 Fixed #5168 (segmentation fault (invalid code) in Tokenizer::simplifyVarDecl) 2013-11-24 11:07:11 +01:00
Daniel Marjamäki 8cca41774d Fixed #4446 (Crash on complex C++ template) 2013-11-21 20:27:24 +01:00
Daniel Marjamäki ef108c49ec Tokenizer: simplify enums better. add parentheses to enforce operator precedence. 2013-11-20 18:04:28 +01:00
Daniel Marjamäki f8cf64afef Fixed #4710 (Template parser bug: const in constructor changes template names) 2013-11-19 06:07:25 +01:00
Daniel Marjamki bcc8384a95 Fixed #5145 (False Positive: Variable 'A' hides enumerator with same name) 2013-11-03 09:34:48 +01:00
Daniel Marjamäki c234cace6d Fixed #5064 (Tokenizer::simplifySizeof: Doesn't simplify 'sizeof !! (a==1);' properly) 2013-10-06 08:20:10 +02:00
Robert Reif 44559a1fb2 Fixed #5069 (sizeof(void) when variable name is override) 2013-10-05 07:40:59 +02:00
Daniel Marjamäki 1c513f330a Fixed #5055 (False negatives when using -I (external source code)) 2013-09-29 18:59:27 +02:00
PKEuS a9a5dc0354 Updated to AStyle 2.03, require this version 2013-08-07 16:27:37 +02:00
Alexander Mai 39ba0d36c1 TestRunner: added test case for assignment simplification in do-while (#4881). 2013-07-29 12:10:11 +02:00
Lucas Manuel Rodriguez 09f4d3732a Fixed #4911 (segfault, assignment in do ... while, 1.61dev) 2013-07-28 11:58:14 +02:00
Daniel Marjamäki dfed6bbea0 Fixed #4445 (Token::Match called with varid 0) 2013-07-19 21:18:54 +02:00
Daniel Marjamäki 2875ee1ecf astyle formatting 2013-07-07 10:26:20 +02:00
Simon Martin d0d3ce50c9 Added testcase for (now working) ticket #4742. 2013-07-06 18:02:04 +02:00
Daniel Marjamäki 7dd07472c1 Fixed #4530 (Tokenizer: improved simplification of strlen in calculation) 2013-06-25 20:10:40 +02:00
Daniel Marjamäki 8ac2b4d516 Travis: Fixed failing test 2013-06-16 16:53:09 +02:00
Daniel Marjamäki a9bd6cf3df Fixed #4857 (False Positive: function argument hides enumerator of same type) 2013-06-16 08:13:41 +02:00
Daniel Marjamäki 722bfe7197 Fixed #4553 (Wrong calculation of known values) 2013-06-14 18:51:52 +02:00
PKEuS 876e9c0039 Fixed issue on C++11 right angle brackets (#4832) 2013-06-12 13:43:29 -07:00
Daniel Marjamäki c4763b9010 Fixed #4463 (false positive: (style) Variable 'CHDERR_NOT_OPEN' hides enumerator with same name) 2013-06-12 06:45:26 +02:00
Frank Zingsheim f5a3492e3a astyle formatting 2013-06-05 22:19:37 +02:00
Daniel Marjamäki dec520c507 Tokenizer::simplifyEnum: Fixed false positives 2013-06-04 21:18:20 +02:00
Daniel Marjamäki 8b5792a0f8 Tokenizer::simplifyEnum: Fixed internalErrors when building with compiled patterns. 2013-06-04 18:57:46 +02:00
Daniel Marjamäki fa1fd31667 Tokenizer::simplifyEnum: Improved handling of shadow variables 2013-06-04 06:51:01 +02:00
Daniel Marjamäki 8954cc0984 Fixed #4280 (Tokenizer::simplifyEnum: don't simplify shadow variables) 2013-06-03 19:18:51 +02:00
Daniel Marjamäki 4659745106 Fixed #4786 (segfault with one LibreOffice file) 2013-05-06 16:56:34 +02:00
Frank Zingsheim 42068a3d60 Fixed #4767 (segmentation fault in expand template) 2013-05-01 13:28:01 +02:00
PKEuS 693c6e84cb Removed more duplicate unit tests 2013-04-13 01:49:17 -07:00
Daniel Marjamäki 9ad39ca4c0 Fixed #4544 (Crash with this line : class CD : public CC< class CB< CA > >) 2013-04-12 16:38:12 +02:00
Daniel Marjamäki e8fbd39efd Templates: better handling of 'X<class Y>' template instantiations. Ticket: #4544 2013-04-11 18:58:39 +02:00
Daniel Marjamki cd770fb106 Fixed #4310 (False positive 'boolean result in bitwise' message in template class (was #3818)) 2013-04-07 16:48:42 +02:00
Ettl Martin 1b9c1c03fa unittests: removed not needed '\n' at the end of testcases. 2013-03-20 15:36:16 +01:00
PKEuS 14feaa8d39 Refactorizations:
- Fixed lots of cppcheck messages about functions that can be const or static
- Fixed possible nullpointer dereference message in symboldatabase.cpp
- Replaced tokAt(+-1) by next()/previous()
2013-03-12 07:42:00 -07:00
Daniel Marjamäki 48e194dc56 Fixed #4572 (Analysis failed: sizeof final) 2013-02-10 23:54:15 +01:00
Andrew C. Martin bd0d9b9639 fix misspellings & gcc v3.4.6 warnings
1.  fix typos / misspellings
 - Fix misspelling within comments, variable/function names, stdout messages
 - changes the name of an error code: ```stlBoundries``` changed to ```stlBoundaries```.  Alias old name (```stlBoundries```) to the new one.

2.  fix gcc v3.4.6 32bit & 64bit warnings

 - fixes gcc v3.4.6 warnings, except for those in tinyxml and "-Wmissing-declarations" makefile warnings
 - in Preprocessor::handleIncludes(), replace a ```vector <bool>``` with ```stack<bool>``` (see ```vector<bool>``` warning below).
   - this is the only ```vector<bool>``` in the codebase
 - ```vector <bool>``` is actually a case of template specialization, and is not recommended, according to the following links:

http://stackoverflow.com/q/6461487
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2160.html
http://stackoverflow.com/q/670308

 - in the codebase before and after this change, testrunner SEGVs in a number of places on gcc v3.4.6, including ```Check::~Check()```, among others
   - fc42fc95 fixes this particular runtime issue for DJGPP & __sun
2013-02-09 23:43:09 -07:00
Daniel Marjamäki 67c9720299 Tokenizer: fixed simplification of static constants 2013-01-19 21:14:15 +01:00
Andrew C. Martin 4a73c93750 Fix compiler warnings and comment/string typos
- fix g++ warning:

> lib/checkother.cpp:3779: warning: comparison between signed and unsigned integer expressions

 - fix suncc warning (see [everything2](http://everything2.com/title/C%252B%252B%253A+static+extern+%2522C%2522)):

> "lib/checkmemoryleak.cpp", line 578: Warning (Anachronism): Formal argument __compar of type extern "C" int(*)(const void*,const void*) in call to bsearch(const void*, const void*, unsigned long, unsigned long, extern "C" int(*)(const void*,const void*)) is being passed int(*)(const void*,const void*).

- prefer empty() / isEmpty() over "size() > 0" (cases not caught by stlSize)

- fix word misspellings (mostly comments, a few output lines)

  - Parenthesis => Parentheses (both variations were used in the codebase)

  - fix typo and wording ("never alwayw") in gui/test/data/benchmark/simple.cpp's CheckOther::unsignedPositive():

```
-  "An unsigned variable will never alwayw be positive so it is either pointless or "
+  "An unsigned variable can't be negative so it is either pointless or "
```
2013-01-16 07:37:07 -07:00
Erik Lax 723d95597b Fixed #4481 (Simplify %str% [ %num% ]) 2013-01-13 20:52:38 +01:00
Daniel Marjamäki 2e56928834 Fixed #4482 (add test for UB due to usage of NULL in variadic functions) 2013-01-13 12:02:10 +01:00
Daniel Marjamäki 97b928b2bc Fixed #4476 (Tokenizer: wrong simplification of static anonymous-type struct array declaration) 2013-01-10 18:24:01 +01:00
Daniel Marjamäki eebfea2b23 Fixed #4381 (Inline type declaration on statics causes warning) 2013-01-07 19:20:15 +01:00
Reijo Tomperi 5d5f7085bf Updating year 2012 -> 2013 to .cpp and .h files and man page. 2013-01-01 18:29:08 +02:00
Daniel Marjamäki b3301a9ef9 Fixed #4433 (Wrong array size for string with \0) 2012-12-26 12:10:09 +01:00
Daniel Marjamäki db2a129557 Tokenizer: Improved handling of '\0' in strings 2012-12-25 08:56:12 +01:00
Daniel Marjamäki 47e1a571f7 Tokenizer: Fixed goto problems 2012-12-22 19:28:53 +01:00
PKEuS 4737966caf Unit test cleanup: Removed some empty lines and whitespaces before \n. 2012-12-06 10:19:22 -08:00
Robert Reif b216639069 Fixed #4378 (simplifyEnum doesn't simplify enum type within open and close parenthisis) 2012-12-02 07:22:55 +01:00
Edoardo Prezioso 47f1220367 Remove useless preprocessor pieces from some testcases. 2012-11-30 20:28:30 +01:00
Edoardo Prezioso a219ed313b Fixed again #2963 (FP: Typedef names considered duplicate because __LINE__ not expanded).
It is caused by a regression introduced with commit 75fbe310ff. Add also a TODO in the non working detection inside TestSimplifyTokens::simplifyTypedef98.
2012-11-30 00:00:44 +01:00
Edoardo Prezioso 76639578ad Improve Tokenizer::simplifyFuncInWhile.
Differentiate between the new cppcheck:r variables by appending a number to the name, like 'cppcheck:r1', 'cppcheck:r2' and more.
2012-11-26 02:19:35 +01:00
PKEuS b15ff0c0e3 Fixed unit test failures caused by previous commit 2012-11-11 15:16:08 +01:00
PKEuS 17b720ef7d Refactorization: Removed unnecessary code. Variable::typeStartToken() and Variable::typeEndToken() never point to "const".
Ran AStyle
2012-11-11 13:32:19 +01:00
PKEuS 58fe7105f4 Remove C++11 keywords "override", "final" and "constexpr" 2012-11-09 19:53:10 +01:00
Edoardo Prezioso 119ab519a4 Support GNU extension of '?:' operator:
"x ? : y" is equivalent to "x ? x : y". I found a lot of code with this extension, probably we should warn a user to not use this.
2012-11-08 17:49:43 +01:00
Edoardo Prezioso 71150e987d Add testcase related to commit 0d26a79f2c.
cover up the case when there's at least a token before 'namespace %type% { }'.
2012-11-04 23:14:41 +01:00
Daniel Marjamäki be174d6266 TemplateSimplifier: Fixed bad pattern that was detected by CheckInternal and pointed out by edward-san. The handling of recursive templates is better now. 2012-10-14 19:48:53 +02:00
Edoardo Prezioso 1951d1cdc5 Tokenizer: improve the new 'skipTernaryOp' function by supporting GCC '{(var|num;)}' statement expression extension; improve 'Tokenizer::simplifyQuestionMark' by supporting simplification with 'case' before ternary operation, using skipTernaryOp to get colon and, most importantly, supporting indented '?:' operations. 2012-10-13 02:32:43 +02:00
Daniel Marjamäki c2b61030a8 Fixed #4254 (Tokenizer::simplifyIfAssign: varids not preserved) 2012-10-06 12:49:24 +02:00
Daniel Marjamäki 9a462d8a0a Fixed #4225 (False positive: uninitialized variable (assignemnt in ternary expression with cast)) 2012-09-30 18:49:25 +02:00
PKEuS c4b881f844 Refactorizations in tokenize.cpp and testsimplifytokens.cpp:
- Avoid const_cast in testsimplifytokens.cpp
- Removed redundant null-check (VS11 code analysis)
- Fixed MSVC compiler warning
- Replaced some indentation counters
2012-09-29 14:10:41 +02:00
XhmikosR 5101243c64 use const_cast instead of c cast 2012-09-29 13:15:09 +02:00
Daniel Marjamäki 8010bcfbe8 astyle formatting 2012-09-26 18:17:02 +02:00
Daniel Marjamäki 0ff8105c71 Fixed #4074 (Internal error. Token::Match called with varid 0) 2012-09-24 06:44:51 +02:00
Daniel Marjamäki 6c25f3662e Tokenizer::simplifyEnum: Don't simplify enums in function heads. Ticket #3953 2012-09-21 16:17:20 +02:00
Edoardo Prezioso 8e1e8525a3 Partial rewrite of Tokenizer::simplifyComma:
skip '= { .. }' where possible;
hence remove '%num% after comma' check because it's redundant now;
replace round braces counter method with faster 'link skip';
if 'endAt' is 'NULL' after finding the ';' token, exit the function;
hence remove redundant 'tok != NULL' check after simplifying 'return' code.
2012-09-20 21:45:16 +02:00
Daniel Marjamäki aa3cdc6b6f Fixed #3565 (Variable hides enumerator (attached code example)) 2012-09-19 19:19:13 +02:00
Ettl Martin 3905f4ad7d fixed #4169 semgentation fault (invalid code); Applied patch from amai and added a unittest. 2012-09-19 11:03:40 +02:00
Daniel Marjamäki 07d2935e81 Fixed #4164 (False positive: (error) Uninitialized variable: min) 2012-09-18 20:55:37 +02:00
Daniel Marjamäki a99515ca91 Fixed #3933 (Negative array index issue (because sizeof struct is assumed to be 100)) 2012-09-16 08:20:43 +02:00
Daniel Marjamäki 19fdbf0fd0 Fixed #4185 (Incorrect 'Found duplicate if expressions' for strings with high bit set) 2012-09-13 16:44:10 +02:00
Daniel Marjamäki 7acb04b44c Tokenizer: improved simplification of numeric calculations 2012-09-09 16:22:39 +02:00
Daniel Marjamäki 511c5a62e7 Fixed #4141 (Crash when parsing divide by zero.) 2012-09-09 12:38:15 +02:00
Daniel Marjamäki 0c55d5cfa7 Fixed #4002 (syntax error for 'X( typedef, Y)') 2012-09-09 09:14:46 +02:00
Daniel Marjamäki 69a0062177 Tokenizer: don't crash for 'int'. Ralated with tickets #2978 and #3304 2012-09-08 20:59:25 +02:00
Daniel Marjamäki 853c6522dc Tokenizer::simplifyEnum: Readded refactorings. Tickets 3949,3950,4025,4053 has been solved as far as I see. 2012-09-08 12:42:24 +02:00
PKEuS 78d49ea4b8 Fixed #3732 - properly simplify struct declarations:
- Don't replace "{ {" if they are part of an initialization
- Properly split struct definition, variable declaration and variable initialization.

Used std::stack instead of std::list
2012-09-08 10:51:31 +02:00
Daniel Marjamäki 2722f53edd Fixed #4142 (false positive (error) Uninitialized variable: b) 2012-09-08 10:15:37 +02:00
anuraggarg011 913670d254 Fixed #3304 (simple cases) 2012-09-04 13:41:14 +02:00
Edoardo Prezioso 04661fd7d0 Fixed test changes I forgot in previous commit. 2012-09-03 15:20:34 +02:00
PKEuS c20adf91bf Moved simplification of wide character string literals (L"foo") to tokenize(). Token::isLong flag used to indicate that string is a wchar_t literal. 2012-09-01 13:12:47 +02:00
Edoardo Prezioso 0d26a79f2c Tokenizer::simplifyEmptyNamespaces: new function.
It removes from the token list, if found, the following tokens: 'namespace %var% { }'. It won't involve C code.
2012-08-28 22:40:25 +02:00
Daniel Marjamäki f127728582 Enable --std=c11 and --std=c++11 by default 2012-08-25 21:57:45 +02:00
Daniel Marjamäki 7786e12ba2 Fixed #3922 (false positive: (error) null pointer dereference) 2012-08-18 22:11:48 +02:00
Daniel Marjamäki 6a5cc4727d Fixed #4019 (false positive: (style) Variable 'dest' is assigned a value that is never used) 2012-08-17 16:37:25 +02:00
Daniel Marjamäki e534ee0426 Fixed #3706 (cppcheck 1.53 hangs when processing a certain template with specializations) 2012-08-13 16:17:33 +02:00
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
Edoardo Prezioso 1d8240356b Really fixed #4024. Now the simplification won't be done on non-executive scopes. 2012-08-10 17:43:09 +02: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
Daniel Marjamäki 6ff1760c72 TemplateSimplifier: Improved handling of unknown inner template instantiation inside template instantiation (#3818) 2012-08-09 17:19:36 +02:00
Daniel Marjamäki 4ec12209dc TemplateSimplifier: Fixed wrong match when inner template parameters are wrongly counted (#3818) 2012-08-08 06:43:41 +02:00
Daniel Marjamäki 77b8e496d6 fixed testrunner assertion 2012-08-07 16:42:11 +02:00
Daniel Marjamäki 735c0f5f6b Fixed #3963 (segmentation fault of cppcheck (invalid typedef code)) 2012-08-07 16:39:41 +02:00
Edoardo Prezioso 9e916eec66 Fixed #4024 (Tokenizer::simplifyFlowControl removes pieces of code inside a class if 'exit' is a member function). 2012-08-07 10:59:27 +02:00
Edoardo Prezioso 09fd3a6ed7 Fixed a testcase failure from Token::stringifyList change. 2012-08-07 10:22:11 +02:00
Daniel Marjamäki 5ee7758a83 Fixed #4015 (segmentation fault of cppcheck (enum)) 2012-08-06 16:21:21 +02:00
Daniel Marjamäki 445fd4e6aa Fixed #4010 (error (cppcheckError): Internal error. Token::Match called with varid 0) 2012-08-05 17:11:39 +02:00
Daniel Marjamäki 435340b463 Fixed #3814 (false positive: missing constructor) 2012-07-29 16:01:05 +02:00
Daniel Marjamäki 1a6f7ea9a0 Fixed #3998 (Tokenizer::simplifyEnum: wrong handling of expressions => crash) 2012-07-26 11:12:28 +02:00
PKEuS 9834888f19 Removed some duplicate tests and a redundant variable 2012-07-25 01:34:54 -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 49198f52c4 Fixed #3934 (False positive for logical conjunction with enum and define) 2012-07-07 15:34:26 +02:00
seb777 5b763a9f0a Fixed #3579 (object destroyed immediately:False positive & negative) 2012-06-10 21:52:32 +02:00
Ettl Martin da5278f90c Added testcase for ticket #3852 2012-05-29 13:20:51 +02:00
Daniel Marjamäki 0bb0fdedc2 Fixed #3747 (False 'boolean result in bitwise' message with 'mask' enums) 2012-05-16 18:48:33 +02:00
PKEuS ec00824fd3 Fixed #3357:
- Print "inconclusive" tag in cli
- Fixed inconclusive handling in checkbufferoverrun.cpp
- Merged reportInconclusiveError into reportError by adding an additional parameter "bool inconclusive" which is false per default
2012-05-06 10:37:41 -07:00
PKEuS 1a5fbd61d2 Splitted class TokenList from Tokenizer 2012-05-05 09:33:26 -07:00
Edoardo Prezioso 6fd6f0998b Improvement to 5b8840c6b02bd648dc2b75e60145474ae12f8e67: handle also 'const struct|union' types as template parameters. 2012-04-27 20:51:55 +02:00
Daniel Marjamäki 5b8840c6b0 Fixed #3764 (Tokenizer::setVarId: no varid for templated variables with const/struct/union types) 2012-04-27 18:02:07 +02:00
Edoardo Prezioso 08ae15e42d Fixed the grammar in some reportError messages in the Tokenizer class, thanks to kimmov's suggestion. 2012-04-25 15:09:46 +02:00
PKEuS 88aa08e71b Refactorizations in test suite:
- Removed redundant tokenization helper functions in testtokenize.cpp and testsimplifytokens.cpp
- Pass arguments as const char[] or const std::string& to avoid instanciation or at least copying of strings
- Removed redundant calls to Tokenizer::validate() - This function is already called implicitly by tokenize() and simplifyTokenList()
2012-04-17 09:51:08 +02: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
PKEuS 62d5069387 Fixed #3722: Handle associative law correctly for operator* 2012-04-13 11:55:09 +02:00
Daniel Marjamäki 6bae724cb6 Fixed #3705 (cppcheck crash (null pointer exception)) 2012-04-09 15:06:06 +02:00
Daniel Marjamäki 68e6511c87 Fixed #3532 (false positive : missing constructor) 2012-03-31 11:30:26 +02:00
PKEuS 0338153de9 Added test case for #3619 2012-03-25 10:33:18 +02: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
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
Edoardo Prezioso d7a918e549 Fixed ticket #3616 (segmentation fault of cppcheck). 2012-02-18 17:58:50 +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 17cd5ec906 Fixed ticket #3604 (cppcheck(1.53) crash). 2012-02-17 21:14:38 +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
Edoardo Prezioso f9ade9562c Fixed ticket #3572 (segmentation fault). 2012-01-31 22:32:28 +01:00
Edoardo Prezioso f8578a380a Added test case from #3533 (segmentation fault of cppcheck). 2012-01-31 18:23:02 +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 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 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 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 f428a29d8e Improve simplifyReturnStrncat when each argument is not composed by one token. 2012-01-26 16:09:32 +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 2a2d01a870 Remove some redundant 'errout.str("")' in some checks because it's already done inside tok call. 2012-01-21 00:59:12 +01:00
Edoardo Prezioso 963f6ce3ef Tokenizer: report syntaxError if there's nothing after 'if|for|while ()' and if there's nothing inside round brackets;
TestTokenizer: change test cases accordingly;
TestSimplifyTokens: ditto.
2012-01-15 14:50:01 +01:00
Edoardo Prezioso a7029291fd Tokenizer::simplifyGoto: process also derived class/structs. 2012-01-04 17:08:53 +01:00
Edoardo Prezioso 6f9cd110d0 Improve Tokenizer: improve 'simplifyDoublePlusAndDoubleMinus' when there are negative numbers. 2012-01-04 13:45:27 +01:00
Reijo Tomperi 8cae17fda8 Update year to 2012 2012-01-01 01:05:37 +02:00
Daniel Marjamäki 8a6b1dc1c9 Fixed #3449 (segmentation fault of cppcheck) 2011-12-31 12:08:49 +01:00
PKEuS 9b685ba3c3 Code cleanup 2011-12-09 21:00:57 +01:00
Edoardo Prezioso 7d12951da0 1)Fixed ticket #3184 (Improve Tokenizer: improve simplifyMulAnd to simplify weirder code);
2)Fix a test case inside TestSimplifyTokens::flowControl.
2011-12-09 20:47:51 +01:00
PKEuS 1c1c31bea0 Tokenizer: Refactorings and improvements. Better handling of [] 2011-12-07 21:15:00 +01:00
Edoardo Prezioso b9224439c1 Add 'exit' and 'abort' to the flow control list in order to simplify code after them. 2011-12-06 22:56:12 +01:00
Edoardo Prezioso 0504952950 Remove some redundant parenthesis - part 9 2011-12-06 16:53:57 +01:00
Edoardo Prezioso 9cadd7c17a Remove some redundant semicolons - part 8 2011-12-04 19:11:51 +01:00
Edoardo Prezioso 4946b036ad Remove some redundant semicolons - part 7 2011-12-04 18:08:35 +01:00
Edoardo Prezioso 52a174fa9d Remove some redundant semicolons - part 6 2011-12-04 17:30:25 +01:00
Edoardo Prezioso b45d63a10a Remove some redundant semicolons - part 5 2011-12-04 17:15:53 +01:00
Edoardo Prezioso a363749a17 1) Remove some redundant semicolons - part 4 ('typedef' != _tokens.str());
2) Tokenizer: Use Token::eraseTokens instead of using the same instructions as the ones inside such function.
2011-12-04 15:40:05 +01:00
Daniel Marjamäki 49784a44e1 Tokenizer: improved handling of inner templates. Partial fix for #3226 2011-12-04 11:38:41 +01:00
Edoardo Prezioso f47ac539d6 Tokenizer::simplifyFlowControl: 1) remove consecutive 'break' or 'continue', since they don't influence the CheckOther results; 2) improve the code speed where possible;
Tokenizer::eraseDeadCode: Ditto.
2011-12-03 17:15:19 +01:00
Daniel Marjamäki 50dfdf7c2e Fixed #3350 (Analysis failed) 2011-12-03 15:15:15 +01:00
Edoardo Prezioso 00bae586e9 Add 'throw' to the flow control statements list for simplification of dead code. 2011-12-03 02:04:29 +01:00
Edoardo Prezioso 42a557432d Remove some redundant semicolons - part 3 2011-12-02 23:04:06 +01:00
Edoardo Prezioso d0d5a2fcd8 Completed ticket #3230 (Refactoring: add function to remove tokens when a label is found.) and fixed ticket #3264 (False positive: Variable is assigned a value that is never used). 2011-11-20 18:37:00 +01:00
Edoardo Prezioso fa34a14d57 Add more tests for flow control simplification. 2011-11-18 21:10:56 +01:00
Edoardo Prezioso 44e348d018 Add test for the consecutive braces simplification, thanks to thomasjfox's example. 2011-11-18 21:04:24 +01:00
Thomas Jarosch c317c8979c Run astyle 2011-11-14 09:21:42 +01:00
Edoardo Prezioso 5cbfbe31c1 Add removal of consecutive braces, i.e.: '{ { ... } }'->'{ ... }'.
Changed a little bit the dead code tests.
2011-11-12 12:07:10 +01:00
Edoardo Prezioso a546fc6e9d Fixed ticket #3310 (segmentation fault of cppcheck) 2011-11-08 17:37:24 +01:00
Edoardo Prezioso 3abece027e Refactoring: unify same dead code tests with a list. 2011-11-08 14:13:26 +01:00
Daniel Marjamäki acaa9c456f Fixed #3152 (Tokenizer: template constructor is removed) 2011-10-29 19:45:47 +02:00
PKEuS d6261debdf Fixes false positives in test suite, adds unit test for void-simplification 2011-10-27 21:54:42 +03:00
Erik Lax b7ab1e7d7e Fixed #3237 (Bug in parser of class operator functions) 2011-10-23 10:25:14 +02:00
Johan Samuelson 3d8fa2f76e Fixed #3123 ([False Positive] Shadowed enum) 2011-10-22 13:43:53 +02:00
Edoardo Prezioso 9257e82475 Improve tokenizer: don't confuse between a label and the case/default statements. 2011-10-19 18:49:02 +02:00
Edoardo Prezioso 882b0c15a0 Improve tokenizing of "do{ ... } while(0)".
The simplification will be the same for every combination, except for the 'continue' and the 'break'. In that case, keep the block braces.
2011-10-19 18:20:29 +02:00
Edoardo Prezioso f4cdf57955 Fixed ticket #3229 (Segfault with goto):
Don't handle labels, gotos, returns and indentations inside the round braces. This is applied not only for simplifyGoto, but also to simplifyFlowControl.
Rewrite enum badly handled by astyle inside mathlib.cpp and move simplifyFlowControl at the end of the simplifyTokenList in order to catch more dead code, not related to the ticket.
2011-10-18 23:56:35 +02:00
Edoardo Prezioso c3caade3ca - Fixed mispelled function name;
changed variable name inside simplifyFlowControl for consistency;
improved simplifyFlowControl to handle better this kind of code:
"return; { { } { label : ; ok ( ) ; } }"->"return ; { { label: ok ( ) ; } }".
2011-10-17 02:16:49 +02:00
Edoardo Prezioso 57ead6988e Fixed ticket #3138 (Tokenizer: remove unreachable code below goto inside a namespace|class|struct block) 2011-10-15 11:35:45 +02:00
Edoardo Prezioso f95b692a69 Fixed ticket #3113 (complete simplification of dead code after control flow statements) 2011-10-15 01:34:07 +02:00
Daniel Marjamäki 6f8e42a5af changed the astyle formatting flags 2011-10-13 20:53:06 +02:00
Edoardo Prezioso b792efb761 Fix ticket 3140 and 3137 (Improve Tokenizer: Remove dead for loop - simplify while(0) better.
Note: it doesn't remove dead code if there's a label inside. Will be improved in another ticket.
2011-10-13 13:01:24 +02:00
Edoardo Prezioso 16506f0a8c Remove redundant simplifyDeadCode call inside the Tokenizer::tokenize and move the relative tests in the file 'testsimplifytokens.cpp'. 2011-10-13 12:26:27 +02:00
Edoardo Prezioso af23a9dcbb Fixed ticket #3140 (Improve Tokenizer: Remove dead for loop 'for (int i = 0; i < 0; ++i)') 2011-10-10 15:15:45 +02:00
Robert Reif ac942c6684 fix #3151 (missing portability warning for extra qualifier on destructor) 2011-09-29 19:25:14 -04:00
Robert Reif f97424b242 start adding Windows ASCII TCHAR conversion support 2011-09-24 14:51:03 -04:00
Robert Reif a685f1f5b7 add operator support to ertra qualification check 2011-09-23 19:45:19 -04:00
Robert Reif 97d4277854 add Microsoft memory function conversions to standard cstring functions 2011-09-22 19:59:56 -04:00
Robert Reif 66eb37c135 convert size_t to standard type 2011-09-18 10:31:31 -04:00
Edoardo Prezioso 1ff7410f4f Fixed #3075 (False positive => Improve tokenizer: remove redundant code after a 'return' state) 2011-09-13 07:55:47 +02:00
Daniel Marjamäki 46b5d5bd00 Fixed #3069 (False positive: Memory leak: data) 2011-09-03 20:45:48 +02:00
Daniel Marjamäki d23c58d387 enable: break out 'performance' and 'portability' from the 'style' id. Ticket: #3074 2011-09-03 15:30:30 +02:00
Robert Reif f4e07c3179 fix #3070 (Other: failed to parse a typedef string. Check continues anyway.) 2011-09-01 19:10:58 -04:00
Robert Reif 4168d79b09 fix #3005 (segmentation fault of cppcheck ( enum : x )) 2011-08-15 07:07:12 -04:00
Robert Reif 5364b4f7fb fix #3007 (false positive: (style) Struct 'Fred' hides typedef with same name) 2011-08-15 06:56:15 -04:00
Robert Reif ed507b73ee fix #3004 (false positive: (style) Struct 'Fred' hides typedef with same name) 2011-08-14 21:00:05 -04:00
Robert Reif 08e9d64a86 fix #3003 (segmentation fault of cppcheck (typedef a x[]; y = x )) 2011-08-14 20:38:16 -04:00
Robert Reif b7f42535ec fix #3000 (false positive: (style) Struct 'Fred' hides typedef with same name) 2011-08-14 18:50:33 -04:00
Robert Reif 389ab80b63 fix #2999 (false positive: (style) Struct 'Fred' hides typedef with same name) 2011-08-14 18:06:05 -04:00
Robert Reif ce00d0d35e fix #2963 (FP: Typedef names considered duplicate because __LINE__ not expanded) 2011-08-11 18:18:47 -04:00
Robert Reif 10eb224ac7 fix #2983 (segmentation fault of cppcheck) 2011-08-09 18:31:02 -04:00
Robert Reif 829611b129 fix #2978 (segmentation fault of cppcheck ( enum E {} e enum )) 2011-08-07 16:48:47 -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 d23fb873cc fix #2970 (Incorrect report: Class does not have a constructor) 2011-08-06 17:54:02 -04:00
Robert Reif fd01a7555a fix #2966 (segmentation fault of cppcheck ( enum x : )) 2011-08-05 18:07:18 -04:00
Daniel Marjamäki fb3870071a Fixed #2885 (crash of cppcheck while checking gcc-testsuite) 2011-07-21 16:13:35 +02:00
Daniel Marjamäki 9f22d2fc6b Fixed #2897 (out of bounds false positive, using reinterpret_cast) 2011-07-21 09:32:24 +02:00
Daniel Marjamäki 481be84004 TestSimplifyTokens: removed copy/pasted comment 2011-07-17 09:14:03 +02:00
Daniel Marjamäki 35938e74ad Tokenizer: better handling of 'struct AB ab; sizeof(ab)' 2011-07-16 22:07:30 +02:00
Daniel Marjamäki 5561d81f0d Tokenizer::simplifyGoto: fixed unit tests 2011-07-03 18:35:11 +02:00
Robert Reif b143b283e9 fix #2886 (crash of cppcheck ( typedef struct x { } )) 2011-07-03 10:50:15 -04:00
Robert Reif 8ec1dfacbf fix missing pop in Tokenizer::simplifyStructDecl() when anonymous struct/union removed 2011-07-03 08:14:51 -04:00
Robert Reif 3f4cc5fa3a add class A {} a; -> class A {}; A a; conversion capability to Tokenizer::simplifyStructDecl() 2011-07-02 09:21:30 -04:00
Reijo Tomperi 89fd5bacf9 Fix #2849, False positive: memory leak (using question mark operator)
http://sourceforge.net/apps/trac/cppcheck/ticket/2849
Simplify: *d = b ? b : a; into if-else
Simplify { ; { ; } } into { ; }
Removed one memleak test which should be redundant now as question marks
should not get into memleak check.
2011-06-30 22:04:26 +03:00
Robert Reif 1713eeb532 fix #2859 (Extra qualification not detected) 2011-06-26 21:13:29 -04:00
Reijo Tomperi 918b4d859f Fixed #2860, False positive: Returning value of strncat() reported as memory leak
http://sourceforge.net/apps/trac/cppcheck/ticket/2860
2011-06-26 23:53:16 +03:00
Robert Reif d80a55267c fix #2844 fix to generate correct output 2011-06-19 20:19:16 -04:00
Robert Reif 0bd26a73c4 fix #2844 (typedef causes 'syntax error') 2011-06-19 17:57:01 -04:00
Robert Reif eaf836b323 fix extra qualification check for same class name in different namespaces 2011-06-14 15:31:52 -04:00
Robert Reif d1b260699a fix #2834 (crash of cppcheck (std::vector<int>::iterator)) 2011-06-12 08:24:49 -04:00
Robert Reif 3d4eb0d77e fix #2682 (segmentation fault of cppcheck ( x a[0] = )) 2011-06-10 15:11:45 -04:00
Robert Reif 6635ed4630 fix #2828 (false positive: Function parameter 'STYLE' hides enumerator with same name) 2011-06-08 20:14:52 -04:00
Robert Reif 311651cc66 fix #2804 (Underlying type of enumerator produces a syntax error) 2011-05-27 11:17:39 -04:00
Robert Reif 51baca0359 fix #1982 (simplifyTypedef: scope info is lost) 2011-05-02 22:42:52 -04:00
Daniel Marjamäki bbd379c802 astyle formatting 2011-05-02 15:08:16 +02:00
Daniel Marjamaki 297ca63868 Fixed #2721 (Tokenizer::simplifyTemplates: fail when using template argument 'char[2]') 2011-05-01 19:05:18 +02:00
Robert Reif 3c415e7833 fix #2745 (Enum vs local variable - conflict) 2011-04-23 22:08:03 -04:00
Robert Reif 04309f74f5 fix #2738 (syntax error on valid code) 2011-04-20 19:09:28 -04:00
Robert Reif b1d3d291e6 fix #2736 (segmentation fault of cppcheck) 2011-04-20 07:49:04 -04:00
Robert Reif 877a233145 fix #2716 (Easy to reproduce crash) 2011-04-16 10:35:23 -04:00
Daniel Marjamäki 739b6a93e2 Fixed #2713 (False positive (Redundant assignment)) 2011-04-16 12:07:56 +02:00
Robert Reif 3159df958d fix #2720 (false positive: syntax error with c++0x code) 2011-04-14 19:50:17 -04:00
Robert Reif 75e5353b6d fix #2718 (Analysis failed. If the code is valid then please report this failure.) 2011-04-13 23:58:58 -04:00
Robert Reif 257197bdd1 fix #2717 (false positive: syntax error (typedef void f(int) const;)) 2011-04-13 23:24:41 -04:00
Robert Reif 50a1f28d86 run astyle 2011-04-13 21:12:35 -04:00
Daniel Marjamäki 11bd6bcd30 Fixed #2712 (false positive: Division by zero) 2011-04-10 21:27:09 +02:00
Daniel Marjamäki 447f61e9c7 Refactoring: Use %op% 2011-04-09 18:30:47 +02:00
Daniel Marjamäki f6d910ab3d Refactoring: Use Token::isOp 2011-04-09 15:54:36 +02:00
Daniel Marjamäki ea57e10c7f Tokenizer::simplifyCalculations: simplify division result if it's a whole number, even though it doesn't have precedence 2011-04-02 12:52:11 +02:00
Daniel Marjamäki f34e9e6623 Tokenizer: better simplification of calculations in conditions 2011-04-02 11:08:58 +02:00
Stefan Weil 675e63b6a7 Spell checks 2011-03-30 16:45:31 +02:00
Robert Reif fc258164cd fix #2675 (false positive: syntax error) 2011-03-24 22:26:42 -04:00
Robert Reif 7b63da4964 fix #2651 (Segmentation fault (typedef)) 2011-03-17 20:00:49 -04:00
Daniel Marjamäki dab09aedee Fixed #2648 (Tokenizer::simplifyTemplates: Segmentation fault (gcc-testsuite)) 2011-03-17 21:45:03 +01:00
Daniel Marjamäki fec9edf628 Tokenizer::simplifyTemplates: First simple fix for problems when using sizeof in template parameter 2011-03-16 22:16:30 +01:00
Robert Reif f7cbc90c84 fix #2581 (### Internal error in Cppcheck. Please report it.) 2011-03-15 23:28:45 -04:00