Edoardo Prezioso
42fd4e2f52
Tokenizer: Change 'var++|--;' into '++|--var;' and remove redundant 'tokAt(0)'.
2011-10-29 22:25:49 +02:00
Daniel Marjamäki
92333b585a
Fixed #3092 (Tokenizer::setVarId : shadow variable in member function gets the wrong varid)
2011-10-29 21:25:58 +02:00
Daniel Marjamäki
a809bb3471
astyle formatting
2011-10-29 19:51:11 +02:00
Daniel Marjamäki
acaa9c456f
Fixed #3152 (Tokenizer: template constructor is removed)
2011-10-29 19:45:47 +02:00
Daniel Marjamäki
8f49eb6a7e
Tokenizer: Make sure that friend classes don't get varid. Ticket: #2962
2011-10-29 18:22:58 +02:00
Edoardo Prezioso
5d868766c7
Tokenizer time improvements (time says real: -1 second)
...
1)change tokAt(1|-1) with next()|previous() with conditions where necessary;
2)change strAt(1|-1) with next()|previous()->str() with conditions where necessary;
3)change tokAt(n)->str(), with n != -1,1, to strat(n);
4)change simplifyFuncInWhile implementation because it was too slow and stupid.
2011-10-29 01:57:53 +02:00
Edoardo Prezioso
dd719b41bf
Definitely check correctly 'sizeof %num%' when '%num%' has '-' sign.
2011-10-29 00:11:38 +02:00
Thomas Jarosch
ef8f49bbf3
Use new findsimplematch API for simple patterns
2011-10-28 12:49:03 +02:00
Edoardo Prezioso
bab740289c
Complete todo: convert 'for' into 'while'.
...
It's not possible to enable this code because of the disaster it will be created for all the checks with the 'for' pattern.
2011-10-28 00:50:54 +02:00
PKEuS
49fd057e17
Tokenizer: Simplify 'foo(void)' to 'foo()'
2011-10-27 19:56:59 +02:00
Thomas Jarosch
22251d50bb
Bugfix: Use Token::Match instead of Token::simpleMatch because it's a complex pattern
...
This bug was in here before my recent refactoring.
(And yes, I wrote a check for cppcheck's Token::Match invocation ;))
2011-10-27 16:43:04 +02:00
Thomas Jarosch
434fb933a8
Implement Token::findsimplematch und use it for simple patterns
2011-10-27 15:59:22 +02:00
Thomas Jarosch
54adb910ec
Use Token::simpleMatch instead of Token::Match for simple patterns
2011-10-27 15:59:22 +02:00
Edoardo Prezioso
9bb1a1b7a5
Added code for simplification of 'for ( a; b; c;); -> '{ a; for (; b; c;) ; }'.
...
It's not enabled because it fails many tests with testrunner.
2011-10-27 02:59:50 +02:00
Edoardo Prezioso
1be1af4afb
Move the simplification of 'strlen' in simplifyTokenList.
...
This way it's possible to omit the call to simplifyKnownVariables before 'strlen'.
2011-10-27 01:24:35 +02:00
Edoardo Prezioso
df5d26901c
Add new warning option to check for dead code and change the order of some struct members to reduce structure padding.
2011-10-24 03:02:00 +02:00
Thomas Jarosch
db8c7deb30
Fixed #3232 (Check if container is modified inside BOOST_FOREACH)
2011-10-23 13:07:43 +02: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
Daniel Marjamäki
32e20d4e31
made 'variableHidingTypedef' inconclusive. See ticket #3199
2011-10-22 13:26:33 +02:00
Marek Zmysłowski
b332ea8222
Fixed #3204 (Refactor standards support in Settings)
2011-10-22 09:45:48 +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
4f256ef314
Runastyle + removal of useless conditions after previous commit.
2011-10-19 14:48:08 +02:00
Edoardo Prezioso
73f0e2c5b9
Fixed ticket #3227 (Improve tokenizer: labels are not handled correctly after a case or another label instruction)
...
Moved the labels simplification after combining the tokens and moved the case/default simplification inside the labels.
2011-10-19 14:20:09 +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
de8eb48a5c
Remove redundant function findmatch inside tokenize.cpp.
...
There's Token::findmatch which is already used inside other Tokenizer functions.
2011-10-17 13:46:27 +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
Ettl Martin
1a710e5761
fixed regression on linux due to missing include
2011-10-16 14:16:35 +02:00
PKEuS
f8074b71d2
Fixed #2470 (False negative: Possible null pointer dereference (C++0x keyword 'nullptr'))
2011-10-16 12:54:58 +02:00
Thomas Jarosch
a52b73f9f9
Fix #3208 (Simplify pointer to standard type, C only)
...
The symbol database is unavailable during token simplification
and &data[0] might return something completely different for C++.
Moved code_is_c() from checkOther to Tokenizer.
2011-10-16 08:09:57 +02:00
Edoardo Prezioso
8afc1b6f2d
Changed the name of the removal of dead code after flow control statements for consistency (simplifyDeadCode is too generalized as name)
2011-10-15 12:45:48 +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
Jonathan Neuschäfer
4fb7865f49
fix typos using codespell
...
Codespell is available at http://git.profusion.mobi/cgit.cgi/lucas/codespell/ .
2011-10-13 22:04:41 +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
Daniel Marjamäki
371871b0b7
Tokenizer::removeMacrosInGlobalScope: Don't remove C/C++ keywords namespace/struct/etc. Ticket: #3193
2011-10-12 19:23:39 +02:00
Robert Reif
ee04c1bfb7
fix #3194 (Parsing glitch causes false 'can be const' error for an 'if' statement)
2011-10-12 09:10:34 -04:00
Edoardo Prezioso
742858b67c
Fixed some simple errors in some old commits.
2011-10-10 17:18:47 +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
Daniel Marjamäki
96beb94b21
Fixed #3183 (False positive: (error) syntax error)
2011-10-09 18:42:36 +02:00
Edoardo Prezioso
9270b84d64
More fixes to the label simplifier (related to ticket 3176):
...
1)Simplify the labels if there are combinations of the symbols '*','&','{' and '(' after a '%var% :' and before another '%var%';
2)but do not simplify the label if it's inside an unpreprocessed macro code.
2011-10-08 21:13:53 +02:00
Robert Reif
a1a839fadc
fix tokenizer and symbol database to not mistake goto statement for variable declaration
2011-10-07 08:11:48 -04:00
Edoardo Prezioso
80df7ea839
Fixed ticket #3176 (cppcheck reports wrong unused variable)
...
Label simplification didn't take count of the '(' parenthesis or the '&' and '*' operators inside or outside the parenthesis after the colon.
2011-10-07 00:54:44 +02:00
Edoardo Prezioso
fe4ce594ce
Renamed the function 'removeRedundantCodeAfterReturn' with 'simplifyDeadCode'.
...
This is a preparation in order to add new features to this function (see the @todo in the tokenize header file, ticket #3113 and #3175 for details).
2011-10-06 22:40:39 +02:00
Edoardo Prezioso
8e90ad106c
Fixed ticket #3148 (Analysis failed on "Modules/mathmodule.c")
...
Fix: Do not handle code when 'return' is inside a macro. This is valid also for 'switch' code inside a macro.
2011-10-05 19:33:46 +02:00
Edoardo Prezioso
3c370dcfdf
Fixed #3146 "Analysis failed" error on softmagic.c:
...
-Fixed: the code didn't check the rightness of the switch syntax if it was inside another switch;
-Tweaked: removed the two bool variables, so now the conditions take count of indentation unsigned variables.
2011-10-04 12:16:39 +02:00
Edoardo Prezioso
bc74213036
Fixed #3132 (Analysis failed. If the code is valid then please report this failure.)
2011-10-03 19:38:37 +02:00