Commit Graph

513 Commits

Author SHA1 Message Date
Daniel Marjamäki b9f4a773b8 Buffer overrun: Added check to detect when size argument to memset is a char constant (#213) 2009-03-25 07:25:10 +01:00
Daniel Marjamäki 9f3634412e simplify tokens (known variable values in conditions) 2009-03-25 07:10:17 +01:00
Gianluca Scacco a66cf8b20f Fixed Ticket #202: Return of the address of an auto-variable 2009-03-24 21:53:46 +01:00
Daniel Marjamäki afcaa30b51 Fixed ticket 216 (False positive: variable scope) 2009-03-24 20:59:56 +01:00
Daniel Marjamäki 6c1af7e5e6 register CheckClass 2009-03-24 20:47:43 +01:00
Daniel Marjamäki 586037ed11 fixed testcase 2009-03-24 20:28:44 +01:00
Daniel Marjamäki da0b571aee Fixed ticket 197 (false positive: condition is always true/false) 2009-03-24 19:49:01 +01:00
Daniel Marjamäki 6580e0eb21 fixed snprintf false positive (#210) 2009-03-24 18:43:39 +01:00
Daniel Marjamäki 65070cc067 Simplify if conditions more.. simplifyIfAssign + simplifyIfNot 2009-03-24 18:23:21 +01:00
Daniel Marjamäki 44c952873e Fixed ticket 205 (False positive: char variable used in bit operation) 2009-03-23 19:04:51 +01:00
Daniel Marjamäki 06776c6ac7 Fixed the testcase TestMemleak::realloc3 2009-03-23 18:34:59 +01:00
Daniel Marjamäki 7905cbc5e7 simplify tokens: move assignment out from condition (Ticket #201) 2009-03-23 18:20:56 +01:00
Daniel Marjamäki a87419f59b Fixed Ticket 199 (The error messages generated by 'unused functions' are wrong) 2009-03-22 18:57:53 +01:00
Daniel Marjamäki 09457194d9 astyle code formatting 2009-03-22 08:23:20 +01:00
Daniel Marjamäki 276c0a7b2f Merge branch 'master' of git@github.com:danmar/cppcheck 2009-03-22 08:20:41 +01:00
Daniel Marjamäki e017d5a079 refactoring - added 'getErrorMessages' to all check classes 2009-03-22 08:20:15 +01:00
Gianluca Scacco abda874944 Refactoring of CheckAutoVariables 2009-03-22 08:01:48 +01:00
Daniel Marjamäki 0a71771c6a improved the Tokenizer::setVarId to handle function parameters better 2009-03-21 21:58:39 +01:00
Daniel Marjamäki 6fc66d3e2c refactoring error messages 2009-03-21 21:33:27 +01:00
Daniel Marjamäki 729b2c1706 Fixed 188 (Return of auto variable address), applied patched submitted by gscacco 2009-03-21 18:36:41 +01:00
Daniel Marjamäki da06c12925 refactoring error messages 2009-03-21 18:31:28 +01:00
Daniel Marjamäki 468ed653e2 refactoring error messages 2009-03-21 17:58:13 +01:00
Daniel Marjamäki aee39ae929 refactoring - handling the stlOutOfBounds error message the new way 2009-03-21 14:20:10 +01:00
Daniel Marjamäki 001cb0a7ec refactoring - added a function getErrorMessages that will be used to get a list of error messages 2009-03-21 14:07:51 +01:00
Daniel Marjamäki bcad5afb26 refactoring - fixed the unit tests 2009-03-21 14:02:58 +01:00
Daniel Marjamäki 170f817a19 refactoring: there are now 2 functions for running checks. 'runChecks' and 'runSimplifiedChecks' 2009-03-21 07:53:23 +01:00
Daniel Marjamäki 0ed425d105 refactoring 2009-03-20 20:21:54 +01:00
Daniel Marjamäki 272d455e2d refactoring: generate error message in the class 2009-03-20 20:09:44 +01:00
Daniel Marjamäki 8e4af409e7 refactoring: Added a function to the Check base class that allows easier error reporting 2009-03-20 19:52:18 +01:00
Daniel Marjamäki ccfdbfca58 improved Token::tokAt to handle negative argument too 2009-03-20 18:50:11 +01:00
Daniel Marjamäki 9f1c3cc535 refactoring the rest of the classes 2009-03-20 18:16:21 +01:00
Daniel Marjamäki 21dff96e7b refactoring checkbufferoverrun 2009-03-20 17:35:53 +01:00
Daniel Marjamäki 5914af4481 refactoring CheckClass 2009-03-20 17:30:24 +01:00
Daniel Marjamäki e6e778e45f refactoring 2009-03-20 17:15:51 +01:00
Daniel Marjamäki 5565be0c74 refactoring: minor cleanup 2009-03-19 21:20:08 +01:00
Daniel Marjamäki d4fdfc0f5a astyle formatting 2009-03-19 20:53:23 +01:00
Daniel Marjamäki dfe867fded added checkautovariables and integrated it into cppcheck 2009-03-19 20:52:18 +01:00
Daniel Marjamäki 16b6a7a605 refactoring: loop through all Check instances and execute the runChecks function 2009-03-19 19:24:13 +01:00
Daniel Marjamäki 47d7ff983f refactoring: removed the changes to the error handling 2009-03-19 18:39:20 +01:00
Daniel Marjamäki a573c62cd5 refactoring: first step - started with checkstl 2009-03-18 22:40:38 +01:00
Daniel Marjamäki f37dd4f143 Fixed ticket 184 (Tokenizer - Simplification: Split up variable declarations) 2009-03-18 20:32:05 +01:00
Reijo Tomperi 2fb4c52728 Fixed tokenizer: "return - 2 ;" --> "return -2 ;" 2009-03-18 20:48:06 +02:00
Reijo Tomperi ca055dc830 Fix ticket #191 (semicolon after #endif stop tokenizing of function)
http://apps.sourceforge.net/trac/cppcheck/ticket/191
2009-03-18 01:10:26 +02:00
Reijo Tomperi 819953006c Astyle fix 2009-03-17 22:00:27 +02:00
Daniel Marjamäki 9c057c707b tokenize negative numbers into a single token 2009-03-17 20:50:06 +01:00
Reijo Tomperi 2a3535c04f Fix ticket #186 (runtime error when checking code that has a namespace)
http://apps.sourceforge.net/trac/cppcheck/ticket/186
2009-03-17 20:16:15 +02:00
Daniel Marjamäki 9fe8ae452a Refactoring the code for the templates handling 2009-03-17 18:55:28 +01:00
Reijo Tomperi b3dd9e699b --debug flag can be used to printout token list (for development purposes) 2009-03-16 23:31:52 +02:00
Reijo Tomperi c413c8d4b3 Fix ticket #179 (preprocessor issues)
http://apps.sourceforge.net/trac/cppcheck/ticket/179
2009-03-16 23:20:55 +02:00
Daniel Marjamäki 0cc7672673 Fixed Ticket #82 (detect buffer overrun; dynamic memory) 2009-03-16 18:11:09 +01:00
Reijo Tomperi 21b687b301 Improved tokenizer to handle '#' better. Previously everything after # was combined into a single token,
now # is considered more like an alphabet, with few exceptions, e.g. "##" tokens.
2009-03-15 23:09:27 +02:00
Daniel Marjamäki a6ad972aad Fix Ticket 180 (Templates: Expanding member functions that are not implemented inline) 2009-03-15 20:03:29 +01:00
Daniel Marjamäki 9b06b22053 templates: replace constructor/destructor names when expanding template classes 2009-03-15 17:07:05 +01:00
Reijo Tomperi ca7870af33 Fix ticket #177 (Tokenizer doesn't add braces around if-scope)
http://apps.sourceforge.net/trac/cppcheck/ticket/177
2009-03-15 14:44:57 +02:00
Reijo Tomperi bb3316a45b Fix ticket #181 (#pragma causes wrong line numbers)
http://apps.sourceforge.net/trac/cppcheck/ticket/181
2009-03-15 14:23:12 +02:00
Reijo Tomperi c385b3e045 Improve creation of link() for Token class. Tokenizer::simplifyTokenList() should now return
code where Token::link() actually works.
2009-03-15 01:39:45 +02:00
Daniel Marjamäki 6eadbaae04 templates: better handling of templates with multiple type arguments 2009-03-14 21:26:32 +01:00
Daniel Marjamäki 75d0e8687b Memory leak: handle allocation in deallocation list 2009-03-14 20:19:36 +01:00
Daniel Marjamäki 02df14ec37 Memory leaks: Refactoring to use Tokenizer::FindClassFunction. Enabled test case, the memory leak is now detected 2009-03-14 18:21:37 +01:00
Daniel Marjamäki 01c39daa13 Merge branch 'ref' 2009-03-13 22:39:47 +01:00
Daniel Marjamäki daa911daeb refactoring: moved 'FindClassFunction' from CheckClass to Tokenizer 2009-03-13 22:28:44 +01:00
Reijo Tomperi 116e940214 Fixed ticket #169 (Add Token::link())
http://apps.sourceforge.net/trac/cppcheck/ticket/169
2009-03-13 23:25:56 +02:00
Reijo Tomperi 3c4704a00c Fix ticket #151 (Handling of namespaces)
http://apps.sourceforge.net/trac/cppcheck/ticket/151
2009-03-13 01:07:05 +02:00
Daniel Marjamäki 4c28882a12 expanding template classes 2009-03-12 22:17:42 +01:00
Daniel Marjamäki f96e2deb1a uninitialized const pointer member variables 2009-03-12 21:33:10 +01:00
Daniel Marjamäki 1514e65464 astyle style fixes 2009-03-11 19:14:45 +01:00
Daniel Marjamäki 77cf2213fe templates: simplify template functions with 1 type argument 2009-03-11 18:50:24 +01:00
Daniel Marjamäki eac29d151c made the Tokenizer::simplifyCasts more generic 2009-03-10 21:26:08 +01:00
Daniel Marjamäki c7c13ce3c1 Fixed ticket 134 (memory leak not detected) caused by wrong checking if code is inside class function or not 2009-03-10 20:44:24 +01:00
Daniel Marjamäki cd54a0ed3b Fixed ticket 147 (Invalid line number for error message) 2009-03-09 20:29:25 +01:00
Daniel Marjamäki f39e117921 removed unused private function CheckSecurity::eraseCheckLoop 2009-03-09 20:09:06 +01:00
Daniel Marjamäki f8cd34198b simplify casts 2009-03-09 19:47:21 +01:00
Vesa Pikki ccfa7ce6ee Merge branch 'WinQt' of git@github.com:danmar/cppcheck into WinQt 2009-03-09 20:00:06 +02:00
Reijo Tomperi de1a786a07 Fix ticket #148 (unable to compile with g++-3.3)
http://apps.sourceforge.net/trac/cppcheck/ticket/148
2009-03-08 20:50:19 +02:00
Daniel Marjamäki ed0c971b1f updated version to 1.30 2009-03-08 16:15:25 +01:00
Reijo Tomperi 765da17132 Astyle fix 2009-03-08 09:49:04 +02:00
Reijo Tomperi 5be85d71a0 Fix ticket #145 (Line numbers are invalid if file is included inside #ifdef)
http://apps.sourceforge.net/trac/cppcheck/ticket/145
2009-03-08 09:45:53 +02:00
unknown bc6e1a74d0 Windows Qt compilation fixes.
FileLister::RecursiveAddFiles failed to compile in Windows when GUI was compiled. Since that method wasn't used in Qt build I ifdeffed it out.

Also removed vcl related code from checkdialog since that was removed from release.
2009-03-07 18:53:50 +02:00
Daniel Marjamäki fe2aee131d Fix ticket #140 (New command line option --auto-dealloc), added documentation 2009-03-07 08:56:12 +01:00
Reijo Tomperi 1ab57390cf Fix ticket #137 (--version would be nice) and also do some cleanup for help texts
http://apps.sourceforge.net/trac/cppcheck/ticket/137
2009-03-06 23:17:42 +02:00
Reijo Tomperi d725f0df58 Fix ticket #139 (Compilation error on building cppcheck version 1.29 with gcc-4.3.2 on Ubuntu 8.10)
http://apps.sourceforge.net/trac/cppcheck/ticket/139
2009-03-06 22:46:32 +02:00
Daniel Marjamäki cc8a6168e7 astyle formatting 2009-03-06 18:13:41 +01:00
Daniel Marjamäki 113b3c1d21 auto-deallocated classes: added command line option for specifying .lst file (http://apps.sourceforge.net/trac/cppcheck/ticket/120) 2009-03-06 17:43:33 +01:00
Daniel Marjamäki d7cd09cb6e added internal support for handling list of classes that are automaticly deallocated 2009-03-06 07:22:07 +01:00
Reijo Tomperi 28475b2986 Fix ticket #135 (Add option to control main() exit value) 2009-03-06 02:03:31 +02:00
Reijo Tomperi 6fcb89f136 Fix segmentation fault that happens with invalid code. 2009-03-05 23:22:00 +02:00
Reijo Tomperi 42a9eb9e53 Fix ticket #133 (Segmentation fault when static_cast is in for loop) 2009-03-05 21:32:02 +02:00
Daniel Marjamäki 0011d059e6 checkbufferoverrun: fixed bug - skip some checks when variable id is unknown (Ticket: 138) 2009-03-05 18:28:59 +01:00
Daniel Marjamäki 4522bcd680 reverted accidental changes committed in [1330] 2009-03-04 17:10:28 +00:00
Daniel Marjamäki 8b7a5dd494 fixed tokenizer problem when reading char constants 2009-03-04 17:02:45 +00:00
Daniel Marjamäki 5c1d4f2703 simplify calculations better 2009-03-04 06:24:03 +00:00
Daniel Marjamäki 547f120ee9 known variables: better handling of ++ and -- 2009-03-04 06:03:51 +00:00
Reijo Tomperi 832275bc37 Fix #132 (False positive returning memcpy()) 2009-03-03 20:39:17 +00:00
Reijo Tomperi 69c23301db Fix ticket Add/Change #125 (the printout of the token list is wrong) 2009-03-03 20:17:23 +00:00
Reijo Tomperi 054518f002 Refactoring: Combined printOut() and stringifyList() in Token class 2009-03-03 19:45:58 +00:00
Daniel Marjamäki 37c889ab30 unused private function: better handling of initialization lists in constructors 2009-03-02 20:40:24 +00:00
Vesa Pikki e629db6818 Now adds directory contents to list of files to check.
Only adds proper (.cpp,.c,.cpp,...) files to the list of files to check.
Modified checkthread to clear results after each file.
2009-03-02 19:56:51 +00:00
Daniel Marjamäki 86050cccdb unused private function: fixed false positive (ticket: 129) 2009-03-02 17:16:02 +00:00
Daniel Marjamäki 87b0314e72 memory leak: fixed issue with reporting wrong location 2009-03-01 20:34:04 +00:00
Reijo Tomperi d4ecddd53c Fixed some compiling warnings by adding more error checking. 2009-03-01 20:08:47 +00:00
Daniel Marjamäki fdaa1af694 removed deprecated flag 'firstMatch' 2009-03-01 20:02:24 +00:00
Reijo Tomperi 015143b56c Copyright fixes 2009-03-01 19:59:13 +00:00
Reijo Tomperi ea30d78405 Fixing compile problem with new gcc 2009-03-01 19:56:27 +00:00
Reijo Tomperi fc8f47145a Copyrights updated 2009-03-01 19:52:33 +00:00
Reijo Tomperi f6848f14ad Fixed another --style problem with our code 2009-03-01 19:38:17 +00:00
Reijo Tomperi 6495912d9a Fixed bug, -j option produced duplicate error messages. 2009-03-01 19:34:32 +00:00
Reijo Tomperi d098b62975 Use reference instead of string copy (fixes some --style warnings from our code) 2009-03-01 19:30:51 +00:00
Daniel Marjamäki 60b3bbdea4 removed the '--vcl' flag from the console app 2009-03-01 19:10:48 +00:00
Daniel Marjamäki c7b068c174 variable id: fixed so that the variable ids are assigned correctly (ticket:126) 2009-03-01 16:37:02 +00:00
Daniel Marjamäki 4e465f7073 variable declarations: don't simplify when declaring and assigning array in the same statement 2009-02-28 20:40:37 +00:00
Daniel Marjamäki c3bbd603c0 variable id: handling 'return' and 'else' better 2009-02-28 20:21:48 +00:00
Daniel Marjamäki 7d9bf491ec sizeof: fixed a problem with 'sizeof(varname)' but there are more to fix with it 2009-02-28 08:34:02 +00:00
Reijo Tomperi 42176f52ca Added Cppcheck::clearFiles() function. 2009-02-27 19:39:50 +00:00
Daniel Marjamäki 6b7b27a2e8 simplify known variable: don't simplify this ';i++;' 2009-02-27 18:25:47 +00:00
Daniel Marjamäki c991aded12 unused functions: fixed false positives 2009-02-27 16:36:37 +00:00
Daniel Marjamäki f4a8bc85f2 simplify tokens: fixed bug when removing redundant parantheses around variable 2009-02-27 06:07:38 +00:00
Daniel Marjamäki c1da4ae57d simplify tokens: remove redundant parantheses around variable.. 'p = (q);' 2009-02-25 19:55:24 +00:00
Daniel Marjamäki 35583293ec memory leak: Fixed a false positive when all is given 2009-02-25 19:20:23 +00:00
Daniel Marjamäki dac1e91013 unused private function: Handle 'embedded' function implementations better 2009-02-25 18:03:17 +00:00
Daniel Marjamäki 4849aaa7ee checkclass: refactoring 2009-02-24 17:50:51 +00:00
Daniel Marjamäki 66c13c7173 reverted [1282] because some changes were committed by mistake 2009-02-24 17:49:43 +00:00
Daniel Marjamäki 8c3e3faa07 checkclass: refactoring 2009-02-24 17:48:11 +00:00
Daniel Marjamäki 159332fde4 sizeof fix. classes and structs are always given the size 100. This removes false positives about mismatching size 2009-02-24 16:30:57 +00:00
Daniel Marjamäki 1e3047b9c2 simplify tokens: simplify known variable value handles ++ and -- better 2009-02-24 16:11:37 +00:00
Daniel Marjamäki d15aea1b0c memory leak: fixed false positive when using 'return strcpy' 2009-02-24 06:23:21 +00:00
Daniel Marjamäki 44a5cecd99 memory leaks: improved handling of --vcl 2009-02-23 19:32:54 +00:00
Reijo Tomperi a7b0c30884 Change -w to -j to make it similar with make and scons. 2009-02-22 18:38:10 +00:00
Kimmo Varis c50493e940 Windows RC file is ANSI file, storing as UTF-8 messes it up. 2009-02-22 14:55:29 +00:00
Reijo Tomperi 033a82d3f2 Members of ErrorLogger::ErrorMessage made public for better access to them. 2009-02-22 11:29:33 +00:00
Reijo Tomperi a64f1d6175 CppCheck::addFile() accepts paths also now. 2009-02-22 11:17:17 +00:00
Daniel Marjamäki d8927e720d constructors: don't warn about missing constructor if class only has static variable members 2009-02-21 13:35:55 +00:00
Daniel Marjamäki 08f76279ed buffer overrun: catch cases when using cin to read to a char array 2009-02-21 12:22:04 +00:00
Daniel Marjamäki 5269e38ae2 security: renamed classes 2009-02-21 12:12:31 +00:00
Daniel Marjamäki b826d2e41b security: Renamed files 2009-02-21 12:07:19 +00:00
Daniel Marjamäki a9009ebf7d TestClass: Added test for uninitialized "mutable int i" 2009-02-21 08:24:57 +00:00
Daniel Marjamäki ed86d924df buffer overrun: dangerous usage of strncpy+strncat 2009-02-20 21:16:07 +00:00
Daniel Marjamäki 15e86db3ed buffer overrun: Added checking of strncat 2009-02-20 21:00:59 +00:00
Daniel Marjamäki 7f94091b9f g++: fixed compiler errors 2009-02-20 19:53:14 +00:00
Reijo Tomperi 61587c42ae Fix ticket #113 (Add support for multi core CPUs and -w parameter to specifify amount of worker threads) 2009-02-20 19:40:42 +00:00
Daniel Marjamäki 439b8c4051 simplify known variables: variable used as array index 2009-02-20 17:27:57 +00:00
Daniel Marjamäki 385be6d0d9 memory leak: Added command line flag '--vcl' that is used to suppress error messages for VCL code 2009-02-20 06:28:18 +00:00
Reijo Tomperi 4fc774deda Multicore cpu support for Linux (currently disabled and compiling produces warnings)
"no errors" output removed.
2009-02-19 22:21:18 +00:00
Daniel Marjamäki efeaac736d security: added simple gui checking 2009-02-19 17:57:27 +00:00
Daniel Marjamäki 4e1f19a366 input validation: added checking 2009-02-19 08:03:14 +00:00
Daniel Marjamäki 2b04c94b95 stl push_back: Added check (invalid iterator) 2009-02-18 19:57:43 +00:00
Daniel Marjamäki f30d7db1e8 activated the Tokenizer::elseif functionality 2009-02-17 20:03:08 +00:00
Daniel Marjamäki 1043b76d31 Added Tokenizer::elseif for breaking up 'else if' into 'else { if ..' 2009-02-17 19:18:26 +00:00
Daniel Marjamäki 4aef89c311 tokenizer: fixed issues related to variable ids
* use setVarId in simplifyTokenList
 * make sure function parameters and variables declared in for example for loops get variable ids
2009-02-16 17:41:33 +00:00
Reijo Tomperi ba28c07f9d astyle fix 2009-02-15 18:47:24 +00:00
Daniel Marjamäki b1982b2041 tokenizer: improved the simplification of '*(var+num)' => 'var[num]' 2009-02-15 14:02:57 +00:00