Commit Graph

642 Commits

Author SHA1 Message Date
Daniel Marjamäki 823fc9ac04 Fixed #3650 (Variable declaration: Doesn't handle template usage well) 2012-04-05 08:53:10 +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
Edoardo Prezioso af02908d42 Fixed ticket #3580 (syntax error in multi variable declaration header). 2012-03-31 18:45:29 +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 002389f836 Fixed #3677
Added forgotten testcase for #3672
2012-03-21 18:40:32 +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
Daniel Marjamäki 555e8c6efc Fixed #36221 (Input streams: Wrong token list simplification) 2012-03-15 19:09:36 +01:00
Daniel Marjamäki a9d56f2738 Tokenizer: simplify known variable value inside conditional block 2012-03-12 17:32:30 +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
Daniel Marjamäki 527d3791e6 Fixed #3596 (memory leak false positive on libedit sources) 2012-02-27 18:55:36 +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 a118f82ca7 Tokenizer::simplifyVarDecl: Don't simplify inside parenhteses 2012-02-18 15:05:29 +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 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
Daniel Marjamäki da8abeb63c Fixed #3584 (2 internal errors : Token::Match called with varid 0) 2012-02-12 17:30:47 +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 2be85e9d37 Fixed #3538 (false positive caused by bad tokenizer simplification) 2012-02-01 21:13:26 +01:00
Edoardo Prezioso 66e1761ffe Fixed ticket #3571 (segmentation fault of cppcheck while scanning gcc-testsuite). 2012-01-31 18:42:19 +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
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 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 7cf8e5dfff TestTokenizer: moved test to proper place. 2012-01-26 22:25:19 +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
Daniel Marjamäki 9eb1a5864b Fixed #3502 (segmentation fault of cppcheck (struct{x y:};)) 2012-01-23 07:39:31 +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
seb777 0be8af5214 Fix ticket #3530 (Add some windows data types to tokenizer) 2012-01-18 12:57:41 +01:00
Edoardo Prezioso c5f7db0645 TestTokenizer: Remove redundant ';' in 'inlineasm' testcases. 2012-01-15 19:49:17 +01:00
Edoardo Prezioso 4d239d0bf7 Run astyle. 2012-01-15 19:47:51 +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
Daniel Marjamäki a6d96f5b72 Fixed #3496 (false positive: syntax error) 2012-01-15 14:33:53 +01:00
Edoardo Prezioso 6a248c35b5 Fixed ticket #3512 (segmentation fault of cppcheck ( 1 *p = const)) 2012-01-14 00:43:58 +01:00
Daniel Marjamäki 0648b3ed5e Fixed #3504 (segmentation fault of cppcheck) 2012-01-13 07:57:12 +01:00
Edoardo Prezioso 2dd53ec966 Fixed ticket #3485 (segmentation fault of cppcheck ( {a:1;}; )) 2012-01-09 16:24:11 +01:00
Edoardo Prezioso 54f54761b4 Fixed ticket #3482 (segmentation fault of cppcheck ( switch(){case} )) 2012-01-09 14:37:20 +01:00
Edoardo Prezioso 75fbe310ff Extract various functions inside the Tokenizer class and fix tokenization of 'return __LINE__ ;'. 2012-01-04 12:57:58 +01:00
Daniel Marjamäki e4f3f91c18 Reverted 9aa8a496. I don't know why I made this fix. 2012-01-02 19:45:20 +01:00
Edoardo Prezioso 38ee7523ad Remove redundant testcase I forgot to remove in previous commit. 2012-01-02 19:41:08 +01:00
Edoardo Prezioso eb657034ba Handle also C# multidimensional arrays with no specified dimension. 2012-01-02 00:22:45 +01:00
Reijo Tomperi 8cae17fda8 Update year to 2012 2012-01-01 01:05:37 +02:00
Edoardo Prezioso 38e0e25ce0 Fixed ticket #3448 (segmentation fault of cppcheck).
Add testcase related to previous commit (add 'A f(&x);' as declaration of variable).
2011-12-31 21:44:07 +01:00
Edoardo Prezioso 8f2ad53332 Add testcase for previous commit. 2011-12-30 18:47:42 +01:00
Edoardo Prezioso 873572d489 Improve C# simplification code with arrays of arrays. 2011-12-30 12:26:28 +01:00
Reijo Tomperi 1afd923d34 Fix bug in C# detection code. The test had a bug also, so it was not detected by the test. 2011-12-27 22:50:56 +02:00
Daniel Marjamäki 987392f254 Tokenizer: Better handling of array of function pointers 2011-12-27 11:56:40 +01:00
PKEuS 46c2bde118 Activate tests in TestTokenizer 2011-12-18 17:54:24 +01:00
Daniel Marjamäki 2bb5de4c89 Fixed #3425 (False positive: Null pointer dereference (pointer is checked in macro)) 2011-12-18 13:33:23 +01:00
Daniel Marjamäki 83cdf734fe Tokenizer: The tokenizer didn't handle '0x0E-7' correctly 2011-12-18 07:37:20 +01:00
Daniel Marjamäki d21ca7881c Fixed #3424 (Tokenizer: doesn't tokenize if-if-else-else correctly) 2011-12-17 19:05:14 +01:00
PKEuS c9f5117cf5 Fixed #3407 (False positive: (inconclusive) Found duplicate branches for if and else. (inline assembler)) 2011-12-13 21:42:38 +01:00
Edoardo Prezioso 79b82f115f Tokenizer: some changes to line numbers of some tokens:
simplifyAsm: change line number of newly added 'asm ( )' in order to be the same as next ';'.
simplifyIfAddBraces: Change line number of newly added '}' in order to be the same as next 'else', except for '{ ; } else'.
2011-12-12 20:55:25 +01:00
Edoardo Prezioso 6506b2c016 Oops. Fix testrunner fail. 2011-12-11 20:36:56 +01:00
Edoardo Prezioso 3c098839d1 simplifyIfAddBraces: Remove restriction for jumping opening parenthesis '(' as a fix to #2873, because even without this the original test case doesn't crash anymore. Add more jumping patterns.
simplifyFunctionParameters: Add more jumping patterns and an observation related to error message for equal parameter names, help needed.
Fix grammar mistake in comment.
2011-12-11 13:07:13 +01:00
Edoardo Prezioso 27801b35eb Other improvements to tokenizer code.
Handle SQL code better, even when there's no ';' after 'EXEC SQL'.
simplifyVarDecl: Check with 'Token::Match' once when you have to check a pattern inside which there should be a number or a variable. Use '%any%' and after that check if that string is a number or a variable name later.
simplifyGoto: process also anonymous structs and unions which should have 'indentspecial' incremented, skip code like 'var = { ... }'.
2011-12-11 02:02:38 +01:00
Edoardo Prezioso 5134964026 Fix code in commit 5f522fb841 and reapply it again. 2011-12-10 23:49:56 +01:00
Daniel Marjamäki 04159b81b8 reverted 5f522fb841, to avoid hang in TestBufferOverrun::arrayInfo 2011-12-10 20:51:36 +01:00
Edoardo Prezioso 5f522fb841 Tokenizer: improve code and remove redundant checks.
In particular: improve 'double sharp' concatenation by handling also code which begins without the [{};]. Do the same with C# code. Also, in the labels simplification function, skip also '{}' when the open bracket is after a '='.
2011-12-10 18:45:27 +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 167a7e3e51 Various code cleanups 2011-12-08 21:28:34 +01:00
PKEuS 1c1c31bea0 Tokenizer: Refactorings and improvements. Better handling of [] 2011-12-07 21:15:00 +01:00
Edoardo Prezioso eb5fe250ab Partial fix ticket #3385 ('throw' isn't removed if the argument of the function is type 'struct|class'). 2011-12-06 21:02:26 +01:00
Edoardo Prezioso 0504952950 Remove some redundant parenthesis - part 9 2011-12-06 16:53:57 +01:00
Edoardo Prezioso b45d63a10a Remove some redundant semicolons - part 5 2011-12-04 17:15:53 +01:00
Edoardo Prezioso 2fc067e6ab Tokenizer::simplifyConst : handle also '%type% const' when the 'type' token is the first one in the list. 2011-12-04 16:59:19 +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 eeb6dc48a5 Fixed #3359 (False positive: array[idx++] += val triggers unexpected 'Array index out of bounds' error) 2011-12-04 12:22:21 +01:00
Edoardo Prezioso 42a557432d Remove some redundant semicolons - part 3 2011-12-02 23:04:06 +01:00
Edoardo Prezioso c2ddb67316 Remove some redundant semicolons - part 2 2011-12-02 22:58:29 +01:00
Edoardo Prezioso ff1cb241a8 Remove some redundant semicolons - part 1 2011-12-02 22:39:33 +01:00
Marek Zmysłowski 3ae96600b5 Fixed #3212 (Simplify the double pointer cast) 2011-11-25 07:23:54 +01:00
Daniel Marjamäki 17f891ad34 Tokenizer::setVarId: Fixed problem with class declarations with inheritance. skip them. 2011-11-21 21:18:56 +01:00
Daniel Marjamäki 9aa8a49677 Tokenizer::setVarId: fixed 'using' bug 2011-11-21 18:04:42 +01:00
Daniel Marjamäki 004dcf834b Fixed #3281 (Tokenizer::simplifyKnownVariables : static constant value is not used) 2011-11-20 21:50:26 +01:00
Daniel Marjamäki b26811cdf5 astyle formatting 2011-11-20 16:50:41 +01:00
Daniel Marjamäki 097637a66c Fixed #3316 (Cppcheck reporting internal errors - code compiles cleanly) 2011-11-20 16:22:21 +01:00
Edoardo Prezioso 42e369a4b4 Change every 'tokAt(..)->link()' to 'linkAt(..)'. 2011-11-20 14:24:27 +01:00
Daniel Marjamäki 1cf45a5cde Fixed #3280 (False positive: assigned value that is never used) 2011-11-20 12:09:07 +01:00
Daniel Marjamäki 8c091ff968 Fixed #3340 (Internal error. Token::Match called with varid 0... union is causing problems) 2011-11-20 08:13:28 +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
Daniel Marjamäki 34e40502c6 Fixed #3314 (cppcheck incorrectly reporting Syntax error.) 2011-11-11 10:53:49 +01:00
Reijo Tomperi ca70693055 Astyle fix 2011-11-10 22:32:37 +02:00
Richard Quirk f56aa19fac Fix varid 0 with function pointer and virtual methods 2011-11-09 21:07:55 +01:00
Daniel Marjamäki 2d00cabee1 Fixed #3279 (Token::Match called with varid 0) 2011-11-09 18:49:17 +01:00
Edoardo Prezioso 392f705b73 Oops. 2011-11-08 23:10:53 +01:00
Edoardo Prezioso 0569953753 Fixed ticket #3309 (false positive: (style) Boolean result is used in bitwise operation. Clarify expression with parentheses) 2011-11-08 22:48:14 +01:00
Edoardo Prezioso 3cc9a333c9 Fixed tokenizer: don't change '*(str+num)' if '*' means a product with a previous variable or number.
Ditto for '&str[num]' (still commented).
2011-11-08 18:14:43 +01:00
Edoardo Prezioso aaa77c4709 Improve tokenizer: remove more redundant parenthesis and add a prototype code for: '&str[num]'=>'(str+num)' with reporting non obvious test failures. 2011-11-07 23:40:06 +01:00
Edoardo Prezioso 6e2f2816de Improve same expression check: remove '%op%' pattern and add ',' for the same expressions as an argument inside a function.
Improve compound assignment simplification: use already defined 'isAssignmentOp' and extend the adding parenthesis to a generic operator, not only to the arithmetical ones. See: http://en.cppreference.com/w/cpp/language/operator_precedence
2011-11-06 14:35:53 +01:00
Daniel Marjamaki b96ab6ba26 Fixed #3188 (Function parser false positive) 2011-11-05 12:23:05 +01:00
Daniel Marjamäki 085a6285fa Fixed #3117 (Tokenizer::simplifyKnownVariables : Don't simplify static variable that is changed) 2011-11-05 08:30:11 +01:00
Daniel Marjamaki b6b5416b42 Tokenizer: Fixed failed unit test 2011-11-02 20:42:38 +01:00
Daniel Marjamaki 0884204c2f Fixed #3279 (Token::Match called with varid 0) 2011-11-02 18:31:13 +01:00