Commit Graph

3774 Commits

Author SHA1 Message Date
Daniel Marjamäki 974225626d Fixed #3901 (false positive: (error) Uninitialized variable: temp) 2012-06-19 20:07:39 +02:00
Daniel Marjamäki ce5c38f52c Fixed #3890 (False positive Uninitialized variable on returning default value on a class member) 2012-06-19 20:04:10 +02:00
Kimmo Varis 68c52ddd69 Refactoring information messages.
Currently the information severity messages are outputted as error
messages with Severity::Information. This causes constant confusion
as people think it as mildest error severity (and rightfully so).
When it was meant to be for printing messages about the checking
procedure itself (like missing header files etc).

So I'm adding a new function for the ErrorLogger for printing these
informative messages. This makes clear the distinction of errors
found from the code and messages related to the checking itself.
It also makes it easier for clients to handle these separately.
2012-06-19 00:16:20 +03:00
Edoardo Prezioso 57ade25099 Fixed checkio.cpp warning in #2123. 2012-06-18 13:08:01 +02:00
Daniel Marjamäki 2f280332ef Merge pull request #99 from kimmov/tests-generate-pri
Generate a test file listing with dmake.
2012-06-17 10:49:42 -07:00
Daniel Marjamäki a37c3144ed Fixed #3858 (Throw exception in destructor BUT inside a try-catch shouldn't be reported) 2012-06-17 14:33:18 +02:00
Daniel Marjamäki 62f92fe253 Fixed #3866 (false positive: memory leak (UNLIKELY)) 2012-06-17 07:54:24 +02:00
Daniel Marjamäki 2481b80875 Code cleanup. Removed CheckLeakAutoVar::doubleDeallocationError since the same checking is already done by CheckOther::checkDoubleFree 2012-06-17 07:22:15 +02:00
Zachary Blair fa2bca1e09 Ticket #3876: Improved check by only bailing of loops that contain break or continue 2012-06-16 13:11:09 -07:00
Daniel Marjamäki 2c6c61fb0d Merge pull request #101 from simartin/clang_warn_fix
Get rid of a warning
2012-06-16 08:48:02 -07:00
Daniel Marjamäki 7d59d86ed6 Fixed #3893 (Improve check: Array index out of bounds not detected when down conting) 2012-06-16 17:44:51 +02:00
Simon Martin 459369e3b9 Get rid of a warning 2012-06-16 06:34:18 +02:00
Daniel Marjamäki 89b1b4ea6e Fixed #3892 (False positive: 'if (var >= 0.0) then if (var >= 0.0) always returns true 2012-06-15 16:54:02 +02:00
Daniel Marjamäki f967142436 Fixed #3875 (Static member method called with class name is considered unused) 2012-06-14 22:04:21 +02:00
Daniel Marjamäki 5174f7ff5e Fixed #3723 (Preprocessor evaluation order) 2012-06-14 21:47:03 +02:00
PKEuS 8b294a2d4f Disabled C4512 in VS10 (#3882) 2012-06-14 09:39:31 -07:00
PKEuS 1a6e69a80b Fix for problem: "Too many #ifdef configurations - cppcheck will only check 12 of 12" 2012-06-13 10:50:50 -07:00
Daniel Marjamäki 4b6e1c6946 Fixed #3855 (false positive: (error) Instance of 'locale' object destroyed immediately) 2012-06-13 19:21:20 +02:00
Daniel Marjamäki cc5e06b5d2 Fixed #3861 (uninitialized variables) 2012-06-13 19:09:51 +02:00
August Sodora 90f92250dd Fixed #3618 (segmentation fault of cppcheck) 2012-06-12 21:07:17 +02:00
Daniel Marjamäki 54a66391d8 Fixed #3750 (false positive: C-style pointer casting) 2012-06-12 18:45:31 +02:00
Kimmo Varis db587794c9 Update Makefile. 2012-06-11 22:16:12 +03:00
Daniel Marjamäki 08a3d0737e Memory leaks: Write error message when deallocated pointer is returned 2012-06-11 18:28:31 +02:00
Zachary Blair e2348560e4 Fixed Ticket #3876 (Error (double free) detected that can't possibly happen) 2012-06-10 17:50:31 -07:00
seb777 5b763a9f0a Fixed #3579 (object destroyed immediately:False positive & negative) 2012-06-10 21:52:32 +02:00
PKEuS 4b80e91145 Implemented support for building cppcheck lib into a dll
Updated VS9 solution
New VS10 solution that builds cppcheck into a dll used by cli and testrunner.
Functional changes and advantages of new solution:
- Share code between testrunner and cli; ability to share code with gui as well (not yet implemented)
- Files of /lib are no longer compiled twice (should improve build time on single core machines)
- Added configuration for building with PCRE support
- Executables are build into /bin (/bin/debug in debug mode) folder (Should no longer require rebuild when switching between debug and release)
- Completely x64 compatible (contains also x64-debug configuration now)
2012-06-10 05:19:09 -07:00
Daniel Marjamäki 171f570639 Handle UTF-16 files. Partial fix for ticket #2083 2012-06-10 11:00:27 +02:00
Daniel Marjamäki 905615e991 Fixed #3878 (Sign extension with unsigned char false positive) 2012-06-09 08:43:13 +02:00
PKEuS e191f0d7d4 Fixed test failures in testio caused by my last commit. 2012-06-08 10:35:08 -07:00
PKEuS c463d97386 Refactorization:
- Implemented consistent behaviour of Variable::typeStartToken/typeEndToken: Skip const and static on all variables.
- Simplified patterns containing "static|" or "const|" when matching typeStartToken.
2012-06-08 09:05:02 -07:00
Daniel Marjamäki 69846b2a06 Fixed #3872 ('char variables in bit operations' warning) 2012-06-08 17:24:54 +02:00
Daniel Marjamäki c5da030674 Fixed #3869 (References to items in array result it 'Uninitialized variable' errors) 2012-06-08 16:17:55 +02:00
Daniel Marjamäki 2b3e5abef8 Fixed #3865 (Suspicious condition. The result of find is an iterator, but it is not properly checked.) 2012-06-07 19:33:18 +02:00
PKEuS 7c1b0a7602 Issue useInitializationList message only on variables of class types. 2012-06-06 03:03:51 -07:00
Daniel Marjamäki 3c103e520b Fixed #3854 (false positive: (style) Variable '_S_c_name' is assigned a value that is never used) 2012-06-05 06:37:55 +02:00
August Sodora e146591b5d Fixed #3544 (segmentation fault of cppcheck) 2012-06-02 16:15:12 +02:00
Daniel Marjamäki 0cf2c2b327 Fixed #3862 (Double deallocation does not take throws into account) 2012-06-01 19:08:50 +02:00
Daniel Marjamäki a823d29da3 Fixed #3809 (false positive: memory leak) 2012-06-01 19:01:19 +02:00
Daniel Marjamäki d1b4bea304 Fixed #3807 (False positive: possible null pointer dereference) 2012-05-31 18:41:00 +02:00
Daniel Marjamäki cad2e80897 Memory leak: Fixed unit tests that were broken by mistake by my previous commit 2012-05-30 06:43:30 +02:00
Daniel Marjamäki 27003e72b8 Memory leak: minor updates of new leak checking. fixed condition in parseConfiguration. write info message if configuration has been given. 2012-05-30 06:36:59 +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
Daniel Marjamäki 8d0f315097 Fixed #3851 (False positive memory leak (condition)) 2012-05-29 21:10:19 +02:00
Zachary Blair 2bd171dded Fixed #3794 (New check: Missing break in switch (duplicate bitwise operation)) 2012-05-28 21:19:22 -07:00
Daniel Marjamäki 9b2d60bf42 Merge pull request #97 from simartin/clang_warn_fix
Get rid of a warning
2012-05-26 12:37:04 -07:00
Daniel Marjamäki 92c5cffeb0 Memory leaks: Fixed false positive when allocated pointer is assigned 2012-05-26 21:28:35 +02:00
Daniel Marjamäki b8b16172b8 Memory leaks: Added support for a simple configuration file format. This is not supposed to become the official configuration format, it's just a temporary format that we can use to start with. 2012-05-26 18:10:12 +02:00
Simon Martin cede3fc805 Get rid of a warning 2012-05-26 15:49:40 +02:00
Daniel Marjamäki bd8fb0a6b5 Memory leaks: Added new checking for memory leaks 2012-05-26 08:53:46 +02:00
PKEuS f4bf94ca4f Fixed #3845 2012-05-25 07:28:32 -07:00
PKEuS 79445e52ad Refactorized CheckUninitVar to use SymbolDatabase 2012-05-25 04:40:18 -07: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 e2bab4b6a3 Implemented Function::nestedIn to be able to identify the scope the function belongs to, even if Function::functionScope.functionOf is not available.
Refactorized usage of SymbolDatabase in checkOther:
- Don't copy Function instances in checkExpressionRange
- Simplifications by more accurate usage of information in database
2012-05-24 08:40:43 -07:00
PKEuS 97c4af44ca Refactorizations in checkOther:
- More accurate usage of symbolDatabase to reduce code and false negatives
- Avoided unnecessary construction of pattern string
- Only search for class/struct definition before usage
2012-05-24 06:34:59 -07:00
PKEuS 334fc16f29 Refactorized CheckOther::checkSizeofForArrayParameter: Use symboldatabase to detect arrays. 2012-05-24 00:39:16 -07:00
PKEuS 9ca7f6a8c3 Fixed crashes #3830 and #3832 2012-05-23 01:04:21 -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 26f5f08614 Initialize Function::start when the function is implemented, not when its defined. (Fixes #3826) 2012-05-22 12:30:10 -07:00
Daniel Marjamäki 77e9106ec0 Fixed #3634 (False positive: compareBoolExpressionWithInt when using boost::tuples) 2012-05-22 19:01:21 +02:00
Daniel Marjamäki 5b0551054a varid: better templates handling 2012-05-22 18:58:13 +02:00
Ettl Martin 1fd6d36493 fixed regression with g++-4.6 (Ubuntu Linux, 64 Bit). Moved local struct definition out of function scope. No functional change. 2012-05-22 15:43:40 +02:00
PKEuS a8382ea553 Implemented file pointer usage checking:
- File I/O without positioning function call (#1742)
- Read/Write to a file that was opened for writing/reading (#463)
- Operations on closed file

Old fflushOnInputStream check is now part of the new check.
2012-05-22 05:30:22 -07:00
PKEuS f3f46b4861 Fixed #3820 2012-05-22 02:27:21 -07:00
PKEuS f5ef6f255e Hande try and do in initialization list usage check (#3823) 2012-05-22 01:35:56 -07:00
PKEuS e8dfe2407a Fixed crash in Variable::evaluate (#3825) 2012-05-22 01:29:33 -07:00
Andy Maloney e344653e90 Remove extra semicolon 2012-05-20 11:40:39 -04:00
Daniel Marjamäki aebedfb123 dmake: updated Makefiles 2012-05-20 12:04:47 +02:00
PKEuS b81eafe0dc Splitted CheckIO from CheckOther. 2012-05-20 02:57:07 -07:00
Edoardo Prezioso 892c125ff8 Fixed: lib/checkclass.cpp:538:85: warning: declaration of ‘name’ shadows a member of 'this'. 2012-05-19 21:51:39 +02:00
PKEuS be7b104a8e Added missing checks to CheckClass::classInfo()
Replaced tokAt(1) with next() in checkother.cpp
2012-05-19 01:51:47 -07:00
Andy Maloney 4686294d7e Fix compiler warning about empty for body 2012-05-18 14:00:10 -04:00
Andy Maloney 12c5980c01 Fix compiler warning about initialization order 2012-05-18 13:59:19 -04:00
PKEuS de79a4c84f Fixed initialization list usage according to cppcheck results
Fixed comments mentioning nonexistent parameters
2012-05-18 07:57:11 -07:00
PKEuS e77f348d82 New check: Suggest to use initialization list instead of assignment in constructor. (#489) 2012-05-18 07:54:58 -07:00
PKEuS 77927583f4 Fixed two compiler warnings spotted by edward-san (one of them was a real bug) 2012-05-17 08:29:32 -07:00
PKEuS a9cfe2814a Made some functions const according to cppcheck results 2012-05-17 02:54:17 -07:00
PKEuS 4825f78663 Fixed #2477 and #2669 2012-05-17 02:15:21 -07:00
PKEuS 3f5712bfb8 Fixed false positive "Function can be const" when 'this' is passed to a Memberfunction 2012-05-17 01:49:52 -07:00
PKEuS 4bb2a1b27b Made some functions static or const according to cppcheck results 2012-05-17 01:33:24 -07:00
PKEuS ea601ef2b0 Fixed false positives about const correctness caused by incorrect handling of default arguments 2012-05-17 01:05:36 -07:00
Daniel Marjamäki f803a18d50 Fixed #3749 (false positive: same expression on both sides of operator) 2012-05-17 07:26:57 +02:00
Daniel Marjamäki 505aa6e4cc TestSimplifyTokens::enum29: Fixed crash 2012-05-16 21:39:26 +02:00
PKEuS 6a05ad1cf8 Improved fix for #2698 and added test case 2012-05-16 12:36:05 -07:00
PKEuS 77df633904 Improved handling of function calls in const correctness check: Fixed #2702, #2698, #2729. 2012-05-16 11:57:12 -07:00
Daniel Marjamäki 0bb0fdedc2 Fixed #3747 (False 'boolean result in bitwise' message with 'mask' enums) 2012-05-16 18:48:33 +02:00
Edoardo Prezioso 573256350a Fixed: mathlib.cpp(258): warning C4702: unreachable code. 2012-05-16 15:26:03 +02:00
PKEuS 279b0c59bb Don't set Preprocessor::missingIncludeFlag if missingInclude warning is suppressed (#3487). 2012-05-16 02:59:45 -07:00
PKEuS 0157f937bf Fixed #3760: Added explicit to C++ keyword list in setVarId
Made some constant arrays static
2012-05-16 01:59:52 -07:00
PKEuS e8cd119ebd Improved parsing of functions that accept nullpointers but no uninitialized data (Fixed #3811) 2012-05-16 00:56:39 -07:00
PKEuS 132a95b5f2 Fixed bug in symboldatabase: Don't ignore const or static on variables declared that are declared with both keywords. (Fixes #3805) 2012-05-15 12:03:43 -07:00
Daniel Marjamäki 4ae8e4f382 Tokenizer::setVarId: Minor fix of sizeof handling 2012-05-15 18:40:24 +02:00
Daniel Marjamäki a0e5fad6a9 Fixed #3776 (Tokenizer::setVarId: No varid set when unknown macro is used before variable declaration) 2012-05-15 07:17:31 +02:00
PKEuS 42fd19fb37 Refactorization in checkclass.cpp:
- Improved handling of pointers and constants in constructor checking (-> Fixed #3801)
2012-05-14 12:50:23 -07:00
PKEuS 1dee3b04b9 Bugfixes in SymbolDatabase:
- Constant pointers are now detected as variable declarations
- Probably fixed #3802
2012-05-14 12:47:02 -07:00
Edoardo Prezioso eacf74be8d Changed the order of some structures in order to improve, even if for a bit, their padding. 2012-05-14 20:49:03 +02:00
Daniel Marjamäki fc7f78244e Fixed #3708 (False positive: uninitialized variable (allocation, unknown nonpointer type)) 2012-05-14 18:34:39 +02:00
Daniel Marjamäki 62f9875f90 Fixed #3799 (Bug: Function gets varId) 2012-05-13 07:55:35 +02:00
PKEuS 06a77679d4 Refactorizations:
- Added support for pointers in self assignement check
- Removed redundant for loop in checknullpointer.cpp
- Fixed warning about signed/unsigned mismatch in cppcheck.cpp by making Settings::_maxConfig unsigned
2012-05-11 10:38:19 -07:00
PKEuS 0452b03f53 Refactorizations in SymbolDatabase:
- Moved complete evaluation of variables type into one function executed when the variable is constructed
- Moved SymbolDatabase::ArrayDimensions to Variable::ArrayDimensions
2012-05-11 17:56:47 +02:00
PKEuS 11a296cb02 Fixed #2708: Print message before checking and after checking is interrupted if there are too many preprocessor configurations
Removed redundant suppression check because the same check is done inside reportErr again.
2012-05-09 09:54:43 -07:00