Commit Graph

3170 Commits

Author SHA1 Message Date
PKEuS 00d6a0e877 refactorizations for CheckClass and for less false negatives related to derived classes 2011-12-14 21:11:40 +01:00
Daniel Marjamäki 295f486cde Uninitialized variables: Detect more errors when variable is given as array index. Ticket: #3369 2011-12-14 19:56:58 +01:00
Daniel Marjamäki 63e2f64b9c Uninitialized variables: Fixed false positives for loops. Ticket: #3369 2011-12-14 18:54:03 +01:00
Daniel Marjamäki 8e3e634ce0 Uninitialized variables: Detect more errors. Ticket: #3369 2011-12-14 18:28:30 +01:00
Daniel Marjamäki 419ae2a135 Uninitialized variables: Fixed false positive in new checking when variable is initialized in condition 2011-12-14 17:17:24 +01:00
Daniel Marjamäki 6a4b1127aa astyle formatting 2011-12-14 17:07:06 +01:00
PKEuS 8ed8206b44 Fixed #3296 (false positive (inconclusive): 'C::operator=' should return 'C &') 2011-12-14 15:37:43 +01:00
Daniel Marjamäki ba463295c2 Uninitialized variables: improved check to detect more errors. Ticket: #3369 2011-12-14 06:00:17 +01:00
Daniel Marjamäki c7ce87d060 Uninitialized variables: Fixed false positives for break/continue/throw 2011-12-14 05:45:52 +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
Daniel Marjamäki 458fa0874a Uninitialized variables: Started writing a new check. Ticket: #3369 2011-12-13 21:57:27 +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
Daniel Marjamäki 34fba9e1ea Fixed #3405 ((error) Invalid number of character ({) when these macros are def ined: 'WIN32'.) 2011-12-13 21:14:41 +01:00
Edoardo Prezioso 4cad5d4df4 Workaround fixes to shut up some cppcheck '--inconclusive' whinings. 2011-12-13 00:24:34 +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
Reijo Tomperi dc59fc4391 astyle fix 2011-12-12 21:27:48 +02:00
Daniel Marjamäki c8f497a9b3 Fixed #3405 ((error) Invalid number of character ({) when these macros are def ined: 'WIN32'.) 2011-12-12 19:35: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
Daniel Marjamäki 5f5c912f3f temporary fix for inconclusive false warnings. there is not sufficient logic for determining when there is NOT a pointer dereference. 2011-12-12 07:43:33 +01:00
Daniel Marjamäki 2dbe7ca196 CheckNullPointer::isPointerDeRef: Skip inconclusive checking when --inconclusive hasn't been given. 2011-12-12 07:35:53 +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
Daniel Marjamäki ffb5d107be CheckNullPointer::isPointerDeRef: Tweaks to reduce false warnings when inconclusive is used. 2011-12-11 08:48:55 +01:00
Daniel Marjamäki 497c54a1a7 Fixed #3168 (false negative: buffer overflow in subfunction) 2011-12-11 08:16:58 +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
Daniel Marjamäki ee39f6402c reverted fix for #3168, I'll rewrite it 2011-12-10 20:46:10 +01:00
Daniel Marjamäki 897e8637b4 Fixed #3168 (false negative: buffer overflow in subfunction) 2011-12-10 19:26:12 +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
Daniel Marjamäki e870c68978 Check64BitPortability: Wiki formatting update 2011-12-10 18:41:09 +01:00
Daniel Marjamäki c5a1b5ecab --doc : don't write internal checks in the doc output 2011-12-10 18:39:25 +01:00
Edoardo Prezioso bf815ac1e4 Improve labels simplification code, remove redundant checking. 2011-12-10 14:13:48 +01:00
Daniel Marjamäki 93b447f7f6 1.52: Updated version 2011-12-10 12:55:40 +01:00
PKEuS 9fc7453917 Memory leaks: Code cleanups 2011-12-10 11:55:14 +01:00
Daniel Marjamäki 8624c0b9fd Merge pull request #67 from makulik/master
Fixed ticket #3389 '-U option doesn't supress include file handling for #include statements inside #ifdef code paths'
2011-12-10 02:44:01 -08: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 51c1e2303f CheckBufferOverrun::checkInsecureCmdLineArgs(): Remove recently unused variable 'pattern'. 2011-12-09 23:24:08 +01:00
PKEuS 91a0a071d0 Take symbol database into use or improve its usage in some checks. 2011-12-09 23:28:10 +02:00
makulik 0a777dcb52 Fixed ticket #3389 '-U option doesn't supress include file handling for #include statements inside #ifdef code paths'
Signed-off-by: makulik <g-makulik@t-online.de>
2011-12-09 21:57:06 +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 f46cf5fd65 Exception safety: refactorings, use the symbol database 2011-12-09 19:53:00 +01:00
Daniel Marjamäki 8ca8887849 C++ Builder : Fixed compiler error 2011-12-08 22:24:09 +01:00
Daniel Marjamäki b383bae4ab C++ Builder: Fixed compiler errors 2011-12-08 22:17:50 +01:00
Daniel Marjamäki 6029e23189 Preprocessor: Use const_iterator instead of iterator where possible 2011-12-08 22:14:11 +01:00
Daniel Marjamäki 60d828e778 C++ Builder: Fixed compiler error 2011-12-08 22:09:03 +01:00
PKEuS 167a7e3e51 Various code cleanups 2011-12-08 21:28:34 +01:00
Daniel Marjamäki e2dd085b60 Fixed #3394 (False positive: possible null pointer dereference) 2011-12-08 19:30:14 +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
Edoardo Prezioso 76972e8dd3 Extend 'Token::deleteNext' by introducing a new parameter which determines how many tokens should be deleted. It's still not used, though. 2011-12-07 23:36:11 +01:00
PKEuS 1c1c31bea0 Tokenizer: Refactorings and improvements. Better handling of [] 2011-12-07 21:15:00 +01:00
PKEuS 97eecb78a7 Fixed #3381 (false positive: (style) Statements following return, break, continue, goto or throw will never be executed) 2011-12-07 18:20:52 +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 c8bbb77776 CheckMemoryLeakInFunction::simplifycode : use properly 'deleteNext' instead of 'deleteThis' or 'eraseTokens' and remove redundant conversion to 'std::string'. 2011-12-05 15:50:11 +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
PKEuS 501d7ccb2d Optimize checkother.cpp by taking symbolDatabase into use. 2011-12-04 20:49:01 +02: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
Daniel Marjamäki c90558f730 Fixed #3358 (False null pointer dereference positive with ternary ?: operator) 2011-12-03 13:10:07 +01:00
Daniel Marjamäki b7988a3dab Fixed #3336 (False positive: Member function is not used (used by template function)) 2011-12-03 12:19:26 +01:00
PKEuS 1f438b0505 Fixed #3375 (Improve check: Detect unreachable code) 2011-12-03 11:43:23 +01:00
Daniel Marjamäki 69d3d4a17d Fixed gcc compiler warnings 2011-12-03 09:57:56 +01:00
Daniel Marjamäki fb3115a199 Fixed #3267 (False positive: resource leak in vdr-xinelib) 2011-12-03 09:53:36 +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
Daniel Marjamäki 9a84c5845a Fixed #3373 (False posititive: incorrect %* handling in sscanf) 2011-12-02 17:09:32 +01:00
Daniel Marjamäki 6763e596b9 Fixed #3345 (false positive: possible null pointer dereference (guarded by &&)) 2011-12-02 06:11:55 +01:00
Richard Quirk d2c8b9be56 Fix possible null pointer dereference 2011-12-01 19:57:04 +01:00
Richard Quirk b2ea78543b Fix false positive with non-const function calls 2011-12-01 19:57:04 +01:00
Richard Quirk a880469c5a Refactor the same expression check
Work out if a function is inconclusive when creating the entry in the
Expressions class instead of when checking the counts at the end. Store
the result in a new bool flag in the ExpressionTokens helper struct.

