Commit Graph

4684 Commits

Author SHA1 Message Date
Reijo Tomperi 5d5f7085bf Updating year 2012 -> 2013 to .cpp and .h files and man page. 2013-01-01 18:29:08 +02:00
Robert Reif d2e8ab9c86 Fixed #4302 (Member variable not initialized in public delegate constructor) 2013-01-01 09:53:40 +01:00
Edoardo Prezioso 6612952dd4 Use 'simple' matching with normal patterns. 2012-12-31 13:30:06 +01:00
Daniel Marjamäki bf169e0c59 Replaced %name% with %type% 2012-12-31 10:45:37 +01:00
Daniel Marjamäki 4378357d7e Fixed #4372 (Tokenizer misidentifying which function a variable belongs to) 2012-12-29 21:07:41 +01:00
Daniel Marjamäki dde4cc39e5 astyle formatting 2012-12-29 17:13:54 +01:00
Daniel Marjamäki 4d085dd3fd Fixed #4316 (False positive: (constStatement) Redundant code) 2012-12-29 17:13:06 +01:00
Daniel Marjamäki e7aa1ec396 Fixed #4411 (Variable is assigned a value that is never used.) 2012-12-29 12:45:37 +01:00
Daniel Marjamäki 8491df31ca Merge pull request #126 from SimonKagstrom/for-upstream
Misc fixes for the --include= option
2012-12-28 23:58:14 -08:00
Daniel Marjamäki 9af51a75e6 Tokenizer::setVarId: Proper handling of 'void f(struct foobar). Ticket: #4444' 2012-12-29 08:54:39 +01:00
Daniel Marjamäki 38d1b064e8 Symbol database: Add support for unnamed array arguments to functions (#4444) 2012-12-29 08:32:43 +01:00
Robert Reif 07d118dee5 Fixed #4449 (segfault in CheckClass::initializeVarList()) 2012-12-29 08:30:14 +01:00
Thomas Jarosch 1f87c6d669 Fix crash on empty brackets
Relevant parts from the backtrace:
2012-12-28 20:16:51 +01:00
Daniel Marjamäki 1769240e15 Fixed #4022 (false positive: (style) Variable 'sort_entry' is assigned a value that is never used) 2012-12-28 18:18:36 +01:00
Robert Reif 5ba2a300af Symbol database: Improved handling of array arguments (#4444) 2012-12-28 16:28:29 +01:00
Simon Kagstrom 95b51d02c9 path: Add getPathFromFilename (returns the path part of a filename)
E.g.,

  /tmp/a.h -> /tmp/
  a.h ->

etc.
2012-12-28 12:44:26 +01:00
Simon Kagstrom 350f86fb6a preprocessor: Kill commented out code 2012-12-28 12:43:43 +01:00
Simon Kagstrom 1e4288fe2e preprocessor: Don't access empty lists
libc aborts with:

/usr/include/c++/4.4/debug/list:256:error: attempt to access an element in
    an empty container.

Objects involved in the operation:
sequence "this" @ 0x0xbfffe5f0 {
  type = NSt7__debug4listISsSaISsEEE;
}

otherwise.
2012-12-28 12:43:43 +01:00
Daniel Marjamäki de2c133f6a Fixed #4426 (False positive: Unitialized variable warning when comparing addresses) 2012-12-28 12:32:15 +01:00
Daniel Marjamäki 6770cc80be Uninitialized variables: Added debug warning for bailout 2012-12-28 11:42:50 +01:00
Thomas Jarosch 78316f02b6 Fix comment about wrong magic number 2012-12-28 11:31:50 +01:00
Thomas Jarosch 4708be09f5 Fixed #4444 (segmentation fault) 2012-12-28 11:15:18 +01:00
Robert Reif bd2f59bdf0 Fixed #4442 (crash of cppcheck while scanning gcc-testsuite (invalid code)) 2012-12-28 08:36:20 +01:00
Daniel Marjamäki b914466285 Uninitialized variables: fixed false positives by bailing out when variable is conditionally initialized and then there is a conditional return. 2012-12-27 18:45:00 +01:00
Daniel Marjamäki bf9b900c30 Tokenizer::setVarId: Fixed problem with initializer lists (#4436) 2012-12-27 18:15:00 +01:00
Robert Reif a43ae677d7 Fixed #4419 (False positive: Class does not have a constructor) 2012-12-27 17:21:30 +01:00
Robert Reif 3e6d601982 Fixed #4436 (FP: Member variable is not initialized in the constructor. (with two parameters)) 2012-12-27 17:15:38 +01:00
Daniel Marjamäki 7368079949 Fixed Cppcheck self-check message 2012-12-27 17:11:22 +01:00
Daniel Marjamäki 57488db9da Preprocessor: Reduce variable scope 2012-12-27 17:00:59 +01:00
Daniel Marjamäki 0585588fc7 astyle formatting 2012-12-27 16:59:30 +01:00
Simon Kagstrom ef28bde3e4 Fixed #4408 (Force inclusion of files (a la -include /.../ in GCC)) 2012-12-27 16:52:31 +01:00
Daniel Marjamäki 2e0a9c4b33 Fixed #4434 (false positive: (style) Mismatching assignment and comparison, comparison 'pen!=-1' is always true.) 2012-12-27 15:40:00 +01:00
acm4me 7da155c8ba Support for Sun Studio C++ compiler 2012-12-27 11:51:12 +01:00
Daniel Marjamäki bfb82fe3e1 Cppcheck: Show single 'too many configurations' message if --enable=information hasn't been used and there are too many configurations. 2012-12-26 18:35:49 +01:00
Daniel Marjamäki b3301a9ef9 Fixed #4433 (Wrong array size for string with \0) 2012-12-26 12:10:09 +01:00
Robert Reif ce380301fd Fixed #4432 (Crash on parsing PHP interpreter) 2012-12-26 08:29:10 +01:00
Daniel Marjamäki f127d56719 Null pointer: Fixed FP when there are 'return p?p->x:0;' 2012-12-25 14:23:50 +01:00
Daniel Marjamäki f16c30248a Uninitialized variables: fixed FP when there are function calls where type* is converted to unknown_type 2012-12-25 14:05:29 +01:00
Daniel Marjamäki f381058293 Uninitialized variables: fixed FP when there are suspicious function calls where type** is converted to type* 2012-12-25 13:58:15 +01:00
Daniel Marjamäki bcc5a82b1d Uninitialized variables: Fixed FP when using typeof on uninitialized data in return statement 2012-12-25 13:31:54 +01:00
Daniel Marjamäki db123c2c9b Fixed #4431 (FP: Erroneous 'Ineffective call of function empty()' in ?: test) 2012-12-25 12:50:38 +01:00
Daniel Marjamäki 299c1bb208 Uninitialized variables: handle unsimplified labels better 2012-12-25 10:37:21 +01:00
Daniel Marjamäki db2a129557 Tokenizer: Improved handling of '\0' in strings 2012-12-25 08:56:12 +01:00
Daniel Marjamäki 83da4125e3 Uninitialized variables: Better value flow analysis. Fixed false positives. 2012-12-24 19:11:13 +01:00
Daniel Marjamäki 31297cf7d3 Opposite inner conditions: Clean up copy/pasted code 2012-12-24 12:21:48 +01:00
Daniel Marjamäki b39afb2cf9 Revert "Fixed #4419 (False positive: Class does not have a constructor)"
This reverts commit 9a79961b6c.

There is a segmentation fault when checking lib/preprocessor.cpp
2012-12-24 07:46:55 +01:00
Robert Reif 9a79961b6c Fixed #4419 (False positive: Class does not have a constructor) 2012-12-24 06:46:30 +01:00
Daniel Marjamäki 56b7670468 Tokenizer::setVarId: Fixed problem in initializer list when parameter and class member has same name 2012-12-23 19:55:09 +01:00
Daniel Marjamäki 0b4da3d5cd Uninitialized variables: Fixed false positives when variable x is given a nonzero value when variable y is uninitialized. 2012-12-23 16:27:04 +01:00
Daniel Marjamäki 9e58714bb1 Cppcheck: Only show 'Too many configurations' and 'Interrupted checking' information messages when information severity is enabled 2012-12-23 08:23:52 +01:00
Robert Reif dae232015e Fixed #4430 (FP: Member variable is not initialized in the constructor.) 2012-12-23 08:04:44 +01:00
Daniel Marjamäki 47e1a571f7 Tokenizer: Fixed goto problems 2012-12-22 19:28:53 +01:00
Daniel Marjamäki 7f6a10599b Fixed #4262 (Small Request/Suggestion for checks on array size of args (bounty offer)) 2012-12-22 09:23:34 +01:00
Daniel Marjamäki 365a260ddc Fixed #4398 (False negative: out of bounds (for loop)) 2012-12-22 08:00:05 +01:00
Robert Reif 80848c6e0e Fixed #4383 (Improve check: uninitialized member variable not detected when initialization is not proper) 2012-12-21 19:36:45 +01:00
Daniel Marjamäki 2050cd71db Uninitialized variables: Better testing of function handling 2012-12-21 19:32:56 +01:00
Daniel Marjamäki dc6aa92f3b Uninitialized variables: warn about structs in C code 2012-12-21 18:50:38 +01:00
Daniel Marjamäki cf84c211ed Uninitialized variables: Improved handling of function calls 2012-12-21 17:04:15 +01:00
Daniel Marjamäki 415ee977d8 Uninitialized variables : fixed false positives when passing address of pointer to function. 2012-12-21 16:57:49 +01:00
Daniel Marjamäki 7e8019e474 Fixed #4403 (False positive 'Conversion of string literal <string> to bool always evaluates to true.' with BOOST_ASSERT) 2012-12-20 20:48:48 +01:00
Daniel Marjamäki ccdea4dc2b Uninitialized variables: Improved checking of functions 2012-12-20 19:45:30 +01:00
PKEuS d82048f5f5 Fixed compiler error in VS10 2012-12-20 04:03:36 -08:00
Robert Reif bb2a15c140 Symbol database: Better handling of 'using namespace N;'. Ticket: #4412 2012-12-20 06:53:04 +01:00
Daniel Marjamäki 3913fd8398 Fixed #4320 (False positives 'unassignedVariable' and 'uninitvar') 2012-12-18 19:02:30 +01:00
Daniel Marjamäki 1e2fb4f1a4 Unused var: Limit bailout for foreach loops. Only bailout if name contains 'foreach' or 'for_each'. Only bailout variables that are used more than once in the body. Ticket: #4155 2012-12-17 18:19:05 +01:00
Daniel Marjamäki 72ea94bf75 Fixed #4155 (false positive: Variable is assigned a value that is never used (inside BOOST_FOREACH loop)) 2012-12-17 17:07:56 +01:00
Daniel Marjamäki a84d21f271 CheckMemoryLeaksInFunction: Fixed problems with catch and function calls. Ticket: #4405 2012-12-16 18:06:40 +01:00
Daniel Marjamäki bca7927913 AST: generate tree from bottom and upwards 2012-12-16 11:48:19 +01:00
Daniel Marjamäki aad3a041ad AST: Handle function calls 2012-12-16 10:06:55 +01:00
Daniel Marjamäki 1ad9c933ec AST: Improved handling of unary operators 2012-12-16 08:41:04 +01:00
Robert Reif 6732f05b95 Fixed #4404 (Forward declared class cause false style warning about missing constructor) 2012-12-16 07:18:03 +01:00
Daniel Marjamäki fa8e5cd7d8 AST: Simple AST. Not used in the clients. Only part of the testing for now. 2012-12-15 20:21:09 +01:00
Daniel Marjamäki d3f5fd4e59 Tokenizer: Fixed Token::Match pattern 2012-12-10 20:38:07 +01:00
Daniel Marjamäki df03e3a8d2 Fixed #4395 (Wrong simplification of known variables in nested assignment) 2012-12-10 06:08:33 +01:00
Robert Reif 5a7ede2563 Fixed #4391 (False positive: ctor not detected after variable declaration) 2012-12-10 06:01:29 +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 927a6e4794 Obsolete functions: removed 'ctime' warning. The function is obsolete but the message don't point out a good replacement nor where it's documented that this function is obsolete 2012-12-09 09:35:57 +01:00
PKEuS 410c0f98d9 Refactorized CheckObsoleteFunctions:
- Speedup checkobsoletefunctions by using symboldatabase and by not calling SymbolDatabase::findFunctionByToken() for each function call.
-> Benchmark (SQlite amalgamation):
    CheckObsoleteFunctions::runSimplifiedChecks(): 9s -> 0,016s (562%, 4% on entire runtime)
- Fixed false negative when passing function result as parameter
2012-12-08 02:46:30 -08:00
PKEuS 578e582987 Fixed regression #4368. 2012-12-08 00:26:10 -08:00
PKEuS 068c695bd1 Fixed false positive when ternary operator is used: case A&&B?B:A: 2012-12-07 12:44:30 -08:00
PKEuS 0ac4c3baf4 New check: Find suspicious case labels like 'case A||B:' 2012-12-07 12:27:32 -08:00
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
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
Robert Reif 8ccbde117a Fixed #4261 (CheckOther::checkComparisonOfFuncReturningBool using wrong function scope test) 2012-10-08 16:15:07 +02:00
Daniel Marjamäki fefd8529c6 Fixed #4007 (False positive: 'Possible null pointer dereference' when using short-circuit evaluation) 2012-10-07 19:06:49 +02:00
Daniel Marjamäki 6a37942431 Fixed #3935 (False report for accessing array out of bounds after casting to short) 2012-10-07 18:38:05 +02:00
Alexander Mai 3656366c7e Fixed #4257 (False Positive: String literal compared with variable - for non-pointer variable) 2012-10-07 16:26:03 +02:00
Daniel Marjamäki 0115bb8d24 Fixed #4102 (False positive: 'find('=') + 1U' can't be replaced with compare) 2012-10-07 12:43:14 +02:00
Daniel Marjamäki 4c1abde48e Reverted 107b3b44. Write syntax error for 'if MACRO()'. We can't know if MACRO() is supposed to be used in the condition or if it is some annotation that should be removed. Ticket #4171 2012-10-06 19:12:39 +02:00
Edoardo Prezioso e3bbcf501f Fixed #4234 (segmentation fault of cppcheck in Tokenizer::simplifyFlowControl() (invalid code)) 2012-10-06 13:37:44 +02:00
Daniel Marjamäki c2b61030a8 Fixed #4254 (Tokenizer::simplifyIfAssign: varids not preserved) 2012-10-06 12:49:24 +02:00
Daniel Marjamäki 10c11ec9dd more java/c# cleanup 2012-10-03 19:51:09 +02:00
Daniel Marjamäki dbddbe75bf Path: Removed java/c# handling. Thanks amai. 2012-10-03 19:47:14 +02:00
Daniel Marjamäki 1e024a9abc cleanup more java/c# code. Thanks amai for telling me about this. 2012-10-03 19:19:49 +02:00
Daniel Marjamäki 2f069f550f Removed Java/C# handling 2012-10-02 18:44:36 +02:00
Edoardo Prezioso 72666e10d1 Related to previous commit: reduce scope level, remove the now redundant check. 2012-10-02 15:19:29 +02:00
Edoardo Prezioso 60de3e75af CheckOther::checkComparisonOfBoolWithBool,checkComparisonOfFuncReturningBool: use symbolDatabase to check only tokens in executable code. 2012-10-01 15:38:31 +02:00
Daniel Marjamäki 9a462d8a0a Fixed #4225 (False positive: uninitialized variable (assignemnt in ternary expression with cast)) 2012-09-30 18:49:25 +02:00
Daniel Marjamäki a64669b1ec Fixed #4203 (Don't warn about setting NULL value for pointers and not using that value) 2012-09-30 17:22:35 +02:00
Daniel Marjamäki c65ac603e9 Fixed #3837 (False positive: national locale inline asm comments are reported as unsupported) 2012-09-30 09:35:32 +02:00
Daniel Marjamäki 4e1bef5535 AssignIf: better handling of function calls 2012-09-29 19:22:34 +02:00
PKEuS c4b881f844 Refactorizations in tokenize.cpp and testsimplifytokens.cpp:
- Avoid const_cast in testsimplifytokens.cpp
- Removed redundant null-check (VS11 code analysis)
- Fixed MSVC compiler warning
- Replaced some indentation counters
2012-09-29 14:10:41 +02:00
PKEuS 5980eb81d1 Fixed cppcheck message in checkclass.cpp 2012-09-29 12:19:30 +02:00
PKEuS 7a1e64fdd4 Replaced unsafe local isFunction() function by symboldatabase. 2012-09-29 11:32:11 +02:00
PKEuS c17853949d Fixed scope handling problems with CheckOther::checkComparisonOfFuncReturningBool(), removed its experimental status. 2012-09-29 11:23:30 +02:00
Daniel Marjamäki 10aa667648 assignif: Fixed testcase. parse while loops if variable is local and not external. 2012-09-29 10:54:09 +02:00
Daniel Marjamäki b6153a00ee assign-if: Fixed token match 2012-09-29 10:41:34 +02:00
Daniel Marjamäki 12cfdee61b AssignIf: Check into scopes recursively 2012-09-29 10:33:54 +02:00
Daniel Marjamäki 52be4a5925 Disabled checkComparisonOfBoolWithBool since there are false positives. Ticket #2617 2012-09-28 19:11:36 +02:00
Daniel Marjamäki ff4f8b58f3 Disable checkComparisonOfFuncReturningBool check because of false warnings. Ticket #2617 2012-09-28 18:51:10 +02:00
Daniel Marjamäki bb62325ddb AssignIf: Better handling of complex conditions with multiple subconditions 2012-09-28 17:03:16 +02:00
Edoardo Prezioso 7362ca9e8f Fixed #4242 (segmentation fault of cppcheck (invalid code: '<')) 2012-09-28 11:24:35 +02:00
Alexander Mai 074b7781b2 Fixed #4239 (segmentation fault of cppcheck (invalid code)) 2012-09-27 06:35:36 +02:00
Daniel Marjamäki 9f7a0146d0 AssignIf: Detect mistake in such code: 'int x=y&4; if ((x==3)||..' 2012-09-26 20:15:46 +02:00
Mohit Mate 9e297c95f2 Fixed #2617 (improve check: comparing boolean with '<') 2012-09-26 18:18:36 +02:00
Daniel Marjamäki 753942df0c Revert "Fixed #4165 (False positive:(error) Uninitialized variable: here)"
This reverts commit 96b1890797.
2012-09-26 16:15:35 +02:00
Daniel Marjamäki 96b1890797 Fixed #4165 (False positive:(error) Uninitialized variable: here) 2012-09-25 20:45:42 +02:00
Daniel Marjamäki 0ff8105c71 Fixed #4074 (Internal error. Token::Match called with varid 0) 2012-09-24 06:44:51 +02:00
Daniel Marjamäki 990340ba98 Fixed #4072 (False positive: Structure is not initialized in the constructor (1.55)) 2012-09-23 18:29:05 +02:00
Daniel Marjamäki 68240fffc6 Fixed #4228 ((error) Internal error. Token::Match called with varid 0 (multiple declarations in for loop)) 2012-09-23 17:15:39 +02:00
Daniel Marjamäki ec01cc811e Second fix for #4207 (Internal error. Token::Match called with varid 0) 2012-09-23 13:25:28 +02:00
Daniel Marjamäki 865c0205e3 Fixed #4210 (Unmatched suppression warning emitted from disabled check) 2012-09-23 10:56:12 +02:00
Daniel Marjamäki c9c04f9691 Fixed #4038 (FP: possible null pointer dereference) 2012-09-23 09:20:16 +02:00
Daniel Marjamäki 2e3a7db4eb Fixed #4115 (Incorrect uninitialized variable error message with realloc macro) 2012-09-22 18:41:33 +02:00
Daniel Marjamäki 37695d44f3 Fixed #4085 (tinyxml2 false positives) 2012-09-22 16:49:28 +02:00
Daniel Marjamäki a17f37c67d CheckBufferOverrun: Better handling of functions with variable arguments 2012-09-22 16:19:19 +02:00
Daniel Marjamäki d3e990b1e5 Fixed #3987 (False positive: Memory leak reported when throwing/catching) 2012-09-22 10:37:27 +02:00
Daniel Marjamäki 6d928a2ff7 Fixed #4119 (false positive with operator= when implemented in terms of swap) 2012-09-22 08:50:36 +02:00
Daniel Marjamäki a65f427195 Fixed #3836 (False positive: variable not initialized in copy constructor/operator (attached example code) 2012-09-22 08:16:16 +02:00
Daniel Marjamäki 6c25f3662e Tokenizer::simplifyEnum: Don't simplify enums in function heads. Ticket #3953 2012-09-21 16:17:20 +02:00
Edoardo Prezioso 8e1e8525a3 Partial rewrite of Tokenizer::simplifyComma:
skip '= { .. }' where possible;
hence remove '%num% after comma' check because it's redundant now;
replace round braces counter method with faster 'link skip';
if 'endAt' is 'NULL' after finding the ';' token, exit the function;
hence remove redundant 'tok != NULL' check after simplifying 'return' code.
2012-09-20 21:45:16 +02:00
Edoardo Prezioso 406483b618 Fixed valgrind error in #3953 , but there's still the bad enum problem. 2012-09-20 21:07:37 +02:00
Daniel Marjamäki de8e592d00 Class: Show inconclusive warnings about unknown types that are not initialized in copy constructors. Ticket: #3611 2012-09-20 19:16:26 +02:00
Daniel Marjamäki 07db469c06 cleaned up braces 2012-09-20 16:49:26 +02:00
Daniel Marjamäki 7d3e661774 Fixed #3611 (CheckClass: uninitVar and operatorEqVarError false positives (non-copyable members)) 2012-09-20 16:47:01 +02:00
Edoardo Prezioso eb5a61edfe Tokenizer: some changes to the code:
be sure '?:' ternary operation has whitespaces around the operators;
remove useless loop to get the 6 next tokens, use tokAt(6);
add '?1:0' to bool values when doing a sum with them.
remove useless 'enum' pattern checking in code executed after simplifyEnum;
after being sure the 'tok' is a standard type, begin the loop with the token next to it;
it's possible to remove two tokens before the current one without moving this.
2012-09-20 01:07:50 +02:00
Daniel Marjamäki aa3cdc6b6f Fixed #3565 (Variable hides enumerator (attached code example)) 2012-09-19 19:19:13 +02:00
Daniel Marjamäki c3cb6202ed Fixed #4172 (TemplateSimplifier: Handle 'A<&f> x' template instantiation) 2012-09-19 16:10:13 +02:00
Ettl Martin 3905f4ad7d fixed #4169 semgentation fault (invalid code); Applied patch from amai and added a unittest. 2012-09-19 11:03:40 +02:00
Ettl Martin 3f89e38275 fixed #4195 segmentation fault of cppcheck (invalid code); Added a testcase 2012-09-19 10:37:30 +02:00
Daniel Marjamäki 07d2935e81 Fixed #4164 (False positive: (error) Uninitialized variable: min) 2012-09-18 20:55:37 +02:00
Daniel Marjamäki ffd5c82b4f Fixed #4118 (False null-pointer warning when check is indirect) 2012-09-18 19:16:28 +02:00
Daniel Marjamäki 9a7d09086e Fixed #3993 (Resource also reported as memory leak) 2012-09-18 16:20:09 +02:00
Daniel Marjamäki 1f7d9ca22c Fixed #4211 (Tokenizer::simplifyVarDecl: Improved handling of >> in templates) 2012-09-17 19:45:42 +02:00
Daniel Marjamäki 3ff792560f Deactived bad message. Ticket #4154 2012-09-17 18:10:11 +02:00
Daniel Marjamäki 25befccb26 Revert "CheckClass::copyconstructors: Removed check. Because there is unfixed ticket #4154."
This reverts commit 066a1d48fe.
2012-09-17 17:59:35 +02:00
Daniel Marjamäki 066a1d48fe CheckClass::copyconstructors: Removed check. Because there is unfixed ticket #4154. 2012-09-17 16:18:27 +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 5237ed2de9 Message refactorization: checkother.cpp 2012-09-16 19:44:02 +02:00
PKEuS 547d3e94b2 Fixed some sign conversion messages from clang. 2012-09-16 16:41:15 +02:00
Daniel Marjamäki a99515ca91 Fixed #3933 (Negative array index issue (because sizeof struct is assumed to be 100)) 2012-09-16 08:20:43 +02:00
PKEuS 9a624576f4 Revert "CheckOther::clarifyStatement: improved message to show what's the 'bad' and the 'good' expression."
This reverts commit f8591f9004.
2012-09-15 20:19:02 +02:00
Daniel Marjamäki 295ba9cc4f Fixed #2709 (Negative times in --showtime summary) 2012-09-15 19:49:48 +02:00
Daniel Marjamäki 2f7032a0e6 Cppcheck: Removed redundant code. 2012-09-15 16:00:46 +02:00
Daniel Marjamäki 7ec825cd5d Cppcheck: Fixed Cppcheck warning about variable scope 2012-09-15 15:54:52 +02:00
Daniel Marjamäki bd734a9610 Fixed #3684 (Preprocessor: #include handling is searching directories in the wrong order) 2012-09-15 12:53:11 +02:00
Daniel Marjamäki f1ebd99dc2 Fixed #3507 (false positive: comma-separated statements before return in methods) 2012-09-15 11:55:08 +02:00
Daniel Marjamäki 84c0368bfd Fixed #3586 (false positive: uninitvar in argument in namespaced function) 2012-09-15 10:48:17 +02:00
Kamil Dudka b4d78e3d05 Fixed #3651 (Preprocessor: Wrong handling of #elif) 2012-09-15 09:34:41 +02:00
Daniel Marjamäki 329f672334 Preprocessor: Added TODO in code. How can userDefines be empty? It is an inner condition and the outer condition checks that it's not empty. 2012-09-15 08:13:52 +02:00
Daniel Marjamäki a9c1a052b9 CheckAssignIf: Improved checking for bitwise or 2012-09-14 19:13:44 +02:00
Daniel Marjamäki 9f2e1ab98d Fixed #4048 (Tokenizer::simplifyVarDecl: Improve handling of 'a::b const * p = 0;') 2012-09-14 16:46:45 +02:00
PKEuS 929f16d892 Fixed hang on garbage code (#4193) 2012-09-14 15:32:35 +02:00
Daniel Marjamäki 19fdbf0fd0 Fixed #4185 (Incorrect 'Found duplicate if expressions' for strings with high bit set) 2012-09-13 16:44:10 +02:00
Daniel Marjamäki a5d32c2665 astyle formatting 2012-09-13 16:43:07 +02:00
PKEuS e136b59f21 Removed redundant "simplifyTemplates" prefix (information already in class name) from function names in TemplateSimplifier. 2012-09-12 20:46:56 +02:00
PKEuS d28ceff449 Simplified code in templatesimplifier.cpp 2012-09-12 20:41:10 +02:00
Daniel Marjamäki 6ebfbf42e1 Fixed #4191 (wrong syntax error if 'error' substring of stringification) 2012-09-12 16:10:45 +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 64faa780fe Fixed #4087 (div by zero check is invalid for floats) 2012-09-11 16:50:42 +02:00
PKEuS 1863306198 Fixed false negative in checkunusedvar.cpp and reduced code dupliaction. 2012-09-11 14:24:12 +02:00
PKEuS 623ffe23f0 Fixed #4145 2012-09-11 14:14:35 +02:00
PKEuS 50f9dd52ab Used enum instead of string in implementation for '--language='. 2012-09-11 08:53:27 +02:00
PKEuS 77b5175ec3 Support 0B... syntax for binary numbers. 2012-09-11 08:39:01 +02:00
PKEuS 95f4bb3e97 Implemented support for binary numbers (#4113) 2012-09-10 21:13:32 +02:00
PKEuS 5940d77a62 Disabled C++ specific checks and simplifications when checking a C or non-C++ file. 2012-09-10 19:02:32 +02:00
PKEuS 87131f6105 Added new cmdline option --language= (alias of GCC-like -x) to enforce a specific language. Valid values: c, c++, java, c#. (#3994) 2012-09-10 18:51:32 +02:00
PKEuS 88f9e9991d Fixed compiler warning (#4136) 2012-09-10 17:43:19 +02:00
PKEuS ce9f6bdb56 Fixed segfault #4182 2012-09-10 17:33:52 +02:00
Daniel Marjamäki 54f1771938 Fixed #4082 (Maybe false positive: memleak) 2012-09-10 17:27:41 +02:00
PKEuS 3449684137 Fixed usage of _settigns->isEnabled("style") in CheckIO. Added forgotten test cases. 2012-09-10 16:23:00 +02:00
PKEuS e9f13e1547 Fixed false positive #4163 2012-09-10 16:14:24 +02:00
PKEuS 1e5d082251 Moved remaining part of c_str() checking to checkstl.cpp. Fixed false positive #4157. 2012-09-10 15:20:38 +02:00
PKEuS 4e59e55229 Refactorization/Partial rewrite of CheckClass::copyconstructors():
- Reformatted check code and some test cases
- Fixed false positives #4148 (non-copyable/unknown base classes) and #4178 (copy ctor implementation not seen)
- Proper usage of STL containers
- Better support for initializer list
- Rephrased error messages
2012-09-10 13:31:30 +02:00
Daniel Marjamäki d3bdd84d8b Fixed #4175 (segmentation fault of cppcheck) 2012-09-09 18:56:26 +02:00
Daniel Marjamäki cf8ac78069 Fixed test assertion failure caused by me 2012-09-09 18:33:41 +02:00
Daniel Marjamäki 7acb04b44c Tokenizer: improved simplification of numeric calculations 2012-09-09 16:22:39 +02:00
PKEuS d44f10fc01 Fixed createLinks2() on this code: nvwa<(x > y)> 2012-09-09 15:31:23 +02:00
PKEuS a748678636 Removed redundant nullpointer checks in token.cpp 2012-09-09 14:34:07 +02:00
Daniel Marjamäki 511c5a62e7 Fixed #4141 (Crash when parsing divide by zero.) 2012-09-09 12:38:15 +02:00
Daniel Marjamäki 107b3b4401 Fixed #4171 (don't choke when parentheses are missing from macros) 2012-09-09 09:48:07 +02:00
Daniel Marjamäki 0c55d5cfa7 Fixed #4002 (syntax error for 'X( typedef, Y)') 2012-09-09 09:14:46 +02:00
Daniel Marjamäki 69a0062177 Tokenizer: don't crash for 'int'. Ralated with tickets #2978 and #3304 2012-09-08 20:59:25 +02:00
Daniel Marjamäki 853c6522dc Tokenizer::simplifyEnum: Readded refactorings. Tickets 3949,3950,4025,4053 has been solved as far as I see. 2012-09-08 12:42:24 +02:00
PKEuS 78d49ea4b8 Fixed #3732 - properly simplify struct declarations:
- Don't replace "{ {" if they are part of an initialization
- Properly split struct definition, variable declaration and variable initialization.

Used std::stack instead of std::list
2012-09-08 10:51:31 +02:00
Daniel Marjamäki a39b58046f Tokenizer: Improved simplification of 'a?(1):b' 2012-09-08 10:45:00 +02:00
Daniel Marjamäki 2722f53edd Fixed #4142 (false positive (error) Uninitialized variable: b) 2012-09-08 10:15:37 +02:00
Daniel Marjamäki 2ce5cb3075 Tokenizer: Simplified parentheses better in such pattern: 'git merge --squash 4142 operator git merge --squash 4142 (%var%|)) ( %num%|%bool% ) %op%|;|,|)' 2012-09-08 07:01:35 +02:00
Daniel Marjamäki 6b56b4a9d3 Show that inconclusive message is inconclusive 2012-09-07 16:11:15 +02:00
PKEuS e87ebcc602 Added support for std::unique and std::remove_if to CheckStl::uselessCalls(). 2012-09-07 14:23:32 +02:00
PKEuS a4b5824dec New internal check: checkRedundantNextPrevious().
Fixed findings by new internal check
2012-09-07 12:36:40 +02:00
PKEuS e4a693eaab Refactorizations:
- Fixed several findings of CheckInternal.
- Removed some debug code from CheckOther::checkRedundantAssignment().
2012-09-07 11:59:20 +02:00
PKEuS 489df29346 Moved Tokenizer::typeConstToConstType() to Tokenizer::simplifyConst() 2012-09-07 11:41:41 +02:00
Ettl Martin 9a375744a4 fixed a wrong spelled word in comments 2012-09-07 11:34:58 +02:00
PKEuS c2d4afc525 Support default arguments in symboldatabase for arguments without name (#4055) 2012-09-06 20:50:46 +02:00
PKEuS 0c812c5ac3 Throw an InternalError when trying to divide (or modulo) by zero in MathLib. 2012-09-06 20:15:32 +02:00
PKEuS 20f989b6c4 Skip code in brackets in default argument declaration (fixes #4057) 2012-09-06 20:02:53 +02:00
PKEuS 31e7e41098 Fixed and refactorized broken CheckNullPointer::CanFunctionAssignPointer():
- return true if parameter is passed by reference (fixes #4111)
- Use symboldatabase
- Improved handling of inconclusive
2012-09-06 18:33:15 +02:00
Edoardo Prezioso 097d0816d0 Fixed #4150 (new ineffective statement check warning wrong). 2012-09-06 17:48:30 +02:00
PKEuS e2bc381550 Don't shift by a negative value in TemplateSimplifier::simplifyNumericCalculations() 2012-09-06 17:02:20 +02:00
PKEuS a8cdd15738 Fixed false positive #4077. 2012-09-06 16:30:10 +02:00
Daniel Marjamäki 1c7027140a Tokenizer: Improved simplifyRedundantParanthesis 2012-09-06 16:16:29 +02:00
PKEuS 6edec7bdce Fixed false positive #4123. 2012-09-06 16:10:51 +02:00
Arpit Chaudhary 67e40a85e5 Improved check for shifting by negative values and removed false positives 2012-09-05 16:09:40 +02:00
PKEuS 536492d5f0 Applied two suggestions of XhmikosR:
- Added UTF8 signature to VS10 solution
- Prefer prefix operator++ (cppcheck catch)
2012-09-05 15:34:37 +02:00
PKEuS f969530e1f Revert "Fixed #4087" which was committed by accident.
This reverts commit 0bbef8d803.
2012-09-05 13:57:57 +02:00
Nilesh Kumar c7633fc73c Fixed #3645 2012-09-05 13:48:00 +02:00
gaurav kaushik 9ad7dfd5fd Fixed #211 and #214 2012-09-05 12:58:09 +02:00
PKEuS e5b1a6ceb1 Merge branch 'master' of github.com:danmar/cppcheck 2012-09-05 12:18:11 +02:00
Zachary Blair 8546bcc94e Fixed #2029 (new check: free invalid address) 2012-09-04 23:31:23 -07:00
PKEuS 0bbef8d803 Fixed #4087 2012-09-04 21:50:50 +02:00
Daniel Marjamäki 2197b84d78 astyle formatting 2012-09-04 16:29:23 +02:00
PKEuS 8c70778b70 Refactorization: Fixed several messages when self-checking cppcheck 2012-09-04 15:29:51 +02:00
PKEuS 8924e8af43 Fixed #4143: Give correct line numbers in checkunusedvar.cpp 2012-09-04 14:53:24 +02:00
anuraggarg011 913670d254 Fixed #3304 (simple cases) 2012-09-04 13:41:14 +02:00
kbajaj91 be716e81d3 Fixed #4138 - False positive about variable assigned a value that is never
used in loops
2012-09-04 13:06:04 +02:00
Edoardo Prezioso f8591f9004 CheckOther::clarifyStatement: improved message to show what's the 'bad' and the 'good' expression. 2012-09-04 02:07:55 +02:00
Edoardo Prezioso 6fd60eebb0 Tokenizer: added a workaround for #3690 (Support MSVC's 'for each'). 2012-09-03 20:23:53 +02:00
Edoardo Prezioso 6100776847 Tokenizer: remove unneeded initialization of strings explicitely with "". 2012-09-03 20:22:27 +02:00
anuraggarg011 bf11248a09 Fixed #1620 (tokenizer: simplify well known math functions) 2012-09-03 18:51:15 +02:00
anuraggarg011 b156c727b0 Fixed #3939: Support ****foo++; 2012-09-03 17:10:27 +02:00
Ankita Gupta c3a65dca40 Fixed #3793 (improve check: calculation in sizeof) 2012-09-03 15:56:10 +02:00
Edoardo Prezioso 804fbe3f8f Tokenizer::simplifyEmptyNamespaces: remove useless condition.
Token::deleteThis handles the !tok->next situation well.
2012-09-03 14:22:31 +02:00
PKEuS 27cafd495a Don't bailout for noreturn functions in checkRedundantAssignments outside switch. 2012-09-03 12:03:30 +02:00
PKEuS d98ee357d4 Fixed crash #4135 when using Q_DECLARE_METATYPE 2012-09-03 11:30:36 +02:00
PKEuS 2be2738c6e Moved duplicate code into function in CheckOther::checkRedundantAssignment() 2012-09-03 10:46:51 +02:00
Kartik Bajaj ea0cbbcf78 Fixed #1481 2012-09-02 18:50:17 +02:00