Commit Graph

4303 Commits

Author SHA1 Message Date
PKEuS 65db8b8b9f Fixed #4229 2012-12-07 11:45:20 -08:00
Edoardo Prezioso 0273c183a7 Run astyle and update the translation files.
I believe we need a hook script because else everytime we change a file we have to make a new commit to fix the discrepancies problems.
2012-12-07 01:49:51 +01:00
Robert Reif 63b585424d Fixed #4386 (False positive: ctor not detected) 2012-12-05 20:31:17 +01:00
Frank Zingsheim b99d3f0767 Style change: Fixed #4369 (false positive: Variable 'i' is assigned a value that is never used)
based on aebdb3769f
due to comment in aebdb3769f
2012-12-05 20:18:14 +01:00
Frank Zingsheim aebdb3769f Fixed #4369 (false positive: Variable 'i' is assigned a value that is never used) 2012-12-04 21:39:51 +01:00
Daniel Marjamäki c91250cd6e Fixed #4277 (duplicateExpression finds false positive for floats in a union as a member of a class) 2012-12-03 17:05:37 +01:00
Daniel Marjamäki b08ba5b575 Preprocessor: Refactoring previous fix 2012-12-02 20:17:25 +01:00
Daniel Marjamäki cb06d07ae7 Fixed #4351 (Escaped whitespace gives wrong error) 2012-12-02 18:04:19 +01:00
Daniel Marjamäki 15ef6bb32f Fixed #4382 (Use of alloca causes VLA recommendation in C++) 2012-12-02 11:39:26 +01:00
Daniel Marjamäki bf91454136 Fixed #4224 (False positive: Comparison of a boolean with an integer (neglecting a cast)) 2012-12-02 08:34:30 +01:00
Daniel Marjamäki dba51c906e cleanup: removed redundant insideLoop assignment in checkunusedvar. Thank you zingsheim for the suggestion 2012-12-02 07:28:05 +01: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 45a16baaa0 Token: try to improve speed of multicompare macro. 2012-12-01 23:58:01 +01:00
Edoardo Prezioso f6c23fa1e7 runastyle and fix checkInternal messages. 2012-12-01 03:17:55 +01:00
Edoardo Prezioso 9ce6630b28 Add some unused private copy ctors and operator=.
In Token and in Check classes, GCC -Weffc++ reports that it's better to override the copy constructors and the assignment operator to avoid problems with copied objects which could have the same pointers, hence with double frees, when we delete one of these pointers in the copied and in the original object.
2012-12-01 02:17:46 +01:00
Edoardo Prezioso f42ab9871d Fix build breakage in recent commits. 2012-12-01 02:02:45 +01:00
Edoardo Prezioso 5101f3c029 Use the new pattern: '%comp%' where possible.
Change also the description comment of the Token::Match by adding the new pattern and the forgotten '%op%'.
2012-12-01 01:31:35 +01:00
Edoardo Prezioso aeb4531a58 Token::Match: add a new pattern: '%comp%'.
Token::Match returns true if the token is a comparison operator. It's equivalent to matching '<|<=|==|!=|>=|>' and the tests show that the new pattern speeds up the program execution. Added the new pattern in CheckInternal (and also reordered the %cmd% lists) and in TestToken.
2012-12-01 00:55:24 +01:00
Edoardo Prezioso f3782935c2 Tokenizer: improve code and change name of +- concatenation function. 2012-12-01 00:43:23 +01:00
Edoardo Prezioso 3d1d983251 Tokenizer: simplify also __FILE__ together with __LINE__. 2012-12-01 00:37:10 +01:00
Daniel Marjamäki 45b77554ea Fixed #4308 (C++11 raw string literals not parsed correctly) 2012-11-30 13:46:46 +01:00
PKEuS bcb4410dae Fixed invalid function in symboldatabase causing endless recursion (VS10 warning) by const_cast 2012-11-30 02:25:40 -08:00
Daniel Marjamäki 672831f41a Fixed #4187 (False positive: Variable inside a lambda is reported as uninitialized) 2012-11-30 10:30:26 +01:00
Daniel Marjamäki 031adef6ea Array index checking: Fixed TODO comment (false negatives when using ?:) 2012-11-30 09:01:15 +01:00
Daniel Marjamäki 1c4afbce8c Cleanup: Removed += and -= patterns from the checks. These should be simplified. 2012-11-30 07:08:16 +01:00
Daniel Marjamäki 82223227bd Uninitialized variables: Fixed false negative in new checking when using while loops 2012-11-30 06:30:04 +01:00
Robert Reif 35c2b8058d Fixed #3190 (SymbolDatabase: Parse of sub class constructor fails) 2012-11-30 06:03:58 +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
PKEuS 0db2675912 Removed unnecessary pattern "const|" - typeStartToken() never points to "const" 2012-11-29 10:47:52 -08:00
Daniel Marjamäki 68327b3c64 Uninitialized variables: Fixed TODO testcase 2012-11-29 18:41:48 +01:00
Edoardo Prezioso e214d94589 Tokenizer: use list.back() when we start the loop backwards. 2012-11-29 17:42:31 +01:00
Daniel Marjamäki 233b7ddb4c Fixed #4323 (False Positive: Null pointer dereference) 2012-11-29 10:32:34 +01:00
Daniel Marjamäki 7760a92930 CheckAssignIf: Better handling of various expressions in assignments 2012-11-29 10:19:52 +01:00
Daniel Marjamäki 3372657a07 Fixed #4227 (False positive: Comparison of a boolean with an integer (double dResult=false)) 2012-11-29 09:29:25 +01:00
Daniel Marjamäki 509721d6d0 Fixed #4304 (False positive during an array declaration) 2012-11-29 08:44:12 +01:00
Daniel Marjamäki ba3833c692 Fixed #3678 (stlcstrReturn for classes which don't provide a std::string) 2012-11-29 07:10:56 +01:00
Edoardo Prezioso 6b40d93f6f Try to fix Visual Studio compiler warning.
Related to commit 119ab519a4.
2012-11-28 12:06:27 +01:00
Daniel Marjamäki 40719c56db Fixed #4183 (false positive with method named c_str()) 2012-11-28 08:48:48 +01:00
Daniel Marjamäki 7d94230329 Fixed #4079 (#if condition does not evaluate numbers with sign) 2012-11-28 07:33:24 +01:00
Daniel Marjamäki 5d1b4e6dbb Tokenizer: Remove redundant '+' 2012-11-28 07:09:56 +01:00
Frank Zingsheim f23ce8d254 Fixed #4180 (false positive: (style) Variable is assigned a value that is never used (inside loop)) 2012-11-28 06:11:33 +01:00
Daniel Marjamäki 4e92f8dfcd Fixed #4295 (False positive: Expression '(X & 0xFF00000000000000LL)==0xa00000000000000' always evaluates to false (64-bit value)) 2012-11-27 17:37:49 +01:00
Edoardo Prezioso f3029ce6bb Fixed a bug in Tokenizer::simplifyKnownVariables.
When we find constant variables, check if there's a usage of its reference in the code (for example: don't simplify 'f(&x)' to 'f(&100)').
2012-11-26 17:06:52 +01:00
Robert Reif bbc1747919 Fixed #3702 (False negative: fail to detect constructor implementation with slightly different (irrelevant) signatures) 2012-11-26 16:34: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
Edoardo Prezioso 9dae536ce3 Little tweaks to Token::Match code. 2012-11-25 15:20:50 +01:00
Edoardo Prezioso 0f4cdc9e87 More CheckNullPointer speed ups, related to #4266. 2012-11-25 14:55:31 +01:00
Edoardo Prezioso 927d3e8ce2 Speed up the new CheckNullPointer checking.
Related to commit 095824373a, using the new precomputed vector of functions, related to ticket #4266.
2012-11-25 12:40:14 +01:00
Zachary Blair 095824373a Fixed #3302 (new check: nullpointer dereference) 2012-11-20 23:56:17 -08:00
Edoardo Prezioso 5fb2115e9d Fixed a bug in Tokenizer::concatenateNegativeNumber.
The first negative number inside a '{}' list was not simplified correctly.
2012-11-20 19:14:58 +01:00
Robert Reif ffe657128f Fixed #4364 (Segfault in CheckStl::stlBoundries) 2012-11-20 06:12:14 +01:00
Edoardo Prezioso e0c10efdce Add a 'prepend' bool option to Token::InsertToken.
If it's true, add a new token before this. Except when this is the first one in the list, because there's not a way to update the list.front (I noticed some Token functions can potentially delete the list.front(), I don't know which effects does it cause).
2012-11-20 02:58:19 +01:00
Edoardo Prezioso fdeacbaec6 Enhance style and code to Token::Match function. 2012-11-20 00:19:57 +01:00
Edoardo Prezioso 39bd31b44c Improve comment style in token.cpp. 2012-11-19 16:30:07 +01:00
Daniel Marjamäki 382e1e95ef Fixed #4168 (False positive: (style) struct or union member 'super::x' is never used) 2012-11-18 15:24:47 +01:00
Daniel Marjamäki 7ecfb189a2 astyle formatting 2012-11-18 15:04:45 +01:00
Edoardo Prezioso c5e5ee9ed2 Adapt %var%|%num% changes with Tokenizer, final. 2012-11-17 22:44:31 +01:00
Edoardo Prezioso 1bf003389e Adapt %var%|%num% changes with Tokenizer, part 4. 2012-11-17 22:43:42 +01:00
Edoardo Prezioso f8e4af9ce2 Adapt %var%|%num% changes with Tokenizer, part 3. 2012-11-17 22:42:24 +01:00
Edoardo Prezioso bd63db62af Adapt %var%|%num% changes with Tokenizer, part 2. 2012-11-17 22:40:44 +01:00
Edoardo Prezioso 2b4215ea7a Adapt %var%|%num% changes with Tokenizer, part 1. 2012-11-17 22:39:02 +01:00
Edoardo Prezioso 9d0a295b85 Partially fixed #4288 (handle %var%|%num% patterns). 2012-11-17 20:51:18 +01:00
Robert Reif 6b8e83a181 speed up checks by caching commonly looked up stuff in the symbol database (checkother, checkstl, checkunusedvar). Ticket: #4266 2012-11-16 06:50:49 +01:00
Daniel Marjamäki a2febc49d6 Fixed #4318 (False positive: 'unreadVariable') 2012-11-15 08:36:43 +01:00
Daniel Marjamäki 79cd601ae7 Fixed #4356 (False positive at variable initialization) 2012-11-15 07:48:45 +01:00
Robert Reif 09eed80938 speed up checks by caching commonly looked up stuff in the symbol database (CheckOther). Ticket: #4266 2012-11-15 07:11:45 +01:00
Robert Reif 04d04c33c2 speed up checks by caching commonly looked up stuff in the symbol database (CheckOther). Ticket #4266 2012-11-14 18:12:33 +01:00
Robert Reif 6578b78077 speed up checks by caching commonly looked up stuff in the symbol database (checkIncorrectLogicOperator). Ticket: #4266. 2012-11-13 18:30:33 +01:00
Robert Reif f82eff6589 speedup checkpostfixoperator.cpp by caching commonly looked up stuff in the symbol database. Ticket: #4266 2012-11-12 06:16:38 +01:00
PKEuS e5ebb49312 Added support for sizeof(wchar_t). Improved <Windows.h> type testing for Win64 platform. 2012-11-11 16:16:17 +01:00
PKEuS 5555e055f1 Refactorized <Windows.h> type support:
- Changed some more Win32 simplifications of wide-character/string types to use wchar_t
- Added support for LPWSTR
- Fixed test case to ensure that simplifications also work for Win32W
2012-11-11 15:40:06 +01:00
PKEuS 4ea2df8671 Changed handling of type wchar_t:
- Don't simplify wchar_t to unsigned short on Win32 platforms to ensure that checking of strings and nullpointer dereferences works.
- Added it as standard type
2012-11-11 14:47:16 +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 704f285c90 Refactorized CheckStl::pushback():
- insert(), reserve() and clear() also invalidate iterators
- Properly support return and throw statements: Bailout after semicolon
- "." is also bad usage of invalid iterator.
2012-11-11 13:03:58 +01:00
Jose Roquette e8d3a4300d Fixed #4197 - False negative: invalidIterator2 not detected 2012-11-11 12:01:52 +01:00
PKEuS 4ee955fc8c Improved CheckNullPointer::isPointerDeRef():
- Fixed #4240
- Added support for wstring/wchar_t
2012-11-10 19:53:20 +01:00
PKEuS 3e03838025 Fixed verbose messages in CheckOther::incorrectLogicOperatorError which didn't contain all information of the short message. 2012-11-10 11:31:36 +01:00
PKEuS f75826c3e2 Added wstring to pattern where I forgot in bbe06c65c0 2012-11-09 20:25:50 +01:00
PKEuS 58fe7105f4 Remove C++11 keywords "override", "final" and "constexpr" 2012-11-09 19:53:10 +01:00
PKEuS ce961578c2 New checks (inconclusive): Suspicious calculation with sizeof()
- Check for sizeof(ptr)/something: This indicates that programmer was trying to calculate array size, but sizeof(ptr) doesn't return the length of the memory area, but size of a pointer.
- Check for sizeof()*sizeof(): This indicates that programmer misunderstood what sizeof() does: It does return the length in bytes of the given variable, not e.g. the number of elements in an array.
2012-11-09 18:08:20 +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 9556634ee7 Revert 1c0617c504. 2012-11-07 18:34:25 +01:00
Edoardo Prezioso 061a5e1ad7 Run astyle. 2012-11-07 02:24:46 +01:00
Edoardo Prezioso 1c0617c504 change some Token::Match patterns used in code:
replace '||' with '%oror%', where possible.
2012-11-07 02:23:09 +01:00
PKEuS aa2ad41629 Print message "Found calculation inside sizeof()" also for increment/decrement operator. 2012-11-06 11:39:47 -08:00
PKEuS bbe06c65c0 Added support for wide-strings (wcs* functions, std::wstring, std::*wstringstream) at many places. 2012-11-06 10:54:52 -08:00
Zachary Blair 51d128c918 Fixed #2029 (free invalid address) by reporting previously-unreported errors as "inconclusive" 2012-11-05 21:02:51 -08:00
Edoardo Prezioso ca2a6e6054 Add '%char%' as a CheckInternal known pattern. 2012-11-05 17:25:36 +01:00
Edoardo Prezioso 63307c5db2 Remove the now useless fix for #4245.
The fix for #4276 made completely useless that branch, so remove it until someone shows a testcase which breaks this commit.
2012-11-05 00:13:04 +01:00
Edoardo Prezioso 7293fcfa9b Remove redundant code in simplifyVarDecl:
TokenList::insertTokens adds the missing braces links when needed. The function does not add links to '<>', though, hence the TODO.
2012-11-05 00:12:22 +01:00
Edoardo Prezioso 4e25ffa948 Remove unexecuted branch in duplicateTypedef:
If the code is intended to be used, please revert + provide a valid testcase.
2012-11-04 23:03:14 +01:00
Edoardo Prezioso 333711ae4f Remove dead branch in simplifySizeof:
the code in that branch won't ever be executed because simplifySizeOf is called after arraySize, which adds the string length inside the '[]' parenthesis.
2012-11-04 22:41:38 +01:00
Edoardo Prezioso 24bf6f99e1 More simplifyRedundantParenthesis changes:
simplify also '( var . var . ... . var )' parenthesis.
2012-11-04 22:38:18 +01:00
Edoardo Prezioso b6b359d1c6 Tokenizer::simplifyRedundantParenthesis refactor:
Change useless 'while' to 'if' where possible; unify duplicate 'delete [| ]| var' handling code.
2012-11-04 20:51:40 +01:00
Edoardo Prezioso 93f1fed205 Tokenizer '?:' handling code refactorization:
move '=|,|(|[|{|}|;|case|return (%bool%) ?' code handling from simplifyConditionOperator in simplifyConstTernaryOp in order to use a more efficient code, thus to remove code duplication.
2012-11-04 19:18:11 +01:00
Edoardo Prezioso 18e1eb7c70 Add missing hunks in the previous commit. 2012-11-04 19:08:54 +01:00
Edoardo Prezioso c54eafdf69 Use '%char%' matching in the tokenizer file. 2012-11-04 17:22:38 +01:00
Edoardo Prezioso 87c931b74b Add '%char%' as pattern to match in Token::Match.
All and only those single characters enclosed in "'" are accepted.
2012-11-04 16:58:18 +01:00
Andrew Martin 7c370ec873 Fixed #4305 (improve check: 'vector.size() < 1' should result in 'inefficient checking for '...' emptiness.') 2012-11-04 16:15:26 +01:00
PKEuS dc3eba964b Incremented version to "1.58 dev" (1.57.99) 2012-11-04 15:49:18 +01:00