Commit Graph

341 Commits

Author SHA1 Message Date
PKEuS 0105f8223c Simplified several Token::Match/simpleMatch calls when match string consists of a single pattern
Fixed two CheckInternal error messages
2013-03-01 03:42:04 -08:00
PKEuS f899e6ca30 Changed behaviour of %op% pattern accordingly to changes to Token::isOp(). Added %cop% as replacement for old %op% 2013-03-01 02:43:59 -08:00
PKEuS 670c4de8a9 Changed behaviour of Token::is*Op() functions:
- Rename Token::isOp() to Token::isConstOp() (indicating that the operator does _not_ modify the input variables)
- Create new Token::isOp(), returning true also for ++, -- and assignment operators
- Make Token::isExtendedOp() returning also true for all assignment and ++/-- operators
2013-02-28 12:50:29 -08:00
Daniel Marjamäki 2edf95a1b9 Fixed #4367 (false positive: Class '...' is unsafe, '...' can leak by wrong usage) 2013-02-24 08:14:25 +01:00
Daniel Marjamäki bd7e3cbac5 Fixed #4540 (memory leak not detected ('.' or '->' is used before Function)) 2013-01-31 17:00:50 +01:00
Robert Reif ec1c86c152 Symbol database: more function/variable cleanup. Ticket: #4494 2013-01-31 06:41:18 +01:00
Robert Reif 859793731d SymbolDatabase: Refactor findFunction handling. Ticket: #4494 2013-01-28 06:47:48 +01:00
Daniel Marjamäki f86e83d813 Memory leaks: Improved handling of allocation functions that contains ::. Ticket: #4494 2013-01-22 21:33:39 +01:00
Andrew C. Martin 4a73c93750 Fix compiler warnings and comment/string typos
- fix g++ warning:

