Commit Graph

4240 Commits

Author SHA1 Message Date
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
Daniel Marjamäki 3a44a5ca3c 1.57: Setting version 2012-11-04 13:50:23 +01:00
PKEuS 4cd96158ae Fixed parsing of "__asm__ volatile {""};" 2012-11-04 12:21:34 +01:00
PKEuS b0c1c2c819 Don't suggest using initialization list for static variables (#4332) 2012-11-04 11:59:09 +01:00
PKEuS e44ee280bc Fixed handling of pointers to functions in namespace as template parameters (#4172) 2012-11-04 11:15:03 +01:00
PKEuS 9cb9388e49 Fixed handling of pointers in templates (#4319) 2012-11-04 10:49:25 +01:00
PKEuS 6122819832 Message refactorization: Changed expression "0-terminate" to "null-terminate" as discussed on 24b98feadb 2012-11-03 21:21:19 +01:00
PKEuS 1c399c86ca Improved fix for #4311; Added back support for "this." (fixes again #4291)
Added TODO unit test for missing varid.
2012-11-03 21:16:05 +01:00
PKEuS c84857fc7e Fixed compilation as shared lib with PCRE: Ensure that sizeof(Settings) is the same with and without HAVE_RULES
Fixed VS10 solution when TinyXml is included (define TIXML_USE_STL).
2012-11-03 20:37:23 +01:00
Daniel Marjamäki 6c2563c467 Fixed #4311 (False positive: warning (selfAssignment): Redundant assignment of 'm_bar' to itself. 2012-11-03 13:18:43 +01:00
Daniel Marjamäki 24e71c479c Fixed #4301 (htmlreport broken) 2012-11-03 11:25:40 +01:00
PKEuS a36e008967 Fixed #4314: Using CheckNullPointer::isPointerDeRef() here is overkill and doesn't work as intended, since this function is designed to return 'false' if it isn't sure. 2012-11-03 10:25:32 +01:00
Edoardo Prezioso c9e0089546 Change Tokenizer member function name.
From 'simplifyQuestionMark' to 'simplifyConstTernaryOp' (the older name was not clear). Adjusted the doxy comment.
2012-11-02 14:57:12 +01:00
PKEuS 24b98feadb Message refactorization: checkuninitvar.cpp, checkunusedfunctions.cpp, checkunusedvar.cpp 2012-11-01 18:40:20 +01:00
Robert Reif d7b658a5aa speed up checks by caching commonly looked up stuff in the symbol database (checkio) 2012-10-30 15:52:45 +01:00
Robert Reif 8e14d7682c Symbol database: fix some function prototype bugs that were found during check conversions. Ticket: #4266 2012-10-30 15:48:06 +01:00
Daniel Marjamäki e1dce66494 tweaked message 2012-10-28 13:03:40 +01:00
Daniel Marjamäki 38213f1f2f Fixed #4237 (False positive: (error) Memory Leak: data (assign reference variable value to a shadow variable in inner scope)) 2012-10-27 16:36:14 +02:00
Daniel Marjamäki 863441afe8 Fixed #4236 (False positive: pointer free()d twice - neglecting call to other function) 2012-10-25 19:41:18 +02:00
Edoardo Prezioso 39a5768e9d Fixed cppcheck message found in lib:
[lib/checkmemoryleak.cpp:869]: (style) The scope of the variable 'realloc' can be reduced.
And since realloc is never used, for now I commented all the lines where 'realloc' is declared/used.
2012-10-25 14:05:53 +02:00
Edoardo Prezioso 8271d63744 Forgot to fix another clang analyzer message.
I don't understand why here there is a loop 'break' after a token stepping forward and a bool assignment.
2012-10-24 15:30:40 +02:00
Edoardo Prezioso 99777671e5 Related to commit 11b00470637ed119140fb6257a5552f13f010d85: fix copy-paste mistake. 2012-10-24 03:27:15 +02:00
Edoardo Prezioso 11b0047063 Fix some clang analyzer messages.
CheckMemoryLeak: two redundant assignments, should be clarified;
TemplateSimplifier: same;
Tokenizer: same.
2012-10-24 03:17:56 +02:00
Edoardo Prezioso b50e1f4451 Attempt to fix all doxygen warnings. 2012-10-24 01:32:07 +02:00
Daniel Marjamäki e7483af028 Opposite inner conditions - made check 'experimental' because there are unsolved false positives. 2012-10-21 18:18:29 +02:00
Robert Reif d1fad4b762 speed up checkmemoryleak by caching commonly looked up stuff in the symbol database (#4266) 2012-10-21 09:07:51 +02:00
Robert Reif 9bc2a62c1e speed up checkio by caching commonly looked up stuff in the symbol database (#4266) 2012-10-21 09:05:01 +02:00
Baris Demiray 0e100f7563 Fixed #4189 (Improve check (printf('%l') not detected)) 2012-10-21 08:50:29 +02:00
Edoardo Prezioso f0f216390e Fixed #4276 (segmentation fault of cppcheck (invalid code)) 2012-10-20 21:40:51 +02:00
Edoardo Prezioso 4ddcde1e6f CheckMemoryLeak: add '?1:0' to clarify the value of the argument to 'deleteNext'; Tokenize.cpp: in simplifyCompoundAssignment(), remove ':' odd code used to fix a weird test case ('case' code not inside a function body), remove useless 'tok->next() != NULL' check (already true by previous condition); in simplifyConditionOperator(), handle better the parenthesis skipping code and remove useless ')'check; in simplifyQuestionMark(), remove useless 'tok->tokAt(-2)' check (Token::Match returns false if the token is NULL), add more patterns to Token::Match to handle more test cases; in simplifyBitFields(), add 'const' to 'offset' bool. RedirectOutputError: style nitpick change to declaration of a pointer. 2012-10-19 14:19:52 +02:00
PKEuS e44e6837c2 Fixed several doxygen-comments in lib and gui 2012-10-19 11:29:05 +02:00
Baris Demiray d84d360afc Fixed #4291 (Variable ID is not set when variable is accessed through 'this') 2012-10-19 06:18:13 +02:00
Edoardo Prezioso c1718ae38d Fixed g++ -Wshadow warning message. 2012-10-17 00:29:06 +02:00
Edoardo Prezioso 61365ea0e5 Fixed #4293 (FP: Variable is not simplified, causing a false positive). 2012-10-17 00:25:20 +02:00
Daniel Marjamäki b591097c87 Revert "Fixed #3190 (SymbolDatabase: Parse of sub class constructor fails)"
This reverts commit 1ee980184e.
2012-10-16 19:12:27 +02:00
Robert Reif 1ee980184e Fixed #3190 (SymbolDatabase: Parse of sub class constructor fails) 2012-10-16 06:11:28 +02:00
Daniel Marjamäki 562291477d Fixed #4226 (False positive: Uninitialized variable (problem with namespace ::rtl)) 2012-10-15 06:53:38 +02:00
Daniel Marjamäki be174d6266 TemplateSimplifier: Fixed bad pattern that was detected by CheckInternal and pointed out by edward-san. The handling of recursive templates is better now. 2012-10-14 19:48:53 +02:00
Robert Reif 3064b48156 speed up checks by caching commonly looked up stuff in the symbol database (checkexceptionsafety) 2012-10-14 17:40:17 +02:00
Robert Reif cf7996e299 SymbolDatabase: Improved find function functionality. Taking arguments into account 2012-10-14 17:34:09 +02:00
Robert Reif 0d4b87c71e SymbolDatabase: Improved find function functionality. Taking arguments into account 2012-10-14 17:30:37 +02:00
Robert Reif 2a2366b258 Fixed #4226 (False positive: Uninitialized variable (problem with namespace ::rtl)) 2012-10-14 17:25:29 +02:00
PKEuS f4a06133a3 New attempt on properly fixing Unicode characters in version resource. 2012-10-14 16:00:58 +02:00
PKEuS 2aae8381cc Message refactorization: checkstl.cpp 2012-10-14 11:16:48 +02:00
PKEuS fc53b15fa4 Refactorized resource files:
- Stored global information about cppcheck version and copyright string in a single resource.h file.
- Use macros of windows.h instead of numeric values for filetype, etc.
- Added versioninfo metadata to lib (#4275)
- Removed VS resource editor code from resource files - these files shouldn't be modified with it to avoid information loss
- Renamed files to version.h/rc
- Encoded files as ANSI again - use escape sequences for unicode characters in literals (#4281)
2012-10-14 10:21:22 +02:00
Edoardo Prezioso 8324de1dc0 Fixed 'tokAt(-2)->link() -> linkAt(-2)' thanks to cppcheck internal check. 2012-10-13 14:59:34 +02:00
Edoardo Prezioso 64b4960acc Tokenizer: simplify GCC '({ %var%|%num% ; })' to '%var%|%num%'.
Remove useless brace around condition in simplifyFlowControl.
2012-10-13 13:24:41 +02:00
Robert Reif 0f8db28d30 speed up checks by caching commonly looked up stuff in the symbol database (CheckBufferOverrun, CheckBoost) 2012-10-13 11:16:48 +02:00
Edoardo Prezioso 1951d1cdc5 Tokenizer: improve the new 'skipTernaryOp' function by supporting GCC '{(var|num;)}' statement expression extension; improve 'Tokenizer::simplifyQuestionMark' by supporting simplification with 'case' before ternary operation, using skipTernaryOp to get colon and, most importantly, supporting indented '?:' operations. 2012-10-13 02:32:43 +02:00
Edoardo Prezioso d4a3c1617a Fixed: Tokenizer::simplifyLabelCaseDefault was careless with '?:' operator near 'case' adding the semicolon after the ternary colon. 2012-10-12 20:51:13 +02:00
XhmikosR 8d08c3b58b pro and pri files: remove unneeded empty lines, use spaces for consistency 2012-10-12 17:46:57 +02:00
Edoardo Prezioso c42facae1f Tokenizer::simplifyLabelsCaseDefault: jump '(' and '[' parenthesis.
TestTokenizer: add simple test cases with some correct and wrong syntax concerning 'case'.
2012-10-12 17:08:21 +02:00
Robert Reif 5a7aae31f3 speed up checkautovariables by caching commonly looked up stuff in the symbol database (#4266) 2012-10-12 06:15:46 +02:00
Daniel Marjamäki dd906a86a6 astyle formatting 2012-10-12 06:12:52 +02:00
Robert Reif 0c731cfa9b speed up check64bit by caching commonly looked up stuff in the symbol database (#4266) 2012-10-12 06:12:21 +02:00
Edoardo Prezioso 1e4b080737 Fixed #4278 (syntax error). 2012-10-11 13:35:20 +02:00
Robert Reif c7961b147d speed up checks by caching commonly looked up stuff in the symbol database 2012-10-11 06:12:24 +02:00
Robert Reif bbfd676b4e speed up checks by caching commonly looked up stuff in the symbol database 2012-10-10 20:42:07 +02:00
Edoardo Prezioso e62e03ab31 Fixed #4267 (segmentation fault of cppcheck (invalid code)). 2012-10-09 20:44:30 +02:00
Edoardo Prezioso 3703e71f82 Related to previous commit: if the '{}' parenthesis are found after 'case', don't skip them after continuing to the main loop or it will cause indentlevel mismatching. 2012-10-09 18:24:21 +02:00
Edoardo Prezioso 9668508b32 Tokenizer::simplifyLabelsCaseDefault:
use more efficient check for 'const' token;
remove redundant NULL checks thanks to commit e3bbcf501f.
2012-10-09 17:52:20 +02:00
Ettl Martin 2cf75d5339 astyle run 2012-10-08 21:50:21 +02:00
Ettl Martin 0879bb5825 #4245: Segmentation fault (invalid code); Applied patch from amai. 2012-10-08 21:49:25 +02:00
Daniel Marjamäki f74c30e116 Fixed #4231 (False positive: (error) Returning/dereferencing 'ptr' after it is deallocated / released (ignoring goto)) 2012-10-08 17:23:47 +02:00