Commit Graph

879 Commits

Author SHA1 Message Date
Simon Martin 2d8993319c Ticket #6810: Avoid infinite loop upon invalid typed enum declaration. 2015-07-15 21:39:15 +02:00
Alexander Mai f806d945a1 Refactoring: Allow TemplateSimplifier to throw InternalErrors by itself. 2015-06-23 20:53:57 +02:00
Daniel Marjamäki 75b0430ba5 Token::strValue: fixed handling of backslash 2015-06-07 11:25:33 +02:00
Simon Martin 50e5595845 Ticket #6708: Check that a function name is not a reserved keyword in SymbolDatabase::isFunction instead of later. 2015-05-26 00:28:08 +02:00
Simon Martin 67eab0cd7c Ticket #6620, #6685: Reserved keywords cannot be function names. 2015-05-23 11:29:58 +02:00
PKEuS 1b6e4589da Implemented array size calculation for n-dimensional arrays with arbitrary dereferencing (#6657) 2015-05-11 17:30:11 +02:00
PKEuS 708a379fd2 Refactorized simplification of sizeof without parantheses:
- Moved sizeofAddParentheses() behind combineOperators()
- Improved sizeofAddParentheses() to handle all code from unit tests at simplifyTokenList1()
- Removed simplification from simplifyTokenList2()
2015-04-13 20:18:21 +02:00
PKEuS 4c40664861 Fixed #6639: Calculate sizeof() of multidimensional arrays 2015-04-13 20:18:21 +02:00
PKEuS 72b4809da0 Moved simplification of operator names before template and parentheses simplifications (#6576) 2015-04-01 13:47:36 +02:00
Dmitry-Me 712b101862 Test simplification of "delete a, b, c" 2015-03-27 17:49:35 +03:00
Dmitry-Me e8f0abf259 Proper simplify delete a,b 2015-03-25 16:54:23 +03:00
Dmitry-Me 9a1b543c07 Tokenizer: Add testcase for 'delete a, a=0;' 2015-03-24 07:59:17 +01:00
PKEuS 42673255ed Refactorized testrunner: Create std::string only where necessary 2015-03-15 12:36:40 +01:00
PKEuS bc5132e0ac Refactorization: Moved declaration of errout, ... to testsuite.h, uniformized style 2015-03-11 22:54:43 +01:00
Daniel Marjamäki d4fa656e58 Refactor and improve Tokenizer::sizeofAddParentheses 2015-02-22 13:38:06 +01:00
orbitcowboy 84e831c21c posix.cfg: Improved support for functions from <unistd.h>. 2015-02-02 17:23:43 +01:00
Dmitry-Me 21fbc30d59 Calling a function using Class::func() syntax should not be simplified 2015-02-02 10:37:10 +03:00
PKEuS 21cb0cfd60 Take simplifyIfNotNull and simplifyIfNot out of simplifyTokenList1 (first step for #6072) 2015-01-31 20:12:02 +01:00
PKEuS 1f97e3001b Fixed calculation of array size (#6487) 2015-01-31 19:06:44 +01:00
PKEuS b2835051df Refactorization: Renamed Token::Match pattern %var% to %name%, implement new pattern %var% which is true if varId > 0. 2015-01-31 12:32:04 +01:00
Daniel Marjamäki 57ec1aea91 Library: Don't rely on ast in isNotLibraryFunction since it's used in tokenizer 2015-01-31 10:24:10 +01:00
Daniel Marjamäki d1927e3492 Removed Tokenizer::simplifyStructInit simplification. 2015-01-04 16:48:52 +01:00
Daniel Marjamäki 7bafbfbd6e Tokenizer: cleanup simplification of '!= 0' to avoid FP in 'x[(y & 0x80) != 0]' (linux) 2015-01-04 13:50:54 +01:00
Daniel Marjamäki eb1c048d2a Tokenizer: Fix wrong simplification when checking linux kernel 2015-01-03 21:35:03 +01:00
Daniel Marjamäki ff11ba9847 Updated copyright year to 2015 2015-01-03 12:14:58 +01:00
Daniel Marjamäki e3892a95b5 Fixed #6290 (Tokenizer: Because 'and' is not simplified to '&&' there are false positives) 2014-12-03 16:32:05 +01:00
Daniel Marjamäki 051d42ae6b astyle formatting 2014-11-20 14:20:09 +01:00
orbitcowboy f5d804f71a running astyle 2014-11-20 10:13:03 +01:00
Daniel Marjamäki ea765c24f2 Fixed #3262 (Tokenizer: wrong 'return a=1,b=2,...;' simplification;) 2014-11-10 17:31:19 +01:00
Simon Martin c6e2107d99 Ticket #6187: Avoid infinite loop if eraseDeadCode does not remove anything (this time without memory corruption). 2014-10-22 20:25:36 +02:00
Robert Reif e2f72b4cb1 Fixed #6215 (Move Windows platform types into library) 2014-10-19 07:34:40 +02:00
PKEuS eefaddf980 Fixed bug in Tokenizer::simplifyReference() (#6133) 2014-10-16 11:43:42 +02:00
Daniel Marjamäki ecd17d84fb Reverted f088588c fix for #6187 that fixes infinite loop, the fix cause a use-after-free regression. 2014-10-16 06:32:06 +02:00
Daniel Marjamäki d0d2a0faf8 simplifyCalculations: Fix simplification of '( %num% )' when parentheses must be kept 2014-10-10 13:19:25 +02:00
Simon Martin f088588c88 Ticket #6187: Avoid infinite loop if eraseDeadCode does not remove anything (invalid goto into a dead loop's body). 2014-09-30 19:43:22 +02:00
PKEuS de13ad7eca Improved simplifications of redundant loops:
- Execute simplifyWhile0 after simplifyKnownVariables (#394)
- Support declaration of variable in loop header in removeRedundantFor
2014-09-26 10:47:05 +02:00
PKEuS 3cf6c19a4b Avoid loading the same .cfg file 30 times in testsimplifytokens.cpp 2014-09-24 13:26:52 +02:00
PKEuS affd0ffdfd Splitted large groups of tests out of testsimplifytokens.cpp and testtokenize.cpp 2014-09-24 13:23:44 +02:00
Daniel Marjamäki dc9b1f09ae astyle formatting
[ci skip]
2014-09-23 16:04:38 +02:00
Daniel Marjamäki f93cf9d1b7 Fixed #6170 (Tokenizer: sizeof on array in 2d-array is not handled properly) 2014-09-16 17:21:17 +02:00
Simon Martin 01cf008792 Ticket #6134: Improve the mechanism differentiating template declarations from template definitions. 2014-09-13 16:44:05 +02:00
PKEuS 4859b55ce6 Merge pull request #422 from simartin/ticket_6023
Ticket #6023: Properly handle template'd default template parameter values
2014-09-06 22:55:45 +02:00
Simon Martin 6e10603227 Ticket #6023: Properly handle template'd default template parameter values. 2014-09-06 20:39:04 +02:00
PKEuS 35b00a5e05 Support rValue references in typedef (#1823) 2014-09-06 19:00:26 +02:00
PKEuS 3e65cb446e Remove "auto" keyword (storage class specifier) from C++03 and C code (#4990). 2014-09-02 11:21:47 +02:00
PKEuS 630211ac7d Added unit test for #4777 2014-08-26 15:30:12 +02:00
PKEuS 6a4319f050 Improved simplifications:
- Rearranged their order to solve problems with typedefs. If we simplify chained declarations before typedef parsing, we have less complex expressions to deal with (#4777).
- Fixed detection of variables hiding enums
2014-08-26 15:21:19 +02:00
PKEuS 399e8e551e Fixed cppcheck internal warnings 2014-08-23 12:47:16 +02:00
PKEuS 7f2be2f57c Fixed template bracket linkage in while loop simplification
Ran AStyle
2014-08-23 12:28:54 +02:00
PKEuS 83a80cebeb Fixed order of simplifications (#6029) 2014-08-06 08:39:23 +02:00
Daniel Marjamäki a943a0739a Tokenizer: Don't remove struct member in Tokenizer::simplifyKeyword() 2014-08-01 17:19:08 +02:00
Daniel Marjamäki 54aede9086 Fixed #5941 (ValueFlow: Wrong value in subfunction under ?) 2014-06-24 19:30:46 +02:00
Daniel Marjamäki a4a6f3e1be Tokenizer: Removed Tokenizer::simplifyConditionOperator(). Using the AST and ValueFlow, it should be much easier to parse ?: than before. 2014-06-10 19:30:13 +02:00
PKEuS 51f381edf3 Fixed VS warnings 2014-06-04 18:55:29 +02:00
PKEuS 26e09ae4a4 Fixes for test suite, added a TODO unit test about bad typedef simplification 2014-06-04 18:46:11 +02:00
PKEuS 8db0790407 Tokenizer::tokenize() can now be called without AST being created 2014-06-04 18:45:28 +02:00
Daniel Marjamäki ed78d3e148 Library: Better error reporting when loading fails 2014-05-26 17:00:41 +02:00
Simon Martin fcff8d39d9 Ticket #5816: Properly handle template'd template parameters in enum initializers. 2014-05-23 21:25:42 +02:00
Simon Martin 69d294c6c4 Ticket #5816: Skip typename in template arguments for enum initializers. 2014-05-17 08:50:12 +02:00
Simon Martin 92cc17110d Ticket #5814: Handle A::B as template parameter for enum initializers. 2014-05-15 21:52:57 +02:00
Simon Martin 1e4902cb65 Ticket #5297: simplifyCalculations should pass once more on tokens being simplified. 2014-05-10 09:37:56 +02:00
Simon Martin 2a6acdf357 Ticket #5605: Don't consider '>' as a default template parameter value. Don't choke on template parameters with erroneous default values.
Ticket #5759: Properly handle pointers to class members in template parameter lists.
Ticket #5762: Handle template specialization tokens.
2014-05-08 13:54:56 +02:00
Daniel Marjamäki 6e25280c90 Reverted fix for #5605 since it cause this crash: #5759 2014-05-05 21:11:47 +02:00
Simon Martin ffe6a0be2b Ticket #5605: Don't consider '>' as a default template parameter value. Don't choke on template parameters with erroneous default values. 2014-05-03 16:26:14 +02:00
Daniel Marjamäki 9c74d914d7 Fixed #5667 (Tokenizer: simplify 'void (X::*f)()' to 'void *f') 2014-04-27 19:49:21 +02:00
Daniel Marjamäki aea528c763 enum: don't simplify enum constant that is assigned 2014-04-23 17:10:17 +02:00
Daniel Marjamäki 52e0e4453b Fixed #5646 (FP: pointer to array is not assigned a value.) 2014-04-21 16:14:49 +02:00
Daniel Marjamäki 6146c8f5bb Tokenizer: Fixed bad simplifyComma for code 'return a ? b = c , d : e ;' 2014-04-18 13:38:48 +02:00
Daniel Marjamäki 064844f8db Tokenizer: Fixed bad simplifyComma for code 'a ? b = c , d : e ;' 2014-04-17 18:47:55 +02:00
Daniel Marjamäki 9d51bfd015 Fixed #5397 (False positive: Same expression on both sides of '&') 2014-04-12 16:06:31 +02:00
PKEuS d4765bccc3 Refactorized inefficient usage of std::string and const char[] (part 2). 2014-04-03 14:56:14 +02:00
PKEuS e9411e05ba Refactorized inefficient usage of std::string and const char[]. 2014-04-02 13:56:34 +02:00
PKEuS efe3f834be Refactorized handling of syntaxError: Print debug output, removed a few return values that are no longer required 2014-03-27 18:41:52 +01:00
PKEuS 7e4081f7f5 Treat syntaxError and cppcheckError as InternalErrors (throw as exception, #4268) 2014-03-27 13:15:21 +01:00
PKEuS 379807a8ea Fixed TODO_ASSERT_EQUAL and #5614 caused by bad simplification of return values. 2014-03-27 11:04:31 +01:00
PKEuS 5f2067e401 Refactorized dead code elimination:
- Use library to get noreturn functions
- Fixed do-while simplification (#4940)
2014-03-23 10:59:41 +01:00
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