> lib/checkother.cpp:3779: warning: comparison between signed and unsigned integer expressions

 - fix suncc warning (see [everything2](http://everything2.com/title/C%252B%252B%253A+static+extern+%2522C%2522)):

> "lib/checkmemoryleak.cpp", line 578: Warning (Anachronism): Formal argument __compar of type extern "C" int(*)(const void*,const void*) in call to bsearch(const void*, const void*, unsigned long, unsigned long, extern "C" int(*)(const void*,const void*)) is being passed int(*)(const void*,const void*).

- prefer empty() / isEmpty() over "size() > 0" (cases not caught by stlSize)

- fix word misspellings (mostly comments, a few output lines)

  - Parenthesis => Parentheses (both variations were used in the codebase)

  - fix typo and wording ("never alwayw") in gui/test/data/benchmark/simple.cpp's CheckOther::unsignedPositive():

```
-  "An unsigned variable will never alwayw be positive so it is either pointless or "
+  "An unsigned variable can't be negative so it is either pointless or "
```
2013-01-16 07:37:07 -07:00
Reijo Tomperi 5d5f7085bf Updating year 2012 -> 2013 to .cpp and .h files and man page. 2013-01-01 18:29:08 +02:00
acm4me 7da155c8ba Support for Sun Studio C++ compiler 2012-12-27 11:51:12 +01:00
Daniel Marjamäki a84d21f271 CheckMemoryLeaksInFunction: Fixed problems with catch and function calls. Ticket: #4405 2012-12-16 18:06:40 +01:00
Frank Zingsheim 327db15284 Fix #4045: memory leak not reported after usage of " + p[]" 2012-12-09 08:59:21 +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
Robert Reif 35c2b8058d Fixed #3190 (SymbolDatabase: Parse of sub class constructor fails) 2012-11-30 06:03:58 +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
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 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
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
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
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
PKEuS 508e9394d3 Added some nullpointer-checks and removed some redundant ones based on VS2012 code analysis results. 2012-09-17 15:22:51 +02:00
XhmikosR 6e4e3dfbfb lib: tabs to spaces, remove trailing spaces and extra empty lines at the end of files 2012-09-17 13:51:23 +02:00
PKEuS 2db1dbe2ce Changed some function prototypes according to cppcheck messages about functions that can be static. 2012-09-11 19:19:11 +02:00
PKEuS 22a8e3f4e6 Replaced Tokenizer::getFunctionTokenByName() by SymbolDatabase::findFunctionByName(), which handles scopes slightly better. 2012-09-11 18:03:47 +02:00
Daniel Marjamäki 54f1771938 Fixed #4082 (Maybe false positive: memleak) 2012-09-10 17:27:41 +02:00
PKEuS 8c70778b70 Refactorization: Fixed several messages when self-checking cppcheck 2012-09-04 15:29:51 +02:00
Daniel Marjamäki 0ead18122d Fixed #3695 (False positive: memory leak (ptr?free(ptr):0)) 2012-07-27 12:25:20 +02:00
Daniel Marjamäki e6f761126c Fixed #2802 (False positive: ::free() is not recognised as free() to release buffers) 2012-07-24 09:28:08 +02:00
Daniel Marjamäki a768b0e8b2 Fixed #3954 (Pointer reference memory leak false positive) 2012-07-17 16:28:34 +02:00
PKEuS 5caab6ba10 Fixed crash on garbage code (#3870) 2012-07-06 09:03:33 -07:00
Edoardo Prezioso fa24fff3dc Fixed the warning with GCC 4.7.1:
cast from type ‘const void*’ to type ‘const char**’ casts away qualifiers.
2012-07-02 19:37:30 +02:00
Daniel Marjamäki 0042ee7bc8 Fixed #3660 (False positive memleak (allocation function uses non-local variable)) 2012-06-25 20:00:50 +02:00
Daniel Marjamäki 72d24ab4b4 Fixed #3904 (false positive memory leak with linked list) 2012-06-23 20:15:58 +02:00
Daniel Marjamäki a823d29da3 Fixed #3809 (false positive: memory leak) 2012-06-01 19:01:19 +02:00
Daniel Marjamäki 2e41510e30 Fixed #3806 (Possible leak in public function. The pointer '' is not deallocated before it is allocated) 2012-05-29 21:13:34 +02:00
PKEuS 9dc8123151 Refactorizations:
- Use const string references instead of const strings copies when possible
- Fixed cppcheck warning about postfix increment in CheckIO
- Use symbolDatabase to detect pointers in CheckOther::checkAssignBoolToPointer
2012-05-25 03:09:41 -07:00
PKEuS dc64ac2918 Removed unnecessary variable Function::start - The value is already stored in Function::functionScope->classStart. 2012-05-22 12:58:46 -07:00
PKEuS 4bb2a1b27b Made some functions static or const according to cppcheck results 2012-05-17 01:33:24 -07:00
PKEuS db914d7185 Fixed compiler errrors and warnings mentioned in #3783 2012-05-07 06:34:47 -07:00
PKEuS 6ef92c4fd7 Use recently implemented new constructor of ErrorLogger::ErrorMessage in checkmemoryleak.cpp and symboldatabase.cpp
Fixed test failure introduced in f105bf75a6
2012-05-06 04:01:56 -07:00
PKEuS 1a5fbd61d2 Splitted class TokenList from Tokenizer 2012-05-05 09:33:26 -07:00
PKEuS 04704ac5fa Refactorizations in checkmemoryleak.cpp:
- Use symbolDatabase more often to increase performance and accuracy.
- Replaced indendation counter
- Replaced custom stringify implementation

Benchmark results (sqlite checking):
4% complete, 7% on "Memory leaks (function variables)", 9% on "Memory leaks (address not taken)" and 82% on "Memory leaks (struct members)"
2012-05-03 10:43:47 +02:00
PKEuS 0d5198ffb9 Refactorization in checkmemoryleak.cpp:
- Fix #347: Added support for vasprintf
- Use %varid% instead of the variable name
2012-04-26 18:56:58 +02:00
PKEuS 5086ae7c31 Refactorizations in CheckMemoryLeakInClass::variable
- Bailout for functions that are not implemented (should fix performance downgrade introduced in fb4709f)
- Jump behind arguments
- Removed unnecessary pop_back operations - container gets destroyed after it.
2012-04-23 15:23:01 +02:00
PKEuS 710fefeef0 Refactorizations:
- Replaced some indendation counters by Token::link() or usage of symbolDatabase
- Use Token::nextArgument() to jump to target parameter
2012-04-21 23:05:37 +02:00
Daniel Marjamäki 8e3f1702fd Reverted 81318b3f to get rid of #3669 false positives 2012-04-10 13:58:59 +02:00