Commit Graph

574 Commits

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