Philipp K
69498de6ca
- Refactorizations in preprocessor.cpp and tokenizer.cpp
...
- Bugfix: tok->stringify(tok) returns now "".
- Removed most of the inline-asm handling in preprocessor; improved the remaining handling of #asm/#endasm: Simplified to "asm(...);" statement
2012-01-02 03:15:02 -08:00
Edoardo Prezioso
b24e6e659e
C# simplification: remove 'using var;' code from the tokenizer.
2012-01-02 00:53:20 +01:00
Edoardo Prezioso
eb657034ba
Handle also C# multidimensional arrays with no specified dimension.
2012-01-02 00:22:45 +01:00
Reijo Tomperi
aa927d5aa3
Refactoring: Add new file lib/templatesimplifier.cpp
...
The plan is to move template simplification into this new class to take some lines from 10 000 line tokenizer.
2012-01-01 22:55:05 +02:00
PKEuS
f4703e026a
Refactoring various issues in cmdlineparser, cppcheckexecutor, check64bit and tokenize.
2012-01-01 21:17:16 +02: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
b9c796d9f8
- Re-elaborate 'using' keyword skipping in Tokenizer::setVarId and
...
Scope::getVariableList;
- Improve setVarId: add possible declaration: 'A f(&x);' and change from:
'if (...){}else{ continue; };' to: 'if (!...) continue;';
- Little refactoring of 'Tokenizer::removeTokens()'.
2011-12-31 21:36:19 +01:00
Daniel Marjamäki
8a6b1dc1c9
Fixed #3449 (segmentation fault of cppcheck)
2011-12-31 12:08:49 +01:00
Edoardo Prezioso
0d3bf5340d
Improve varId and getVariableList filter, related to previous commit.
2011-12-30 18:13:42 +01:00
Edoardo Prezioso
873572d489
Improve C# simplification code with arrays of arrays.
2011-12-30 12:26:28 +01:00
Edoardo Prezioso
d0a3560c92
Rewrite Tokenizer::hasEnumsWithTypedef by using 'findmatch' in order to shorten the code.
2011-12-30 11:38:18 +01:00
Reijo Tomperi
90e1a397a2
Refactoring: Remove duplicate function from tokenizer: code_is_c() -> isC()
2011-12-29 00:36:16 +02:00
Reijo Tomperi
614c90b156
astyle fix
2011-12-28 23:57:54 +02:00
Edoardo Prezioso
09bfa66536
Always by pressing request, oops.
2011-12-28 22:51:13 +01:00
Edoardo Prezioso
ec0badb651
By pressing request, extract method: simplifyJavaAndCSharp.
2011-12-28 22:44:53 +01:00
Edoardo Prezioso
f9dd927ff4
Move non-C++ simplification outside big loop.
...
Related to commit b2f8161862
.
2011-12-28 22:12:54 +01:00
Reijo Tomperi
0a588496a0
Fix astyle and test failures.
2011-12-28 22:05:10 +02:00
Edoardo Prezioso
b2f8161862
Rewrite fix of ticket #3415 (Segmentation fault in new check for uninitialized variables):
...
new simplify: 'code ; ({ some_code ; });' to 'code ; some_code ;';
remove the sanity check in checkunusedvar, so when it crashes again it's easy to spot a bigger problem;
'internal' reported 'Token::Match' with simple pattern.
'Tokenizer::tokenize()' refactorings:
make one loop with many simple simplifications instead of many loops with one simplification.
some style changes.
2011-12-28 16:55:59 +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
Jonathan Neuschäfer
7a5627029f
tokenizer: proper checks for Java and C#
2011-12-27 18:01:39 +01:00
Daniel Marjamäki
91874214d8
Refactoring: Added utility function that determine if scope ends with a call to a noreturn function
2011-12-27 18:00:12 +01:00
Daniel Marjamäki
987392f254
Tokenizer: Better handling of array of function pointers
2011-12-27 11:56:40 +01:00
Daniel Marjamäki
9593e14d72
Removed debug variables
2011-12-27 09:27:46 +01:00
Edoardo Prezioso
293437bdfc
Fixed ticket #3416 (segmentation fault of cppcheck)
2011-12-26 03:21:23 +01:00
Reijo Tomperi
e112bfdd47
Refactoring: Rename some variables and funtions in tokenizer.
...
Small logic change also for count variable to make new name more logical.
2011-12-26 00:06:27 +02:00
Reijo Tomperi
347982a347
Refactoring: Extract several methods from tokenize()
2011-12-24 23:23:08 +02:00
Reijo Tomperi
8e6ebd4a22
Refactoring: Extract method: simplifyDoublePlusAndDoubleMinus()
2011-12-24 22:51:55 +02:00
Reijo Tomperi
6155932207
Refactoring: Rename some variables with too short names, such as "s".
2011-12-24 00:25:03 +02:00
Reijo Tomperi
00cbf02d84
Refactoring: Rename variable used -> templateInstantiations
2011-12-24 00:03:03 +02:00
Reijo Tomperi
70c4bb54b4
Refactoring: Split long function in tokenizer.
...
simplifyTemplatesInstantiate()
2011-12-22 23:13:45 +02:00
Reijo Tomperi
1c12d04d0d
Refactoring: Make a 300 line function a little smaller.
...
simplifyTemplatesInstantiate()
2011-12-22 22:39:15 +02: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
Daniel Marjamäki
6a4b1127aa
astyle formatting
2011-12-14 17:07:06 +01:00
Edoardo Prezioso
40aa326065
Tokenizer: remove redundant 'done' condition, related to ticket #3409 .
...
Add more possible letters to simplifyInitVar patterns.
Replace 'tokAt(1)' with 'next()' and 'linkAt(1)' with 'next()->link()'.
Little optimizing improvements to simplifyAsm.
2011-12-13 22:41:38 +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
81a2e62abd
Tokenizer::simplifyGoto: fix another memory read error reported by Valgrind.
...
Also improvements to Tokenizer are done.
2011-12-12 22:03:25 +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
626f13ae7e
Tokenizer: Fix another Valgrind error in simplifyErrNoInWhile. Add more jumping patterns to simplifyIfAddBraces and simplifyDoWhileAddBraces.
2011-12-12 13:15:35 +01:00
Edoardo Prezioso
99d8ce3732
Fix Valgrind error in arraySize():
...
if there's code like: 'int [ ] a = { 1 , 5 , }', 'end' is last '}', when 'tok2' arrives to second ',' and cppcheck finds out that next token to 'tok2' is '}', remove this ',' with 'tok2->deleteThis()' but it causes (maybe) a memory corruption to 'end' which will gave problems later because 'tok' will be assigned to it or its next token.
2011-12-12 02:23:49 +01:00
Edoardo Prezioso
52620e6493
Tokenizer::simplifyDoWhileAddBraces:
...
1)rewrite fix for ticket #988 (just don't simplify inside macro parenthesis);
2)use a different organization of the code: start from last token and proceed backwards. This way 'simplifyDoWhileAddBracesHelper' can be called just once, hence the 'Helper' code can be improved and moved in the main function.
2011-12-12 00:20:46 +01:00
Edoardo Prezioso
cf574072b6
Tokenizer::arraySize(): improve code structure, fixed 'tok2' for-looping which didn't stop to the ending '}' parenthesis.
2011-12-11 23:13:37 +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
Edoardo Prezioso
bf815ac1e4
Improve labels simplification code, remove redundant checking.
2011-12-10 14:13:48 +01:00
Daniel Marjamäki
c2e86b867c
Fixed #3386 (Syntax Error: 'int a[]={b<c?1:2,3};')
2011-12-10 11:34:27 +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
Daniel Marjamäki
8ca8887849
C++ Builder : Fixed compiler error
2011-12-08 22:24:09 +01:00
PKEuS
167a7e3e51
Various code cleanups
2011-12-08 21:28:34 +01:00
PKEuS
1bef8d1247
Tokenizer: Code cleanups
2011-12-08 17:42:26 +01:00
Edoardo Prezioso
149ff355e2
Add more kind of code to process for 'removeExceptionSpecifications' (unions, anonymous unions and structs).
2011-12-08 02:50:05 +01:00
Edoardo Prezioso
4de5d87078
1)Remove newly copy of 'eraseTokens' and replace every occurrence with 'deleteNext' with right parameter.
...
2)General improvements to code.
2011-12-08 01:44:18 +01:00
PKEuS
1c1c31bea0
Tokenizer: Refactorings and improvements. Better handling of []
2011-12-07 21:15:00 +01:00
Edoardo Prezioso
612b3c59ca
1)Implement another declaration of 'Token::eraseTokens' with parameters: the starting token and the number of times needed to call 'deleteNext'.
...
2)Use the overloaded 'eraseTokens' where needed instead of using consecutively 'deleteNext'.
3)Tokenizer: general optimizations about the deletion of some tokens.
4)Run astyle.
2011-12-07 02:29:03 +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
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
1b4b8fbefe
Tokenizer: use more 'deleteNext' instead of 'eraseTokens' where possible.
2011-12-05 18:52:34 +01:00
Edoardo Prezioso
186ab3645e
Oops. I should eventually keep ';', not 'typedef'.
2011-12-05 00:26:08 +01:00
Edoardo Prezioso
65213772df
Tokenizer: use 'deleteNext()' or, even better, 'eraseTokens' instead of 'deleteThis()' where possible.
2011-12-05 00:08:50 +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
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
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
Thomas Jarosch
fcb6759f43
The usual astyle run
2011-12-03 17:01:56 +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
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
Edoardo Prezioso
767413adad
1)internal check found a 'findmatch' with simple string argument;
...
2)Style: uniform 'while (...)' when inside it there's an assignment;
3)Replace '0' with 'NULL' where there's comparison with a pointer.
2011-12-01 12:04:47 +01:00
Edoardo Prezioso
1084e4bece
1) Shut up GCC compiler for 'missing braces around assignment';
...
2) Tokenizer::simplifyGoto: Code refactoring in order to skip code inside '()|[]' parentheses without counting.
2011-11-30 20:58:39 +01:00
PKEuS
6b6f780057
code cleanups and refactorings
2011-11-26 21:02:04 +01:00
Marek Zmysłowski
3ae96600b5
Fixed #3212 (Simplify the double pointer cast)
2011-11-25 07:23:54 +01:00
Thomas Jarosch
5025d1019f
Use Token::simpleMatch instead of Token::Match
...
"--enable=internal" reported:
[lib/tokenize.cpp:3563]: (warning) Found simple pattern inside Token::Match() call: ") ;"
2011-11-24 10:11:45 +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
Edoardo Prezioso
6889a28d31
1) Run runastyle;
...
2) Clarify some comments in 'Tokenizer::simplifyFlowControl' and in 'Tokenizer::eraseDeadCode';
3) Add some 'const' variables inside 'Tokenizer::eraseDeadCode'.
2011-11-20 19:06:55 +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
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
Thomas Jarosch
c317c8979c
Run astyle
2011-11-14 09:21:42 +01:00
Edoardo Prezioso
2c64d299ca
Change every 'tokAt(...)->str()' to 'strAt(...)'.
2011-11-13 13:10:59 +01:00
Edoardo Prezioso
b28a44dc3b
Change: 'next()->next()'->'tokAt(2)', 'previous()->previous()'->'tokAt(-2)'.
2011-11-12 22:33:03 +01:00
Edoardo Prezioso
ed6a0e14c4
Add simplification of the consecutive braces before the end of 'tokenize()' function.
2011-11-12 16:59:20 +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
5a35beebf7
added todo comment
2011-11-11 11:07:03 +01:00