The pointer to symbol database and ref to list of const functions are
temporarily stored in  the Expressions helper class to avoid passing
them in too on every endExpr(tok) call.

Use a const reference to ExpressionTokens in the check loop to avoid
repeating the it->second several times, which clarifies what that code
does.
2011-12-01 19:57:04 +01:00
PKEuS 5017646488 Coding fixes and refactorings 2011-12-01 19:43:51 +01:00
Daniel Marjamäki c7e2a198cb Fixed Visual Studio compiler warnings 2011-12-01 18:32:14 +01:00
Daniel Marjamäki 93b21c6cc5 Fixed Visual Studio compiler warnings 2011-12-01 18:27:25 +01:00
Daniel Marjamäki 98480bf504 Fixed #3354 (Incorrect both sides of '||' expression match when using increment in expression.) 2011-12-01 17:46:33 +01:00
Daniel Marjamäki fddfd16758 checkDuplicateExpressions: validate tokens instead of string. Fix for my previous commit. 2011-12-01 17:43:29 +01:00
Daniel Marjamäki 31b576de3b Fixed #3334 (Test for same expression on both sides of '&' reports false positive) 2011-12-01 17:07:55 +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
Zachary Blair 344d7e2f34 Fixed #3283 (False negative: array index out of bounds not found for constant string and known array index value) 2011-11-30 19:17:09 -08:00