Commit Graph

4613 Commits

Author SHA1 Message Date
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
Daniel Marjamäki 8236cd4d50 Fixed #3785 (false positive: (style) Variable 'dinv' is assigned a value that is never used) 2012-05-08 12:04:54 -07:00
Daniel Marjamäki dad2fb6db1 Fixed #3737 (Preprocessor: __cplusplus always defined for c++ code) 2012-05-08 11:49:43 -07:00
Daniel Marjamäki 99a29eafc9 Fixed #3691 (Tokenizer::simplifyKnownVariables: continue in switch) 2012-05-07 12:11:23 -07:00
Daniel Marjamäki 2fbd77c5a1 Fixed #3715 (false positive checking a map bounds) 2012-05-07 12:03:33 -07:00
PKEuS db914d7185 Fixed compiler errrors and warnings mentioned in #3783 2012-05-07 06:34:47 -07:00
PKEuS ec00824fd3 Fixed #3357:
- Print "inconclusive" tag in cli
- Fixed inconclusive handling in checkbufferoverrun.cpp
- Merged reportInconclusiveError into reportError by adding an additional parameter "bool inconclusive" which is false per default
2012-05-06 10:37:41 -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 28f6e2f4a9 Resolved cyclic dependency between Tokenizer and TemplateSimplifier 2012-05-06 01:38:55 -07:00
PKEuS f105bf75a6 Refactorizations in ErrorLogger:
- Implemented constructor for ErrorLogger::ErrorMessage that takes a callstack of tokens -> replaced duplicate code in Check and Tokenizer
- Implemented strigify() for ErrorLogger::ErrorMessage::FileLocation to replace two identical implementations of it.
2012-05-06 01:17:15 -07:00
Daniel Marjamäki 58bee0afde Makefile: generated new Makefiles since the Tokenizer has been split up 2012-05-05 18:39:29 +02:00
PKEuS 1a5fbd61d2 Splitted class TokenList from Tokenizer 2012-05-05 09:33:26 -07:00
Ettl Martin 5d088aa99c fixed wrong spelled words in comments. No function change. 2012-05-05 15:21:27 +02:00
Daniel Marjamäki 11614021e8 Fixed #3768 (Tokenizer::setVarId: no varid for 'std::string' parameter after a 'std::string' parameter called 'string') 2012-05-05 09:59:43 +02:00
Daniel Marjamäki 005ce81689 Fixed #3640 (False positive: statement begins with numeric code) 2012-05-04 17:53:47 +02:00
Daniel Marjamäki 119b24e363 Fixed #3756 (False positive: uninitvar in malloc) 2012-05-03 19:10:51 +02:00
PKEuS aec57db9b2 Fixed #3778: Added missing function Function::getArgumentVar 2012-05-03 13:29:41 +02: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
Daniel Marjamäki d5442280b1 Fixed #3597 (Errors in evaluation of chained assignment operators) 2012-05-01 07:06:14 +02:00
PKEuS 8e362ad5f7 Fixed #3771
Stronger testing for false positives in inconclusive checking in checknullpointer.cpp
2012-04-30 12:36:41 +02:00
Edoardo Prezioso 5d6a257c86 Fixed #3770 (Segmentation fault in K&R function parameters simplification) 2012-04-29 12:58:52 +02:00
Daniel Marjamäki 082e6d506b #3744 (Unexpected unused value warning for char ptr types set in switch) 2012-04-28 15:43:42 +02:00
PKEuS a0d92f5ed9 Refactorizations in SymbolDatabase:
- Skip struct keywords in argument list so that Variables declared like "Struct Foo bar" get a type
- Remvoved redundant argument from Function::addArguments
- Set Function::functionScope for global functions
- Replaced some indendation counters by Token::findClosingBracket
2012-04-27 21:51:13 +02:00
Edoardo Prezioso 6fd6f0998b Improvement to 5b8840c6b02bd648dc2b75e60145474ae12f8e67: handle also 'const struct|union' types as template parameters. 2012-04-27 20:51:55 +02:00
Daniel Marjamäki 5b8840c6b0 Fixed #3764 (Tokenizer::setVarId: no varid for templated variables with const/struct/union types) 2012-04-27 18:02:07 +02:00
PKEuS f1511dd795 Fixed #3766 2012-04-27 10:17:07 +02:00
Edoardo Prezioso bc8de44ddd Fixed one of the warnings with GCC: variable shadows a member of Token class. 2012-04-27 02:41:46 +02:00
Ettl Martin bb8342fbb4 fixed misspelled word 'Comparision' --> 'Comparison' 2012-04-26 23:04:55 +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
Daniel Marjamäki df6f88b4fe Fixed #3755 (Tokenizer::setVarId: improve varid inside class for struct/class variables) 2012-04-26 18:38:47 +02:00
PKEuS c3578e88b6 Reverted erroneously committed lines at the end of nullpointer. Sorry for that 2012-04-26 17:55:31 +02:00
PKEuS ddca2e2f85 Added a lot of functions of the C standard library to nullpointer/uninitialized buffer checking. 2012-04-26 17:53:21 +02:00
PKEuS 746beb98bf Added support for delete and delete[] in invalidDeallocation check (fixes #1773) 2012-04-26 16:44:33 +02:00
PKEuS dee5568853 Fix bug in class Token that causes recently added modulo-check to fail. 2012-04-26 16:39:16 +02:00
PKEuS 92737578ac Refactorizations:
- removed unused function CheckOther::concatNames
- Replaced one indendation counter by Token::link() in checkother.cpp
- Forward declaration of Settings in threadexecutor.h
2012-04-26 15:29:39 +02:00
PKEuS 5ac7552e4e New check: Comparision of modulo results that are always true/false. 2012-04-26 15:23:47 +02:00
PKEuS 2a2d76749e Improve check: Check for 64-bit portability issues when returning pointers/integers 2012-04-26 13:39:19 +02:00
PKEuS 30e8e389a7 Fixed #2980 2012-04-26 10:58:35 +02:00
PKEuS 1e708e10d0 Fixed #2875 2012-04-26 10:35:40 +02:00
PKEuS ebf89aa229 Fixed #3725: Associate functions with correct parent scope when definition doesn't directly follow declaration. 2012-04-25 20:52:59 +02:00
PKEuS 31a252b057 Fixed #3746: Issue operatorEqToSelf error only if the operator takes an object of the class as argument. 2012-04-25 20:25:51 +02:00
Daniel Marjamäki f84a4344ae Fixed #3754 (Tokenizer::simplifyKnownVariables: wrong for loop simplification) 2012-04-25 19:23:17 +02:00
Edoardo Prezioso 08ae15e42d Fixed the grammar in some reportError messages in the Tokenizer class, thanks to kimmov's suggestion. 2012-04-25 15:09:46 +02:00
PKEuS dd5e9aa454 Make use of recently implemented Token::type() functionality 2012-04-25 09:56:07 +02:00
Daniel Marjamäki fb6c7f33f0 Fixed #3707 (Uninitialized variable with operator >> and templates) 2012-04-24 19:50:54 +02:00
PKEuS e0a3ca0845 Refactorizations in class Token: changed handling of different types of tokens.
- Replace _isNumber, _isName, _isBoolean attributes by a single _type attribute (enum Token::Type), because not two of the old booleans could be true at the same time.
-> Add support for lots of different other kinds of tokens. (More precise checking of token type possible)
-> Replaced instant checking of type for Operators, etc. by a value calculated at creation time. (Faster checking)
2012-04-23 21:05:26 +02:00
PKEuS 8cbed66089 Changed relationship between templatesimplifier and tokenizer:
- Pass a tokenizer to templatesimplifier to reduce code duplication (Make use of Tokenizer::reportError; remove redundant TemplateSimplifier::addtoken2) and amount of arguments passed to functions

Removed ctor and dtor implementation from TemplateSimplifier: This class shouldn't be instanciated.
2012-04-23 20:45:36 +02:00
Daniel Marjamäki 6ae135124e Tokenizer::setVarId: better handling of initializer lists 2012-04-23 18:26:27 +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
Daniel Marjamäki 706631f527 Fixed #3748 (False positive out of bounds with postincrement) 2012-04-22 12:22:49 +02:00
Daniel Marjamäki d5f6cfcfa8 Tokenizer: Use new setVarId function. Removed the old one. 2012-04-22 11:36:31 +02:00
PKEuS 3d2b5a30fe Implemented generic reportError functions in tokenizer (similar to Check::reportError) to reduce code duplication 2012-04-22 11:28:46 +02:00
Daniel Marjamäki 8c8c9d5e5b Tokenizer::setVarIdNew: don't treat '(sizeof *p)' as a variable declaration 2012-04-22 11:06:56 +02:00
Daniel Marjamäki d63093d9bb Tokenizer::setVarIdNew: Fixed issue found through TestUnusedVar tests 2012-04-22 10:59:58 +02:00
Daniel Marjamäki 871823e9c6 Tokenizer::setVarId: fixed problem for classes with inheritance 2012-04-22 10:38:06 +02:00
Daniel Marjamäki e39b7f1bfd Tokenizer::setVarIdNew: Fixed TestTokenizer::varid38 2012-04-22 10:24:19 +02:00
Daniel Marjamäki e745d971c8 Tokenizer::setVarIdNew: Fixed test case TestTokenizer::varid27 2012-04-22 10:19:29 +02:00
Daniel Marjamäki b4ffb5e0cf Tokenizer::setVarIdNew: Fixed TestTokenizer::varid39 test case 2012-04-22 09:51:00 +02:00
Daniel Marjamäki ed6673a9aa Tokenizer::setVarIdNew: Fixed TestTokenizer::varid44 2012-04-22 09:18:27 +02:00
Daniel Marjamäki 71050bc586 Tokenizer::setVarIdNew: fixed TestTokenizer::varid_in_class2 test case 2012-04-22 08:51:19 +02:00
Ahti Legonkov 79af6f65d7 Fixed #3699 (cppcheck hangs with 100% cpu load on parsing preprocessor code) 2012-04-22 06:49:42 +02:00
Edoardo Prezioso be5a61b794 Fixed ticket #3721 (false positive: syntax error on valid C code ( K&R function style )). 2012-04-22 01:56:40 +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 6d9b4a8032 Tokenizer::setVarIdNew: Fixed TestTokenizer::varid_operator test case 2012-04-21 19:29:24 +02:00
Daniel Marjamäki 1cc256339c Tokenizer::setVarIdNew: Fixed TestTokenizer::varid19 test case 2012-04-21 18:22:18 +02:00
Daniel Marjamäki 42a95c9202 Tokenizer::setVarIdNew: Fixed segfault when using new setVarId on invalid code 2012-04-21 18:02:26 +02:00
Daniel Marjamäki bd60dd46d0 Tokenizer::setVarIdNew: handle special case when there is an unknown macro. Ticket #2638 2012-04-21 17:57:20 +02:00
Daniel Marjamäki b86295fbcd Tokenizer::setVarIdNew: Improved C++ handling. All the TestTokenizer::varidclass?? tests pass now. 2012-04-21 17:25:44 +02:00
Daniel Marjamäki 6071a5afc3 Tokenizer::setVarIdNew: Fixed varidclass9 2012-04-21 13:39:43 +02:00
Daniel Marjamäki 85b470c41b Tokenizer::setVarIdNew: Better C++ handling (varidclass5 and varidclass13) 2012-04-21 13:11:30 +02:00
Daniel Marjamäki 1492d8990f Tokenizer::setVarId: better C++ handling 2012-04-19 20:58:52 +02:00
PKEuS af80344ab7 Refactorizations in checkclass.cpp:
- Removed local isVirtual implementation in checkclass.cpp, use Function::isImplicitlyVirtual instead
- Don't bailout when we see C++-style casts in checkConst
- Don't bailout for this pattern "any << member << any"
- Improved/Fixed some test cases (-> #1305)
2012-04-18 18:51:38 +02:00
PKEuS 6a37c36ee8 Fixed #3741
Removed redundant nullpointer check (cppcheck catch)
2012-04-18 16:35:04 +02:00
PKEuS cb7537418a Make use of Token::findClosingBracket in templatesimplifier.cpp 2012-04-18 16:16:06 +02:00
PKEuS cb064dc20e Implemented generic mechanism for '<'-'>' "linkage" before link() works (Taken from Scope::findClosingBracket, but C++11 right angle bracket support added): Token::findClosingBracket
-> Replaced several indendation-counting mechanisms in tokenize.cpp

Fixed build failure in checkclass.cpp
2012-04-18 16:02:03 +02:00
PKEuS f6fd44910a Refactorizations in SymbolDatabase:
- Replaced Scope::access by a locally stored std::map, because its a temporary status variable that is only necessary when creating the symboldatabase
- Moved SymbolDatabase::argsMatch to Function::argsMatch, because its function specific
- Improved Scope::findClosingBracket: Improved reliability, made it static and faster
2012-04-18 13:00:34 +02:00
PKEuS 1793bf8928 Fixed false positive in stlBoundries check (#3740) 2012-04-18 10:08:59 +02:00
PKEuS c6f6194008 Added Function::isImplicitlyVirtual to symboldatabase.cpp
Made SymbolDatabase::argsMatch static because its possible and necessary for Function::isImplicitlyVirtual
2012-04-17 19:50:44 +02:00
Daniel Marjamäki bb4184ca03 Tokenizer::setVarIdNew: better handling of class variables 2012-04-17 19:06:00 +02:00
PKEuS 8e5949c6ce Added several C++11 algorithms and containers to CheckStl
Added pattern "> %varid%" to CheckStl::stlBoundries()
Fixed message in checkOther (#1320)
2012-04-17 12:54:01 +02:00
PKEuS 82cd022646 Refactorized CheckStl::mismatchingContainersError:
- Improved error message
- Made patterns more generic by using Token::nextArgument()
2012-04-17 12:21:41 +02:00
Ettl Martin 09d41b2f84 ticket 2669: added todo testcase 2012-04-17 00:31:32 +02:00
Reijo Tomperi 4e2946a8d0 Fix spelling error: unecessary unnecessary 2012-04-16 21:33:16 +03:00
PKEuS bac8ed7127 Refactorized stringification of tokens:
- Function that stringifies one token: Token::stringify()
- Functions that stringify a list of tokens: Token::stringifyList()
-- Single and powerful "base" function, used by several "light" functions
Refactorized
- testtokenize.cpp and testsimplifytokens.cpp: Use improved stringification functions instead of several local implementations
- Avoided redundand creation of std::string when using TestTokenizer::tokenizeAndStringify and in cmdlineparser.cpp
2012-04-16 19:51:07 +02:00
Daniel Marjamäki 5ad1840120 Tokenizer::setVarIdNew: Copied code from Tokenizer::setVarIdOld that sets varid in member functions 2012-04-16 19:48:58 +02:00
PKEuS 1c3c94dc67 New simplification: Remove 'extern "C"' from C++ code.
Refactorization in cppcheck.cpp: Catch exception as const reference instead of non-const reference.
2012-04-16 16:25:04 +02:00
PKEuS 8cb904feaa Refactorizations in class Token:
- Added support for < and > in nextArgument()
- Made isStandardType inline by writing its implementation to token.h (like other bool is*() functions)
- Made firstWordEquals return bool instead of integer (only 0 and 1 were returned)
- Use std::string::empty() instead of operator==(""); Use character literals instead of string literals for single characters printed.
2012-04-16 15:28:38 +02:00
PKEuS 66d947675f Refactorizations in tokenize.cpp:
- Removed a few indendation counters
- Removed unnecessary pattern "- >" because this code is simplified to "." before.
- Generalized pattern of simplifyFunctionReturn()
- Simplified removeExeptionSpecification, no longer recursive (-> #3385)
2012-04-16 10:49:09 +02:00
Daniel Marjamäki 8f866c6e4c Tokenizer::setVarIdNew: handle c++ keyword 'using' 2012-04-15 18:29:35 +02:00
Daniel Marjamäki c58d02f146 Tokenizer::setVarIdNew: in C code, allow that variable declaration starts with delete and throw 2012-04-15 18:23:12 +02:00
Daniel Marjamäki ea148173bb TemplateSimplifier: Allow that template parameter starts with :: 2012-04-15 18:15:36 +02:00
Daniel Marjamäki b0dc708b4d Tokenizer::setVarIdNew: variable declarations dont start with NOT/goto/return/delete/etc 2012-04-15 18:02:49 +02:00
Daniel Marjamäki 46bfe27831 Tokenizer::setVarIdNew: Better handling of function calls 2012-04-15 17:44:51 +02:00
Daniel Marjamäki 31f8a71f84 Tokenizer::setVarIdNew: Better handling for catch-exception-by-reference 2012-04-15 17:39:22 +02:00
Daniel Marjamäki 3c1dfc658c Tokenizer::setVarIdNew: use the new setVarId with a few more test cases. Improved setVarId: references in executable scopes must be initialized. 2012-04-15 14:32:47 +02:00
Daniel Marjamäki 27c37896a0 Tokenizer::setVarIdNew : use new setVarId function in TestTokenizer::varidReturn2. 2012-04-15 14:19:17 +02:00
Daniel Marjamäki 95dafd30dd Tokenizer::setVarIdNew : enable more testcases. better handling of unions and struct members. 2012-04-15 13:42:13 +02:00
PKEuS a420a36606 Removed deprecated cmdline options -s, --style, -a, --all, --auto-dealloc, --test-2-pass 2012-04-15 13:10:41 +02:00
Daniel Marjamäki 7669abb170 Tokenizer::setVarId : Starting to rewrite Tokenizer::setVarId. The purpose of the rewrite is to make this function faster. 2012-04-15 11:47:22 +02:00
PKEuS f1692cdefe Set version to "1.55 dev" 2012-04-15 11:40:14 +02:00
Daniel Marjamäki 3ddbcc7fbe 1.54: updated version numbers 2012-04-15 07:23:26 +02:00
Daniel Marjamäki c6ba3ba3ca Fixed #3714 (segmentation fault of cppcheck checking libtiff) 2012-04-14 18:36:19 +02:00
PKEuS 9f054fbb3c Fixed crash when "-rp=" or "--relative-paths=" is given - print Error. 2012-04-14 14:44:15 +02:00
PKEuS 62d5069387 Fixed #3722: Handle associative law correctly for operator* 2012-04-13 11:55:09 +02:00
PKEuS 05a6638468 Removed code that became unnecessary after 7be01da8e9.
Fixed wrong comment in cli/pathmatch.h (doxygen warning)
2012-04-13 11:08:46 +02:00
Edoardo Prezioso 51789d8e20 Fixed ticket #3712 (false positive: syntax error on valid C code ( K&R function style )) 2012-04-13 00:39:40 +02:00
Ettl Martin 7be01da8e9 fixed ticket 3693. Added modulus operator to Mathlib + unittests. Added a test to checkother to ensure the testcase of ticket 3693 does not trigger an error message. 2012-04-12 14:02:09 +02:00
Daniel Marjamäki 8e3f1702fd Reverted 81318b3f to get rid of #3669 false positives 2012-04-10 13:58:59 +02:00
Daniel Marjamäki 23c71daf37 astyle formatting 2012-04-10 13:45:56 +02:00
Daniel Marjamäki c7093ca5d6 Tokenizer: allow that time is measured for certain slow simplifications 2012-04-10 13:45:34 +02:00
Daniel Marjamäki 6bae724cb6 Fixed #3705 (cppcheck crash (null pointer exception)) 2012-04-09 15:06:06 +02:00
Daniel Marjamäki bbdeebafda Fixed #3700 (false positive: (style) Variable 'H' is not assigned a value) 2012-04-09 12:55:26 +02:00
Daniel Marjamäki 26a9a1b571 Fixed #3661 (False positive: unusedPrivateFunction) 2012-04-09 11:19:19 +02:00
PKEuS c12d82aeb9 Fixed false negative in unused functions check when function returns reference
Removed some unnecessary loops
2012-04-09 11:00:31 +02:00
Daniel Marjamäki b8d233f1a2 false poitive - invalid iterator after break 2012-04-09 07:19:39 +02:00
Daniel Marjamäki 66227c4da0 Fixed #3609 (clarifyCondition delivers false positives when using Windows-Traits as a template) 2012-04-08 18:07:11 +02:00
PKEuS 772108374e Removed unused variable CppCheck::_errout. 2012-04-08 14:18:13 +02:00
Daniel Marjamäki 6360afdcfa CheckOther: Use reportInconclusiveError to report inconclusive error 2012-04-08 10:47:01 +02:00
Simon Martin 3ccdd16b01 Avoid clang warning. 2012-04-07 15:36:45 +02:00
PKEuS 7de545f0fe Refactorizations:
- Added forgotten initialization of Settings::_relativePaths
- Some PCRE-Rules specific code hidden behind HAVE_RULES
- Use initialization list in ErrorLogger::ErrorMessage::ErrorMessage() and CppCheck::CppCheck
- Avoided unnecessary copies of std::strings in cppcheck.cpp
- Moved "// Alert only about unique errors"-code to make it work in debugFalsePositive mode
2012-04-06 18:16:59 +02:00
PKEuS 6643e14d3c Avoid copying Settings in CppCheckExecutor 2012-04-06 14:19:26 +02:00
PKEuS 25167b58a9 Implemented #2990: Print relative paths if -rp or --relative-paths is given 2012-04-06 10:49:21 +02:00
PKEuS b0f571b25c Fixed #3383: If there is an empty line between subsequent break statements, only issue a message for inconclusive checking 2012-04-05 10:38:29 +02:00
PKEuS 425cbea6b1 Improvements in checkclass.cpp:
- Generalized CheckClass::noMemset:
-- Checking for all three mem...-functions for all patterns, generalized them so that we need less patterns
-- Use nextArgument() to jump over irrelevant arguments
- Replaced CheckClass::hasDeallocation by CheckClass::hasAllocation:
-- Reduced number of false negatives by returning also true whenever a member variable is allocated (also without previous deallocation)
-- Reduced code duplication
- Removed indendation counter and redundant variable in CheckClass::initializeVarList
2012-04-05 09:43:40 +02:00
Daniel Marjamäki 823fc9ac04 Fixed #3650 (Variable declaration: Doesn't handle template usage well) 2012-04-05 08:53:10 +02:00
Stefan Weil 37b98c2a56 Fix compiler warning
gcc warning:
lib/checkclass.cpp: In member function ‘void CheckClass::checkConst()’:
lib/checkclass.cpp:1197: warning: declaration of ‘name’ shadows a member of 'this'

Rename local variable 'name' to 's'.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2012-04-04 20:39:11 +02:00
PKEuS d6cfbc6483 Improved checks in CheckStl:
- Generalized check for inefficient emptiness check to detect !%var%.size() calls also outside of if and while; detect it also for %var%.size() when linked with && or ||.
Refactorizations in CheckStl:
- Removed an indendation counter and an offset variable
- Reduced distance given to tokAt calls in CheckStl::redundantCondition
- Rearranged code in CheckStl::missingComparison to use more efficient comparision of varIds instead of variable names. Use varId in pattern instead of variable name.
2012-04-04 19:44:57 +02:00
PKEuS bef2caf489 Improved checks in CheckStl:
- Improved message of stlIfStrFind according to discussion on github (77d9ed1877)
- Generalized pattern for substr in CheckStl::uselessCalls; added check for substr calls like ".substr(%any%,0)" which result in an empty string.
2012-04-04 19:40:28 +02:00
Edoardo Prezioso b90d9c8a19 Make 'const' the new variable 'funcName'. 2012-04-03 22:51:56 +02:00
PKEuS 77d9ed1877 Fixed #3162: Check whole condition for suspicious find calls. 2012-04-03 20:59:45 +02:00
Edoardo Prezioso ecc5dea113 Fixed ticket #3703 (false positive: syntax error on valid C-code ( K&R - style )). 2012-04-03 20:12:34 +02:00
Edoardo Prezioso 5d91ef76fe Fixed ticket #3701 (false positive: syntax error on valid C code ( K&R function style ). 2012-04-03 19:49:58 +02:00
PKEuS c1fc7a2218 Improved CheckOther::checkComparisonOfBoolWithInt and CheckOther::checkComparisonOfBoolExpressionWithInt:
- Added support for comparision of bool constant with number constant (-> fixed #1877) and integer variable with boolean expression
- Moved a check from checkComparisonOfBoolWithInt to checkComparisonOfBoolExpressionWithInt
- Generalized some patterns
- Made error message more accurate concnerning the "neither 0 nor 1" part.
- Reduced number of Token::Match calls
2012-04-02 15:45:51 +02:00
PKEuS fc8749e952 Improved nullpointer check:
- Fixed #3673
- Fixed potential issue with constructor calls (like #3697)
- Added support for operator+ on std::string
2012-04-02 12:12:02 +02:00
PKEuS 033e4a2c1f Fixed #3676. 2012-04-02 11:21:04 +02:00
PKEuS 8492685531 Fixed #3697. 2012-04-02 11:02:41 +02:00
Edoardo Prezioso af02908d42 Fixed ticket #3580 (syntax error in multi variable declaration header). 2012-03-31 18:45:29 +02:00
PKEuS 8949464ed6 Fixed another memory leak in executionpath.cpp 2012-03-31 15:03:11 +02:00
Pierre Schweitzer 72c2f400b1 Fix a memory leak and a performance issue in checkExecutionPaths() 2012-03-31 13:14:24 +02:00
Daniel Marjamäki 68e6511c87 Fixed #3532 (false positive : missing constructor) 2012-03-31 11:30:26 +02:00
Daniel Marjamäki 1309825bf1 Merge pull request #91 from HeisSpiter/e46c7eb32033b520374e9df8c13bc8589c0602d0
Handle Rtl memory functions in Tokenizer::simplifyMicrosoftMemoryFunctions()
2012-03-28 09:43:14 -07:00
Daniel Marjamäki e6dc901761 Fixed #3574 (false positive: check sign of unsigned variable (type cast)) 2012-03-28 18:33:34 +02:00
Daniel Marjamäki abcbe2e49f Fixed #3594 (false positive: returning reference to auto variable) 2012-03-28 18:21:06 +02:00
PKEuS 4f1f6e1824 Improved simplification of calculations:
- Use more generic patterns
- Look on operator precedence more consequently
-> Made a TODO test case from a test case that worked previously, because the calculation is simplified so that the problem isn't detected any more.
Changed comment "Coding style checks" to "Checks", because it didn't fit
2012-03-27 21:29:50 +02:00
Pierre Schweitzer e46c7eb320 Add the RTL memory functions for the simplifications on Windows code. 2012-03-27 21:24:46 +02:00
PKEuS b37cf11d20 Refactorizations:
- Increased encapsulation by making some functions private
- Removed redundant function CheckBufferOverrun::ArrayInfo::declare
- Avoided copy of ArrayInfo object
- Removed unnecessary and suspicious "if(sizeof(int) == 4)"
2012-03-27 19:40:39 +02:00
Daniel Marjamäki 01ddfb6f80 Fixed #3534 (Broken support for dollar signs in identifiers) 2012-03-27 19:35:41 +02:00
PKEuS 782cd5d228 Fixed #3687: Don't treat catched variables as local ones. 2012-03-26 21:19:42 +02:00
Daniel Marjamäki c07044b3d3 Fixed #3573 (Preprocessor: handle '!(X)' the same as '!X') 2012-03-26 19:01:45 +02:00
PKEuS 989ac449e4 Made invalidPointerCast message inconclusive for casting from floating point type* to char* (Fixed #3639) 2012-03-25 12:55:39 +02:00
Daniel Marjamäki 4773384ff4 xml: Add attribute 'inconclusive' to the xml (format version 2) 2012-03-25 11:59:30 +02:00
Daniel Marjamäki 1d95416840 astyle formatting 2012-03-25 11:51:59 +02:00
Daniel Marjamäki ca6a93816b Merge pull request #89 from HeisSpiter/master
Merged two checks to get a better one regarding sizeof
2012-03-25 02:38:04 -07:00
PKEuS e4d92055e7 Improved sizeofCalculation check:
- Bailout on expanded macros for conclusive checking
- Support for more operators
- Removed indendation counter
Improved checkSignOfUnsignedVariable:
- Made the patterns more generic
- Improved verbose error message (-> Fixed #3080)
2012-03-25 11:32:00 +02:00
August Sodora fe9d491aae 3619 Check that tok2->next() exists before using 2012-03-25 10:24:29 +02:00
Edoardo Prezioso 28431da0ae Nitpicky style change: use 'for(;;)' construct instead of 'while(true)' in the code. 2012-03-24 21:50:09 +01:00
PKEuS e6bcab7c35 Fixed #3360: "type const* var;" is now recognized as variable declaration. 2012-03-24 15:10:06 +01:00
PKEuS b964551424 Fixed #3252
Make use of std::isupper instead of custom implementation
2012-03-24 13:48:33 +01:00
PKEuS 8c657872d1 Check for unused private functions now handles overloads - removed redundant and less powerful duplicate of CheckClass::isVirtualFunc.
CheckClass::initializerList does now also check copy constructors
Started fix for #3682: use reportInconclusiveError
2012-03-24 10:50:19 +01:00
Daniel Marjamäki 4076c46a33 Merge pull request #88 from leg0/ticket_3675
Fixed ticket #3675.
2012-03-24 00:36:37 -07:00
Pierre Schweitzer 2b5ddb7858 Merge the strncmp & malloc sizeof checks into a more generic test that handles several cases where sizeof is misused, or could be misused 2012-03-23 21:47:13 +01:00
PKEuS e938235385 Store functions which are declared but not implemented in the function list of the containing scope -> Fixed #3679
Refactorizations:
- Simplified some code
- Improved condition in findVariableType to reduce unnecessary comparisions of empty strings.
2012-03-23 17:59:51 +01:00
Ahti Legonkov 780481e82a Fixed ticket #3675. 2012-03-23 01:45:47 +02:00
Daniel Marjamäki d04698df13 Merge pull request #87 from HeisSpiter/master
Fix a bug introduced with a previous commit and add a new check
2012-03-21 13:20:39 -07:00
Pierre Schweitzer ec44967e13 Add a new test to check improper sizeof usage. It's for the moment limited to malloc calls. 2012-03-21 21:13:09 +01:00
PKEuS 002389f836 Fixed #3677
Added forgotten testcase for #3672
2012-03-21 18:40:32 +01:00
Pierre Schweitzer 9d002916f4 Fix line number displayed on leakNoVarr error 2012-03-20 22:28:56 +01:00
Daniel Marjamäki a2351ba44f Fixed #3648 (Internal error: Token::Match called with varid 0) 2012-03-20 19:05:24 +01:00
Daniel Marjamäki d6c8de104c Revert "Fixed #3648 (Internal error: Token::Match called with varid 0)"
This reverts commit 1fa1ddccba.
2012-03-20 19:00:16 +01:00
Daniel Marjamäki 1fa1ddccba Fixed #3648 (Internal error: Token::Match called with varid 0) 2012-03-20 18:58:27 +01:00
PKEuS cb2a754983 Implemented support for C++11 right angle brackets (>>)
Implemented support for linkage between < and > (Information: It is possible that under certain circumstances comparision operators are linked, since its sometimes difficult to separate between them.)
2012-03-19 18:45:47 +01:00
PKEuS 7055526f4a Fixed #3672: bitwise and operator in if/while does no longer confuse setVarId code
Improvements to CheckUnusedVar:
- Improved handling of arrays of struct/class instances
- Differ between addressof and bitwise-and operator
- Made some members private to improve encapsulation
- Replaced some simple patterns by direct function calls
- Removed an unnecessary condition
2012-03-19 17:41:16 +01:00
Pierre Schweitzer 544a1f714e Updated error message about not taking return value from function that returns allocated memory 2012-03-18 13:45:50 +01:00
Daniel Marjamäki 1e125dc017 Fixed #3671 (False positive: Resource leak: fd) 2012-03-18 11:54:09 +01:00
Daniel Marjamäki 29063098bf Fixed #3670 (false positive: Allocation with open never assigned) 2012-03-18 07:49:22 +01:00
PKEuS e3b3b7b62f Refactorizations on buffer overrun check:
- Replaced a few indendation counters by smaller and faster code
- Make use of safer nextArgument() function instead of some local implementations
- Replaced some simple patterns by direct function calls
- Made a strncpy/strncat search pattern more generic
- Replaced offset variable by incrementation of Token* to avoid subsequent calls to tokAt
- Increased data encapsulation in header
2012-03-17 21:55:08 +01:00
PKEuS 3af32b0da2 Refactorizations in tokenizer:
- getSourceFilePath returns a const reference now
- Replaced some simple patterns by string comparisions/direct function calls
- Replaced a few indendation counters by easier code
- Replaced one offset variable by token pointer to avoid subsequent calls to tokAt with the same number
2012-03-17 11:48:40 +01:00
PKEuS 60cc8296c3 Fixed crash in checkmemoryleak.cpp reported by HeisSpiter 2012-03-17 11:34:27 +01:00
PKEuS fb4709f1be Refactorizations in checkmemoryleak:
- Replaced two indendation counters and one variable storage by symboldatabase functions
- Removed zero-element at end of two static arrays
- More accurate algorithm for finding a parameter by varid
- Replaced some simple tokens by direct string comparision
- Made some functions in checkmemoryleak.h private to improve encapsulation
2012-03-16 19:52:18 +01:00
Daniel Marjamäki 2757229064 Fixed #3666 (False positive: Uninitialized variable (taking address)) 2012-03-16 17:28:05 +01:00
PKEuS 0340764726 Improved nullpointer check: Detect dereferences by streams (#410)
Refactorizations:
- Replaced || by %oror% in Token::Match patterns
- Replaced some simple patterns by direct comparisions, replaced Match call with simpleMatch
- Increased data encapsulation by making more members private in CheckNullpointer
2012-03-16 17:24:03 +01:00
PKEuS 4587a1a06c Fixed recently introduced assertion failure in debug mode 2012-03-15 21:06:24 +01:00
PKEuS b6057a1148 Improved CheckOther::checkIncorrectLogicOperator:
- Added a lot of additional pattern
- Rewrote error messages to make them more understandable and better fitting to the situation. (Fixed #3664)
- Cleanup in unit tests
Improved message of static string comparision check
2012-03-15 20:38:28 +01:00
Daniel Marjamäki fc84f55f80 Fixed #3536 (Preprocessor #if fails to correctly compare two #defined values) 2012-03-15 20:04:34 +01:00
Daniel Marjamäki 813a193bb6 Merge pull request #84 from HeisSpiter/master
Fix for bug #3439
2012-03-15 11:37:42 -07:00
Daniel Marjamäki 555e8c6efc Fixed #36221 (Input streams: Wrong token list simplification) 2012-03-15 19:09:36 +01:00
Pierre Schweitzer e9a696f70e Set back getErrorMessages() as private 2012-03-15 18:52:51 +01:00
Pierre Schweitzer f3b1c46c7d Define error messages for --errorlist for CheckMemoryLeakNoVar class 2012-03-14 23:44:04 +01:00
Pierre Schweitzer 81318b3f4a Detect and display an error on leaks due to return of a function that allocates something is ignored.
This fixes #3439
2012-03-14 22:24:43 +01:00
Daniel Marjamäki 45759f6f7d CheckMemoryLeak: report debug warning when variable id is 0. Ticket #3527 2012-03-14 18:54:34 +01:00
Daniel Marjamäki 4f3878eb1e Fixed #3569 (false negative: buffer access out of bounds) 2012-03-13 21:30:03 +01:00
Daniel Marjamäki a9480ca0c1 CheckBufferOverrun: move condition before loop 2012-03-13 21:19:10 +01:00
PKEuS 7cfffc9c9d Improved CheckOther::checkIncorrectLogicOperator:
- Implemented automatic swapping of conditions and operands
- Added several patterns
- Added support for conditions outside of if/while
2012-03-12 19:06:30 +01:00
Daniel Marjamäki a9d56f2738 Tokenizer: simplify known variable value inside conditional block 2012-03-12 17:32:30 +01:00
PKEuS 533db6421f Renamed ID uninitialized member variables in constructors to "uninitMemberVar" to avoid ambiguity (#2715)
Refactorizations:
- Replaced another single-token-pattern
- Replaced a "continue" with a "break" statement, because its safe to assume that only one variable with a specific ID can exist in a scope
2012-03-11 14:29:00 +01:00
PKEuS 6f164de609 Improved static string comparision check: Implemented #3214
Fixed false negative on argument count of fnprintf/snprintf when first variable argument is a string. (#3655)
Uncommented call of virtualDestructorError in getErrorMessages in checkclass.h
Refactorizations:
- Rearranged code in checkother.h to make ordering more consistent and to increase encapsulation of private data
- Replaced some single-token-patterns
2012-03-11 11:01:39 +01:00
Daniel Marjamäki 3f1ab5af9b charvar: dont write warning about char type array index when array is small and the full valid range is accessible with the char type. If there are out of bounds access then, it is not because the type of the variable. 2012-03-10 12:19:28 +01:00
Simon Martin 190cba519d Fixed shadowing warning 2012-03-09 08:06:58 +01:00
August Sodora e0bee0e037 Fixed #3567 (False positives in boolean expressions) 2012-03-07 20:31:23 +01:00
Daniel Marjamäki 680883a6a7 fixed #3649 (False Positive: Uninitialized variable using operator assignment) 2012-03-06 18:51:50 +01:00
PKEuS ef6e381d47 Improved bitwise on boolean check to make it working on more code patterns
Refactorizations in checkother.cpp:
- Make use of symboldabase instead of: indentation counters, manual detection of variable declarations
- Removed some indexing variables to reduce calls to tokAt and the numbers given to this function
- Use tok->nextArgument() to jump to a specific argument
2012-03-03 21:14:20 +01:00
Stefan Weil 2ce5b80599 Fix compilation with HAVE_RULES=yes
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2012-03-01 20:07:00 +01:00
PKEuS 1ef99e2f21 Improved checkautovariables:
- Added support for checking a few more code patterns
- Simplified code by using more information from the symboldatabase
- Moved redundant part of c_str-check to checkstl
Two fixes according to output of pvs studio in testsimplifytokens.cpp
2012-03-01 18:38:20 +01:00
PKEuS c61762f454 Refactorized doAssignement:
- Enhanced performance by directly iterating through the token list instead of index access
- Added more allocation functions
- Simplified code
Replaced avoidable strlen call in cppcheckexecutor.cpp
2012-02-29 20:57:48 +01:00
Daniel Marjamäki db1205cdb3 Preprocessor: better handling of '#if A==1' 2012-02-29 19:08:01 +01:00
Daniel Marjamäki 527d3791e6 Fixed #3596 (memory leak false positive on libedit sources) 2012-02-27 18:55:36 +01:00
Ettl Martin 2ac907b40a fixed compiler warning (gcc-4.6.1) 2012-02-27 14:13:34 +01:00
Ettl Martin 013ef6157d fixed regression 2012-02-26 13:35:35 +01:00
PKEuS 1747813a8b Added check for invalid pointer casts (#1255)
Detect sign extension problems when variable is a reference (#3637)
Refactorizations:
- Tokenizer::getFiles returns a reference instead of a pointer, because its guaranteed that no nullpointer is returned
- Remove signed/unsigned in one step for "%type% signed|unsigned"
- Fixed recently introduced compiler warning in symboldatabase.cpp
2012-02-26 11:56:32 +01:00
Daniel Marjamäki 385c9d341d Fixed #3633 (False positive: struct array not assigned a value) 2012-02-26 08:29:02 +01:00
Edoardo Prezioso 4d3013d43d Improve 'Tokenizer::elseif' code in order to not touch 'else if' inside a macro parenthesis. 2012-02-26 02:50:48 +01:00
Daniel Marjamäki bbfae8e3ae Fixed #3583 (False positive Variable X is assigned a value that is never used) 2012-02-25 12:56:33 +01:00
PKEuS 9431fb1b7e Improved STL checks:
- Added performance checking for .c_str() for return values and function parameters (#1079)
- Added more containers (basic_string, C++11 containers) and more functions to checking (.at, .resize, .reserve, ...)
- Make use of symboldatabase in missingComparision check
2012-02-25 12:43:27 +01:00
PKEuS 9a5f66030c Improved unused private function check:
- Fixed #3628
- Added support for friend
Improved symbol database:
- friend scopes are now set
- Added findScopeByName function
Refactorizations:
- Removed some unnecessary "virtual" keywords
- Removed unnecessary _filename member variable, pass it as argument instead
- Made CppCheck::replaceAll static, since it is independant from a specific CppCheck instance, Pass string to be modified by reference
2012-02-24 20:45:56 +01:00
PKEuS 9f42ce91a1 Refactored STL container usage in CLI.
Pathmatcher masks are converted to lowercase only once when instance is created
2012-02-19 17:22:59 +01:00
Daniel Marjamäki 39b0f1ba95 Fixed #3608 (unreadVariable when variable used in inline assembly) 2012-02-19 16:04:35 +01:00
Daniel Marjamäki 69d03bac34 Fixed #3603 (False Positive: Variable is assigned a value that is never used) 2012-02-19 15:25:46 +01:00
PKEuS b1ff900aaa Some refactorizations 2012-02-18 23:43:51 +01:00
Edoardo Prezioso d7a918e549 Fixed ticket #3616 (segmentation fault of cppcheck). 2012-02-18 17:58:50 +01:00
Daniel Marjamäki a118f82ca7 Tokenizer::simplifyVarDecl: Don't simplify inside parenhteses 2012-02-18 15:05:29 +01:00
PKEuS 4b52df675a Some refactorizations 2012-02-18 14:44:04 +01:00
Daniel Marjamäki 0705dbd34a Tokenizer::simplifyCasts: don't simplify 'f((double)(v1)*v2)' to 'f(*v2)' 2012-02-18 14:26:00 +01:00
PKEuS 2ba2a4e6ae Some refactorizations 2012-02-18 11:55:05 +01:00
Daniel Marjamäki bfb4dd6425 Fixed #3529 (False 'Boolean result is used in bitwise operation' in a template) 2012-02-18 08:51:09 +01:00
Edoardo Prezioso a08dab3776 Fixed warning about order of variable initialisations in Settings constructor. 2012-02-17 21:22:42 +01:00
Edoardo Prezioso 17cd5ec906 Fixed ticket #3604 (cppcheck(1.53) crash). 2012-02-17 21:14:38 +01:00
PKEuS 485e836535 Refactorizations in MathLib.
Fixed recently introduced bug on floating point numbers with multiple preceding zeros (for example 004.123)
2012-02-17 19:54:53 +01:00
PKEuS 8ea5df62c4 - Improved support for numbers in code:
-- Use MathLib::toLongNumber for conversion in tokenizer (Fix #3610)
-- Handle octal numbers in tokenizer
- Refactorizations in MathLib::toLongNumber and Settings
2012-02-17 15:47:08 +01:00
Zachary Blair 9d75641ef8 Fixed #3598 (false positive: (error) Memory pointed to by 'a' is freed twice.) 2012-02-16 21:03:38 -08:00
Ettl Martin d8c24c3afc fixed wrong spelled word. 2012-02-15 22:57:20 +01:00
Daniel Marjamäki 04e4b5d14d lib: fix for my previous commit. If there are no dependencies then don't insert dependencies 2012-02-15 08:13:42 +01:00
Daniel Marjamäki 8f3d511871 lib: allow that file dependencies are taken from Cppcheck after a check 2012-02-15 08:08:28 +01:00
PKEuS 2e13a51d08 Fixed #3591 2012-02-13 19:46:45 +01:00
PKEuS df0cb89a40 Fixed compiler error 2012-02-13 18:48:44 +01:00
PKEuS bb319c1c96 Improved Tokens and Tokenizer:
- Better handling of deleteThis() as last element of token list
- Code simplified
2012-02-13 17:44:08 +01:00
Daniel Marjamäki da8abeb63c Fixed #3584 (2 internal errors : Token::Match called with varid 0) 2012-02-12 17:30:47 +01:00
Erik Lax f1dbd1a89a Fixed #3518 (False negative: Possible null pointer dereference (in the same condition)) 2012-02-11 16:15:38 +01:00
PKEuS 42f418db54 - Improved nullpointer check: Fixed #1171
- Improved accuracy of function analysis in symboldatabase
- Code cleanups
2012-02-11 12:26:48 +01:00
Daniel Marjamäki c33dbb80fb 1.53: Updated version info 2012-02-11 08:17:07 +01:00
Daniel Marjamäki 4511d0fe5f fixed cppcheck inconclusive warning, possible null pointer dereference otherwise condition is redundant 2012-02-11 08:07:19 +01:00
Daniel Marjamäki bbb707c460 Fixed #3587 (Wrong tokenizer simplification - variable assigned by operator>>) 2012-02-07 08:05:50 +01:00
Daniel Marjamäki 47c7e346aa Uninitialized variables: Another fix for false positives when it's known that inner conditions are true 2012-02-06 19:26:28 +01:00
Daniel Marjamäki d6a887e1f9 Uninitialized variables: Fixed false positives when goto is simplified and inner condition is known to be true/false 2012-02-06 07:32:29 +01:00
Daniel Marjamaki fbb5ebe3c6 Fixed #3577 (Preprocessor: Defines given on command line are not used in the code) 2012-02-05 20:48:28 +01:00
Zachary Blair 8f827aa65f FIxed #3581 (double free false positive when exception rethrown) 2012-02-04 11:24:40 -08:00
PKEuS d5c2c7db88 - Moved checkCatchExceptionByValue from CheckOther to CheckExceptionSafety
- Fixed false positive: throw outerCatchVar; in inner catch is now correctly handled
- Added eTry and eCatch to Scope::isLocal -> Scopes inside catch are now detected by symbol database
2012-02-02 16:17:42 +01:00
Daniel Marjamäki 2be85e9d37 Fixed #3538 (false positive caused by bad tokenizer simplification) 2012-02-01 21:13:26 +01:00
Daniel Marjamäki 036b2a84bf Fixed #3570 (False Postive for 'nullPointer' check) 2012-02-01 20:38:47 +01:00
Edoardo Prezioso f9ade9562c Fixed ticket #3572 (segmentation fault). 2012-01-31 22:32:28 +01:00
Edoardo Prezioso bc034095f1 Fixed ticket #3543 (segmentation fault of cppcheck). 2012-01-31 19:34:55 +01:00
Edoardo Prezioso 66e1761ffe Fixed ticket #3571 (segmentation fault of cppcheck while scanning gcc-testsuite). 2012-01-31 18:42:19 +01:00
PKEuS 22c1ce8a68 Fixes for #3480 and #3568. 2012-01-31 15:49:34 +01:00
Edoardo Prezioso 9f81b48dc1 Fixed ticket #3558 (Tokenizer: improve simplifyVarDecl to take count of undefined size VLA's). 2012-01-30 23:41:43 +01:00
Edoardo Prezioso 0fd7504295 Related to ticket #3560 (conditional pointer user): remove also dead code in the lower scope if the actual scope isn't special. 2012-01-30 21:43:23 +01:00
Edoardo Prezioso 11e724df46 Tokenizer::simplifyTypedef: some optimizations on new code. 2012-01-30 17:08:35 +01:00
Edoardo Prezioso 7cd36f44b6 Tokenizer::simplifyTypedef: 'tokAt(offset)=>tokOffset': finished. 2012-01-30 16:38:04 +01:00
Edoardo Prezioso 67d095a10e Tokenizer::simplifyTypedef: 'tokAt(offset)=>tokOffset': work in progress.. 2012-01-30 16:20:15 +01:00
Edoardo Prezioso 7c596a2b90 Tokenizer::simplifyTypedef: 'tokAt(offset)=>tokOffset': work in progress.. 2012-01-30 16:18:42 +01:00
Edoardo Prezioso 187c463475 Tokenizer::simplifyTypedef: 'tokAt(offset)=>tokOffset': work in progress.. 2012-01-30 16:17:57 +01:00
Edoardo Prezioso b366bf69ad Tokenizer::simplifyTypedef: 'tokAt(offset)=>tokOffset': work in progress.. 2012-01-30 16:16:08 +01:00
Edoardo Prezioso fa077ede94 Tokenizer::simplifyTypedef: 'tokAt(offset)=>tokOffset': work in progress.. 2012-01-30 15:08:01 +01:00
Edoardo Prezioso 9438d1c2d0 Tokenizer::simplifyTypedef: 'tokAt(offset)=>tokOffset': work in progress.. 2012-01-30 15:04:41 +01:00
Edoardo Prezioso fe3fd1a073 Tokenizer::simplifyTypedef: redundant assignment to 'offset'. 2012-01-30 13:33:27 +01:00
Edoardo Prezioso 5a1585dcfb Tokenizer::simplifyTypedef: 'tokAt(offset)=>tokOffset': work in progress.. 2012-01-30 13:24:31 +01:00
Edoardo Prezioso d9e9c0aceb Tokenizer::simplifyTypedef: 'tokAt(offset)=>tokOffset': in progress.. 2012-01-30 13:15:25 +01:00
Edoardo Prezioso 017f0090fa Tokenizer::simplifyTypedef: 'tokAt(offset)=>tokOffset': begin conversion. 2012-01-30 13:10:50 +01:00
Edoardo Prezioso e530d770e1 Tokenizer::simplifyTypedef: to be sure there are no problems, promote to 'int' the variable 'offset'. 2012-01-30 13:04:10 +01:00
Edoardo Prezioso a93af0dba6 Tokenizer:: Use 'link' instead of 'parens' variable. 2012-01-30 12:22:37 +01:00
Daniel Marjamäki 9df6088ddd Revert "really fix #3527 (Internal error. Token::Match called with varid 0. Please report this to Cppcheck developers)"
This reverts commit a37031944e.

I don't want this hard coding of macro names. Feel free to come with a more generic solution if you want.
2012-01-30 06:15:41 +01:00
Robert Reif 415aaca6dd Merge branch 'master' of git://github.com/danmar/cppcheck 2012-01-28 20:59:51 -05:00
Robert Reif a37031944e really fix #3527 (Internal error. Token::Match called with varid 0. Please report this to Cppcheck developers) 2012-01-28 20:58:51 -05:00
Edoardo Prezioso 697af4f7be Improve 'CheckMemoryLeakInClass::check'. 2012-01-28 23:24:00 +01:00
Edoardo Prezioso fa77f98b1c Tokenizer: it's possible to set null lower bound for eraseDeadCode when used inside simplifyFlowControl.
Remove now unused 'beginindent' and moved 'goto' simplification together with 'return' group.
2012-01-28 21:37:30 +01:00
Edoardo Prezioso bb703f4d0b Fixed: (warning) Found simple pattern inside Token::Match() call. 2012-01-28 20:31:12 +01:00
PKEuS 91a01a0a0d - checkUnsignedDivision checks for variable/variable (inconclusive). General bailout for if-statements.
- Make use of recently implemented symboldatabase functions (catch-support, reference-support)
- Other refactorizations
2012-01-28 12:32:28 +01:00
Daniel Marjamäki 46b8dc5e16 Fixed #3527 (Internal error. Token::Match called with varid 0. Please report this to Cppcheck developers) 2012-01-28 10:00:41 +01:00
Daniel Marjamäki 01f6bbda62 Null pointers: fixed false positive when '?' is used in return statement. Ticket: #3560 2012-01-28 08:06:03 +01:00
Robert Reif 42afd2d63a fix #3561 (SymbolDatabase: throw foo; creates a variable with type throw) 2012-01-27 19:24:01 -05:00
Edoardo Prezioso 8289e2428d Tokenizer: Stylish change to condition. 2012-01-27 17:12:28 +01:00
Edoardo Prezioso 0dd4b9ad3a Temporary workaround to ticket #3459 (Simplify goto before loop) :
don't simplify code which contains the label pointed by 'goto'.
2012-01-27 16:56:12 +01:00
Edoardo Prezioso 6314d04a04 Tokenizer: Add 'BOOST_FOREACH' pattern where it was missing. 2012-01-27 16:47:26 +01:00
Edoardo Prezioso ca8e8d26c7 Tokenizer: extract realloc simplification and simplify also when each argument is done by more than one token.
Restyling of a comment in tokenize.h.
2012-01-27 13:56:06 +01:00
Edoardo Prezioso 421ae9df03 simplifyCondition: handle also '( a || true || b)' -> '(true)' and '( a && false && b)' -> '(false)'.
Clarify a comment about previous commit.
2012-01-26 23:14:44 +01:00
Edoardo Prezioso 0f1f3c0f5f Tokenizer::removeRedundantCondition: refactoring due to various reasons.
1) Remove the dead code with 'eraseDeadCode', not with 'eraseTokens' because of the possible presence of labels.
2) It's impossible that in tokenizer there is pattern like 'if (true|false) {code;} else if (cond) {code_cond;}' because the function 'Tokenizer::elseif' adds '{' between 'else' and 'if', hence a code path is redundant, so it's removed from code.
2012-01-26 22:32:11 +01:00
Edoardo Prezioso b6763313c5 Tokenizer::simplifyQuestionMark: use links instead of indentation level number. 2012-01-26 17:55:22 +01:00
Edoardo Prezioso 6e164ae7ed Fixed ticket #3557 (Tokenizer: simplification of '[]' doesn't work well):
extract undefined size array simplification and handle multiple arrays and combos between pointers and arrays, don't handle the definitions as arguments of function.
2012-01-26 17:25:52 +01:00
PKEuS 6906001366 Added support for references to symboldatabase 2012-01-26 17:04:25 +01:00
PKEuS 5c2af0b2e3 - initialising std::string with 0 in initialisation list is partially detected in nullpointer check (#3520)
- executionpath checking makes use of symboldatabase
- CheckExceptionSafety::checkRethrowCopy makes use of symboldatabase
2012-01-26 16:50:59 +01:00
Edoardo Prezioso f428a29d8e Improve simplifyReturnStrncat when each argument is not composed by one token. 2012-01-26 16:09:32 +01:00
Edoardo Prezioso 20372eecfa Fixed gcc warning: variable which shadows a member of 'this'. 2012-01-26 15:20:20 +01:00
Edoardo Prezioso b6a0896ce6 Change 'simplifyReturn' to 'simplifyReturnStrncat' because it's not clear what this function does. 2012-01-26 11:49:08 +01:00
Robert Reif 4d56395504 symbol database: add simple try/catch tests 2012-01-25 22:48:18 -05:00
Robert Reif 6b0aff487f symbol database: add preliminary support for throw/catch block scopes. Just like the rest of cppcheck, ... is not handled properly for variables. Deep namespaces are also not handled properly yet. This is not an issue because this new capability is not used by any checks so it should be harmless. 2012-01-25 22:05:29 -05:00
PKEuS 42a75692d4 Improved nullpointer check:
- More accurate checking for dereferences and non-dereferences
- improved checking for nullpointer dereferences after return statement
- Supports pointer dereferences by std::string
- Code optimization/refactorization
2012-01-25 15:16:22 +01:00
Zachary Blair 589a2461bd Fixed ticket #3550 (false positive: (error) Memory pointed to by 'pxpm' is freed twice) 2012-01-24 22:43:44 -08:00
Robert Reif b6afa8a025 symbol database: add missing variable flag debug printing 2012-01-24 20:45:38 -05:00
Daniel Marjamäki 8e2c40b4b3 Fixed #3323 (#undef needs different handling) 2012-01-24 07:43:26 +01:00
Edoardo Prezioso 5953ed7318 Fixed ticket #3528 (Tokenizer: improve simplifyFunctionParameters to take count of square brackets) 2012-01-23 16:10:15 +01:00
Daniel Marjamäki 9f139cf414 Fixed #3509 (FP: Variable 'itemList' is not assigned a value, when << operator is used) 2012-01-23 08:02:59 +01:00
Daniel Marjamäki 9eb1a5864b Fixed #3502 (segmentation fault of cppcheck (struct{x y:};)) 2012-01-23 07:39:31 +01:00
Robert Reif e39b70c1be symbol database: add missing endl in debug dump 2012-01-22 22:32:53 -05:00
Daniel Marjamäki f81557da50 Fixed #3508 (Symbol database: mixing up constructors and destructors) 2012-01-22 19:48:36 +01:00
Edoardo Prezioso 6cac600d37 Token::replace: Little style change. 2012-01-22 00:03:33 +01:00
Edoardo Prezioso 3a2ba173ac Token::move|replace: update progressValues correctly. 2012-01-21 21:06:30 +01:00
Daniel Marjamäki b8faee9d30 Fixed #3497 (False positive: Uninitialized variable) 2012-01-21 20:42:41 +01:00
PKEuS 36479499e7 - Solved FIXME: Made detection of code that is no pointer-dereference more robust, uncommented code (checknullpointer.cpp)
- Removed more indendation level counters
- Make use of symbol database more often
- Other refactorizations
2012-01-21 19:55:32 +01:00
PKEuS 87e19d2552 Refactorized check for dead pointers after throw:
- Less bailouts for inconclusive checking
- Support for static variables
- Changed severity to warning (error is not certain)
2012-01-21 19:11:06 +01:00
Edoardo Prezioso b0dac2fa2e Tokenizer::copyTokens: add optional parameter which preserve the line number differences between tokens to be copied. 2012-01-21 17:18:16 +01:00
Ahti Legonkov 78461093f0 Fixed #3531 (When macro definition contains parenthesis, the #defined symbol does not get #defined.) 2012-01-21 12:51:54 +01:00
PKEuS 96ae010e48 - Correctly set Scope::function variable in symboldatabase
- Refactorizations
- Fixed some cppcheck warnings
2012-01-21 10:08:09 +01:00
Zachary Blair 0415444e28 Merge branch 'master' of github.com:danmar/cppcheck 2012-01-19 23:02:33 -08:00
Zachary Blair b89adff9fd Fixed Ticket #3300 (false negative: doublefree of pointer) 2012-01-19 22:59:54 -08:00
seb777 9be2d1cc62 It is a good practice to clear container after deleted all the items 2012-01-19 12:41:14 +01:00
Daniel Marjamäki 525e7fba20 Fixed #3490 (False positive: sscanf with %c) 2012-01-18 23:57:08 +01:00
Stefan Weil 7607e4c68d Fixed #3519 (Wrong line number in warning charBitOpError) 2012-01-18 13:09:46 +01:00
seb777 0be8af5214 Fix ticket #3530 (Add some windows data types to tokenizer) 2012-01-18 12:57:41 +01:00
Edoardo Prezioso 9019190a37 Tokenizer: various improvements to code. 2012-01-17 11:51:11 +01:00
Edoardo Prezioso 40739eb3fb Reverted some changes in commits 4b05c3e19f and 4b08b13845. 2012-01-16 11:44:31 +01:00
Edoardo Prezioso 4b05c3e19f Tokenizer::simplifyIfAddBraces: improve comments; handle independently 'a = { .. };'; reduce use of 'Token::(simple)Match' functions. 2012-01-15 19:53:11 +01:00
Edoardo Prezioso 4b08b13845 Tokenizer: reduce usage of Token::Match in some cases. 2012-01-15 15:00:52 +01:00
Edoardo Prezioso 963f6ce3ef Tokenizer: report syntaxError if there's nothing after 'if|for|while ()' and if there's nothing inside round brackets;
TestTokenizer: change test cases accordingly;
TestSimplifyTokens: ditto.
2012-01-15 14:50:01 +01:00
Daniel Marjamäki a6d96f5b72 Fixed #3496 (false positive: syntax error) 2012-01-15 14:33:53 +01:00
PKEuS 461565c50a Fixed #3517 and #3513 2012-01-15 12:32:02 +01:00
PKEuS c294b15360 Removed more indendation counters. 2012-01-15 12:31:49 +01:00
Daniel Marjamäki d891d1ce5d Fixed segfault in TestTokenizer::cpp0xtemplate3 2012-01-15 12:14:47 +01:00
Daniel Marjamäki 7e3735988d TemplateSimplifier : Fixed bug in recent commit. 2012-01-15 11:58:07 +01:00
Edoardo Prezioso 4399fca769 Code style: Use 'linkAt' instead of 'tokAt(..)->link'. 2012-01-14 15:21:45 +01:00
Reijo Tomperi dd18f595b1 Fix #3516 (inaccurate warning: "An unsigned variable will always be positive" (unsigned n; if (n >=0);))
http://sourceforge.net/apps/trac/cppcheck/ticket/3516
2012-01-14 12:50:09 +02:00
Edoardo Prezioso 6a248c35b5 Fixed ticket #3512 (segmentation fault of cppcheck ( 1 *p = const)) 2012-01-14 00:43:58 +01:00
Edoardo Prezioso 37f3aa1528 Fixed ticket #3486 (segmentation fault of cppcheck) 2012-01-13 23:53:53 +01:00
Daniel Marjamäki 0648b3ed5e Fixed #3504 (segmentation fault of cppcheck) 2012-01-13 07:57:12 +01:00
Daniel Marjamäki 47716ee4ca Fixed #3497 (False positive: Uninitialized variable) 2012-01-13 07:26:56 +01:00
seb777 8754caa36d Fix ticket #3483 (POSIX.1-2008 - obsolete functions)
From POSIX.1-2008 specification (see http://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_xsh_chap01.html#tag_22_01_01_04):
- remove obsolete functions ctime, asctime, rand, tmpnam (non reentrant functions check)
- add obsolete base functions (obsolete functions check):
 - rand_r
 - tmpnam, tmpnam_r
 - utime
 - asctime, asctime_r
 - ctime, ctime_r
- update unit tests (non reentrant function)
- update messages (cosmetic) (obsolete functions check)
2012-01-12 22:28:12 +01:00
Robert Reif 6f3807d915 add some more windows types 2012-01-10 21:55:24 -05:00
Reijo Tomperi be7691c7b4 Refactoring: Move rest of the template simplification into TemplateSimplifier
simplifyCalculations() was temporarily moved into TemplateSimplifier also, it should be moved to a better place.
2012-01-09 21:33:11 +02:00
Reijo Tomperi 756b8762ab Catch InternalError by reference instead of creating a copy of it. 2012-01-09 18:30:36 +02:00
Edoardo Prezioso 2dd53ec966 Fixed ticket #3485 (segmentation fault of cppcheck ( {a:1;}; )) 2012-01-09 16:24:11 +01:00
Edoardo Prezioso 54f54761b4 Fixed ticket #3482 (segmentation fault of cppcheck ( switch(){case} )) 2012-01-09 14:37:20 +01:00
Edoardo Prezioso 57fcde8090 Fixed ticket #3481 (segmentation fault of cppcheck) 2012-01-09 13:39:02 +01:00
Edoardo Prezioso a951d34aa8 Fixed ticket #3480 (segmentation fault of cppcheck) 2012-01-09 12:48:52 +01:00
Reijo Tomperi 194327048a Add InternalError and change MathLib to throw it in case of an error.
- Previously MathLib errors did not provide a filename, but after this change at least source file name should be printed
and if token is provided, also line number should be printed.
- Change also Token to use InternalError
- Modify Cppcheck-class to catch InternalError instead of Token
- Run dmake to update Makefile
2012-01-08 22:19:44 +02:00
PKEuS c273d6d31d Refactorized checkautovariables.cpp. Removed indendation counters.
Fixed #3478
2012-01-08 15:32:22 +01:00
Kamil Dudka e09b0330e4 Class: Don't warn about uninitialized union members because they are often combined with a second variable 2012-01-08 12:17:55 +01:00
Daniel Marjamäki 65ce55e675 Fixed #3472 (false positive: (error) Passing value 0 to log() leads to undefined result) 2012-01-08 12:07:25 +01:00
Daniel Marjamäki ee55d3294a Refactoring. Assume that .C files contain C code on case insensitive filesystems. 2012-01-08 10:34:31 +01:00
Daniel Marjamäki 304980848f Fixed #3473 (False positive: variable is assigned value that is never used (used in return statement)) 2012-01-08 08:44:18 +01:00
Daniel Marjamäki 70c83d9ca9 Fixed #3467 (False positive: Variable is not assigned a value (new)) 2012-01-08 08:31:00 +01:00
Reijo Tomperi 3c0ada52e6 Refactoring: Extract sizeof simplifying from template simplifying 2012-01-08 00:21:12 +02:00
Reijo Tomperi 93e3e7361e In unix .C is considered C++. Changed isC() and isCPP() to work like they were before refactoring. 2012-01-07 10:47:15 +02:00
Daniel Marjamäki 6a63104743 Fixed #3320 (False positive: Member variable is not initialized in the constructor (namespaces).) 2012-01-07 09:28:26 +01:00
Daniel Marjamäki a5264f6395 Symbol database: dump if --debug and --verbose is given 2012-01-07 08:21:34 +01:00
Reijo Tomperi 2a79399a53 astyle fix 2012-01-06 21:57:59 +02:00
Reijo Tomperi e91d239ea5 Refactor: Move file extension checks from Tokenizer to Path class. This has also functional change as now also file.JAVA is considered a Java file. 2012-01-06 21:56:28 +02:00
PKEuS 8378153669 Fixed missing include 2012-01-06 18:11:06 +01:00
Daniel Marjamäki de4a64332e Refactoring: Copy FileLister::acceptFile to Path::acceptFile. Use Path::getFilenameExtension and Path::acceptFile in Tokenizer. Use Path::acceptFile in CppCheck::processFile instead of hardcoded handling. 2012-01-06 17:31:10 +01:00
Daniel Marjamäki 9a102702cb Refactoring: Disable debug warnings when file extension is neither .c nor .cpp. To somewhat prevent that people fix java/c# specific debug warnings. 2012-01-06 16:08:08 +01:00
Edoardo Prezioso 05f16a25af Fixed ticket #2405 (debug messages provide incorrect file:line information) 2012-01-06 15:15:52 +01:00
Daniel Marjamäki bd8c21fc6b Refactoring: Made Preprocessor::simplifyCondition nonstatic 2012-01-06 08:42:07 +01:00
Daniel Marjamäki 66472b09c0 Refactoring: Made Preprocessor::match_cfg_def nonstatic 2012-01-06 08:15:48 +01:00
Daniel Marjamäki e4875178fa Refactoring: Removed redundant settings parameter for Preprocessor::removeComments 2012-01-06 08:09:53 +01:00
Daniel Marjamäki 94d220e370 Refactoring: Made Preprocessor::getcode nonstatic 2012-01-06 08:01:50 +01:00
Reijo Tomperi eda04ad906 Refactoring: Move template code into templatesimplifier: simplifyTemplatesExpandTemplate() 2012-01-05 22:45:19 +02:00
Daniel Marjamäki 07776e90ad Preprocessor: cleanup 2012-01-05 18:37:15 +01:00
Daniel Marjamäki c5f62c19d6 astyle formatting 2012-01-05 18:24:27 +01:00
Daniel Marjamäki 56a5e08f6b Use symbol database dump code written by Robert Reif. The symbol database is dumped if --debug is used. 2012-01-05 18:22:54 +01:00
Edoardo Prezioso a7029291fd Tokenizer::simplifyGoto: process also derived class/structs. 2012-01-04 17:08:53 +01:00
Edoardo Prezioso b0e4dc3ab8 Refactoring: replace forgotten code with function call 'simplifyRedundantConsecutiveBraces'. 2012-01-04 16:47:36 +01:00
Edoardo Prezioso 6f9cd110d0 Improve Tokenizer: improve 'simplifyDoublePlusAndDoubleMinus' when there are negative numbers. 2012-01-04 13:45:27 +01:00
Edoardo Prezioso 75fbe310ff Extract various functions inside the Tokenizer class and fix tokenization of 'return __LINE__ ;'. 2012-01-04 12:57:58 +01:00
PKEuS eabdc9082e Fixed false positives related to %*[] in scanf format string (#3468) 2012-01-04 11:22:42 +01:00
Reijo Tomperi 0369681a2c Refactoring: Move template code into templatesimplifier: simplifyTemplatesGetTemplateNamePosition() 2012-01-03 23:49:50 +02:00
Reijo Tomperi ac290b1a8a Refactoring: Move template code into templatesimplifier: simplifyTemplatesUseDefaultArgumentValues(), simplifyTemplatesInstantiateMatch() 2012-01-03 23:35:06 +02:00
PKEuS 756ee800b0 Use std::stack instead of std::vector Tokenizer::createTokens. Removed #pragma warning(disable: 4503) 2012-01-03 11:46:35 +01:00
Edoardo Prezioso c76f06c01b Fixed ticket #3447 (Improve void CheckStl::if_find()) 2012-01-02 23:12:59 +01:00
Reijo Tomperi 16fb1801e1 Refactoring: Move template code into templatesimplifier: simplifyTemplatesGetTemplateDeclarations(), simplifyTemplatesGetTemplateInstantiations() 2012-01-02 23:05:27 +02:00
Reijo Tomperi 37269d0c28 Refactoring: Move template code into templatesimplifier: simplifyTemplatesExpandSpecialized() 2012-01-02 22:53:13 +02:00
Reijo Tomperi 8084bc80fc Refactoring: Move template code into templatesimplifier: removeTemplates() 2012-01-02 22:46:43 +02:00
Reijo Tomperi e9071a8bb6 Refactoring: Move code into templatesimplifier: templateParameters() 2012-01-02 22:43:38 +02:00
Reijo Tomperi d26bcfe8d5 Refactoring: Move code into templatesimplifier 2012-01-02 22:37:32 +02:00
Daniel Marjamäki e4f3f91c18 Reverted 9aa8a496. I don't know why I made this fix. 2012-01-02 19:45:20 +01:00
Edoardo Prezioso 94a2287370 Revert 'using' changes as it was until some time ago. 2012-01-02 19:27:32 +01:00
PKEuS 9c423b82c1 Refactorizations in preprocessor.cpp 2012-01-02 15:52:19 +01:00
PKEuS 621d43e9e4 Fixed #3461: Support for %m* on scanf-functions 2012-01-02 14:05:58 +01:00
Daniel Marjamäki 906c2b70ac Fixed #3445 (Problems with lib/standards.h) 2012-01-02 13:36:17 +01:00
PKEuS 08805dd9fe Fixed compiler errors with GCC 2012-01-02 13:10:35 +01:00
PKEuS 38ddcde7b0 - Refactorizations in preprocessor.cpp and tokenizer.cpp
- Bugfix: tok->stringify(tok) returns now "".
- Removed most of the inline-asm handling in preprocessor; improved the remaining handling of #asm/#endasm: Simplified to "asm(...);" statement
2012-01-02 12:58:34 +01:00
PKEuS 064e0ea0d0 Revert "- Refactorizations in preprocessor.cpp and tokenizer.cpp"
Committing with subversion seems to have issues. Sorry for that. I'll the changes again, now using git.

This reverts commit 69498de6ca.
2012-01-02 12:10:53 +01:00
Philipp K 69498de6ca - Refactorizations in preprocessor.cpp and tokenizer.cpp
- Bugfix: tok->stringify(tok) returns now "".
- Removed most of the inline-asm handling in preprocessor; improved the remaining handling of #asm/#endasm: Simplified to "asm(...);" statement
2012-01-02 03:15:02 -08:00
Daniel Marjamäki 01759b03f9 Fixed #3463 (Uninitialized variable variable pointer) 2012-01-02 11:25:13 +01:00
Daniel Marjamäki 112873e876 Revert "Fixed #3450 (CLI --report-progress is currently useless)"
This reverts commit e769fe6294.
2012-01-02 07:42:39 +01:00
Daniel Marjamäki e769fe6294 Fixed #3450 (CLI --report-progress is currently useless) 2012-01-02 07:27:45 +01:00
Edoardo Prezioso b24e6e659e C# simplification: remove 'using var;' code from the tokenizer. 2012-01-02 00:53:20 +01:00
Edoardo Prezioso eb657034ba Handle also C# multidimensional arrays with no specified dimension. 2012-01-02 00:22:45 +01:00
Reijo Tomperi aa927d5aa3 Refactoring: Add new file lib/templatesimplifier.cpp
The plan is to move template simplification into this new class to take some lines from 10 000 line tokenizer.
2012-01-01 22:55:05 +02:00
PKEuS f4703e026a Refactoring various issues in cmdlineparser, cppcheckexecutor, check64bit and tokenize. 2012-01-01 21:17:16 +02:00
Reijo Tomperi 8cae17fda8 Update year to 2012 2012-01-01 01:05:37 +02:00
Erik Lax 3d0c1a3301 Fix #3457 (Statement following goto can be executed)
http://sourceforge.net/apps/trac/cppcheck/ticket/3457
2012-01-01 00:11:03 +02:00
Edoardo Prezioso 38e0e25ce0 Fixed ticket #3448 (segmentation fault of cppcheck).
Add testcase related to previous commit (add 'A f(&x);' as declaration of variable).
2011-12-31 21:44:07 +01:00
Edoardo Prezioso b9c796d9f8 - Re-elaborate 'using' keyword skipping in Tokenizer::setVarId and
Scope::getVariableList;
- Improve setVarId: add possible declaration: 'A f(&x);' and change from:
'if (...){}else{ continue; };' to: 'if (!...) continue;';
- Little refactoring of 'Tokenizer::removeTokens()'.
2011-12-31 21:36:19 +01:00
Daniel Marjamäki 8a6b1dc1c9 Fixed #3449 (segmentation fault of cppcheck) 2011-12-31 12:08:49 +01:00
Reijo Tomperi 0e1fb5f75b astyle fix 2011-12-30 21:01:33 +02:00
Edoardo Prezioso 8f2ad53332 Add testcase for previous commit. 2011-12-30 18:47:42 +01:00
Edoardo Prezioso 0d3bf5340d Improve varId and getVariableList filter, related to previous commit. 2011-12-30 18:13:42 +01:00
Edoardo Prezioso 8c68b811f3 Fix debug message "Scope::checkVariable found variable '%var%' with varid 0." in C# code with 'using %var%;'. 2011-12-30 13:01:09 +01:00
Edoardo Prezioso 873572d489 Improve C# simplification code with arrays of arrays. 2011-12-30 12:26:28 +01:00
Edoardo Prezioso d0a3560c92 Rewrite Tokenizer::hasEnumsWithTypedef by using 'findmatch' in order to shorten the code. 2011-12-30 11:38:18 +01:00
Daniel Marjamäki 6a0c463ebd #3382 (Clarify error message 'invalid deallocation') 2011-12-30 10:32:55 +01:00
Daniel Marjamäki 2ae48c7aef Fixed #3454 (false positive: (style) Variable 'iFaktor' is assigned a value that is never used) 2011-12-30 09:47:15 +01:00
Reijo Tomperi 65b58bcb99 Partial fix to #3452 (ErrorLogger: complain/raise assertion when error message has extra newlines etc)
http://sourceforge.net/apps/trac/cppcheck/ticket/3452
Add assert for newlines.
2011-12-30 01:22:16 +02:00
Marek Zmysłowski dd8316474a Fixed #3335 (new check: warn about potential missuse of isgraph-like functions) 2011-12-29 08:08:37 +01:00
Daniel Marjamäki 6d98406d71 Fixed #3444 (False positive using putenv) 2011-12-29 07:35:27 +01:00
Reijo Tomperi 90e1a397a2 Refactoring: Remove duplicate function from tokenizer: code_is_c() -> isC() 2011-12-29 00:36:16 +02:00
Reijo Tomperi 614c90b156 astyle fix 2011-12-28 23:57:54 +02:00
Edoardo Prezioso 09bfa66536 Always by pressing request, oops. 2011-12-28 22:51:13 +01:00
Edoardo Prezioso ec0badb651 By pressing request, extract method: simplifyJavaAndCSharp. 2011-12-28 22:44:53 +01:00
Edoardo Prezioso f9dd927ff4 Move non-C++ simplification outside big loop.
Related to commit b2f8161862 .
2011-12-28 22:12:54 +01:00
Reijo Tomperi 0a588496a0 Fix astyle and test failures. 2011-12-28 22:05:10 +02:00
Edoardo Prezioso bbac4f1faf Fix ticket #3451 (A (style) type warning witout message text). 2011-12-28 17:15:04 +01:00
Edoardo Prezioso b2f8161862 Rewrite fix of ticket #3415 (Segmentation fault in new check for uninitialized variables):
new simplify: 'code ; ({ some_code ; });' to 'code ; some_code ;';
remove the sanity check in checkunusedvar, so when it crashes again it's easy to spot a bigger problem;
'internal' reported 'Token::Match' with simple pattern.

'Tokenizer::tokenize()' refactorings:
make one loop with many simple simplifications instead of many loops with one simplification.
some style changes.
2011-12-28 16:55:59 +01:00
Daniel Marjamäki 379440e2a4 CheckNullPointer: Use Tokenizer::IsScopeNoReturn 2011-12-28 08:17:58 +01:00
Daniel Marjamäki 7f42300c18 Null pointer: Removed old code for handling exit(). No testing affected. 2011-12-28 08:07:21 +01:00
Reijo Tomperi 1afd923d34 Fix bug in C# detection code. The test had a bug also, so it was not detected by the test. 2011-12-27 22:50:56 +02:00
Jonathan Neuschäfer f10d314391 checkmemleak.h: use Tokenizer::isJavaOrCSharp() 2011-12-27 18:01:39 +01:00
Jonathan Neuschäfer 7a5627029f tokenizer: proper checks for Java and C# 2011-12-27 18:01:39 +01:00
Jonathan Neuschäfer 103588c5bc Refactoring: tokenizer: factor out fileExtension 2011-12-27 18:01:39 +01:00
Daniel Marjamäki 91874214d8 Refactoring: Added utility function that determine if scope ends with a call to a noreturn function 2011-12-27 18:00:12 +01:00
Daniel Marjamäki 32ed84f4c5 Uninitialized variables: Fixed false positives when using typeof() 2011-12-27 17:03:48 +01:00
Daniel Marjamäki 7c606c4e3b Uninitialized variables: Fixed false positives for such code: 'if (cond1) { a=0; } if (cond1) { if (cond2) { use_a; } }' 2011-12-27 13:16:16 +01:00
Daniel Marjamäki 987392f254 Tokenizer: Better handling of array of function pointers 2011-12-27 11:56:40 +01:00
Daniel Marjamäki 0bf8e6206c STL: Fixed false positive when using string::find 2011-12-27 11:02:43 +01:00
Daniel Marjamäki f6b201bb3b Uninitialized variables: Fixed false positives when pointer is dereferenced in unexpanded macro 2011-12-27 10:18:49 +01:00
Daniel Marjamäki 9593e14d72 Removed debug variables 2011-12-27 09:27:46 +01:00
Daniel Marjamäki fdb6ee2ad7 Uninitialized variables: Fix false positives related to for loop 2011-12-27 08:18:05 +01:00
Daniel Marjamäki 5bac8eca37 Uninitialized variables: Fixed false positives (caused by my 'check more variables' commit) 2011-12-26 22:14:52 +01:00
Daniel Marjamäki 5aaec7adc5 Uninitialized variables: Better handling of variable usage in condition 2011-12-26 18:56:40 +01:00
Daniel Marjamäki 59cd099ba7 Uninitialized variables: Fixed false positives caused by recent commit when potentially uninitialized variable is read in condition 2011-12-26 18:32:42 +01:00
Daniel Marjamäki 481fa532a8 Uninitialized variables: Fixed false positives caused by recent improvement when variable is potentially initialized in else block. 2011-12-26 18:17:13 +01:00
Daniel Marjamäki c56e2e7cf9 Uninitialized variables: Fixed false positives for unconditional inner scopes 2011-12-26 17:52:32 +01:00
Daniel Marjamäki 025518c474 Uninitialized variables: Fixed false positives when goto is used. 2011-12-26 16:46:10 +01:00
Daniel Marjamäki 8eb067358c Uninitialized variables: check more variables 2011-12-26 14:01:46 +01:00
Daniel Marjamäki f48edb63a3 Uninitialized variables: Improved checking when there are multiple if/else and a certain path causes an error 2011-12-26 12:36:35 +01:00
Daniel Marjamäki 2d05cae13b Fixed #3201 (Checking iterators from different objects) 2011-12-26 10:30:39 +01:00
Daniel Marjamäki fd4bc12ed3 Fixed #3438 (false positive: (style) Variable 'dBuf' is not assigned a value) 2011-12-26 08:12:23 +01:00
Daniel Marjamäki fd3f384e24 astyle formatting 2011-12-26 07:58:02 +01:00
Daniel Marjamäki 096b22c46e #3434 (False positive Returning reference to auto variable) 2011-12-26 07:44:16 +01:00
Daniel Marjamäki 385afffb14 Null pointers: show inconclusive errors if functions are called. Assume they won't assign the pointer. Ticket: #3443 2011-12-26 07:13:10 +01:00
Edoardo Prezioso 293437bdfc Fixed ticket #3416 (segmentation fault of cppcheck) 2011-12-26 03:21:23 +01:00
Reijo Tomperi e112bfdd47 Refactoring: Rename some variables and funtions in tokenizer.
Small logic change also for count variable to make new name more logical.
2011-12-26 00:06:27 +02:00
Daniel Marjamäki b742c03b65 Fixed #3443 (false positives: possible null pointer dereference (calling unknown function)) 2011-12-25 17:01:45 +01:00
Daniel Marjamäki a4dcf8feea Fixed #3435 (False positive: (warning) Member variable 'A::m_Vec' is not initialized in the constructor.) 2011-12-25 11:05:06 +01:00
Reijo Tomperi 347982a347 Refactoring: Extract several methods from tokenize() 2011-12-24 23:23:08 +02:00
Reijo Tomperi 8e6ebd4a22 Refactoring: Extract method: simplifyDoublePlusAndDoubleMinus() 2011-12-24 22:51:55 +02:00
Daniel Marjamäki c81a055caa C++ Builder: Fixed compiler error (weird error) 2011-12-24 08:10:16 +01:00
Reijo Tomperi 6155932207 Refactoring: Rename some variables with too short names, such as "s". 2011-12-24 00:25:03 +02:00
Reijo Tomperi 00cbf02d84 Refactoring: Rename variable used -> templateInstantiations 2011-12-24 00:03:03 +02:00
PKEuS dca03c3ce2 Remove unnecessary includes
Also add a unit test related to #3427
Also improve the description text in checkclass and remove unused variable.
2011-12-23 23:31:48 +02:00
Daniel Marjamäki 8e94e2261b Comparing bool with int: Fixed false positives 2011-12-23 19:11:51 +01:00
PKEuS 8213a15b2a improving checkSizeofForStrncmpSize 2011-12-23 18:11:34 +01:00
Daniel Marjamäki e9d697b636 Fixed #3419 (false positive: (style) Same expression on both sides of '&'.) 2011-12-23 16:08:53 +01:00
PKEuS 409364747c Fixed #3441 (segmentation fault of cppcheck (%: return ; ())) 2011-12-23 12:46:59 +01:00
Daniel Marjamäki df8504f0ea Clarify calculation: Fixed false positives when there are various function calls 2011-12-23 12:13:39 +01:00
Daniel Marjamäki ba5558748d Uninitialized variables: Fixed false 'dangerous usage of strncpy' positive when resulting string is used by strncpy 2011-12-23 08:44:28 +01:00
Reijo Tomperi 70c4bb54b4 Refactoring: Split long function in tokenizer.
simplifyTemplatesInstantiate()
2011-12-22 23:13:45 +02:00
Reijo Tomperi 1c12d04d0d Refactoring: Make a 300 line function a little smaller.
simplifyTemplatesInstantiate()
2011-12-22 22:39:15 +02:00
Marek Zmysłowski 4b4f201b79 Fixed #3437 (segmentation fault of cppcheck) 2011-12-22 07:28:28 +01:00
Daniel Marjamäki deccb1df06 Fixed #3433 (False positive: Same iterator is used with both myVector and myMap) 2011-12-21 06:16:06 +01:00
Daniel Marjamäki fd0d9c8694 CheckOther: Added line break to make the code more readable 2011-12-20 20:54:14 +01:00
Daniel Marjamäki f8181df340 Fixed #3410 (Comparing bool against bool produces false positive) 2011-12-20 06:38:05 +01:00
PKEuS 6dc2a6e7ab Refactorized CheckUnusedVar 2011-12-18 20:15:41 +01:00
PKEuS b6b97fa43d Fixed #3427 (False positive: (error) Dangerous usage of c_str(). The returned value by c_str() is invalid after this call.) 2011-12-18 19:44:38 +01:00
PKEuS 0205582161 Fixed #3327 (printf with std::string as parameter) 2011-12-18 19:41:21 +01:00
Daniel Marjamäki 1ba1be4b8d Fixed #3428 (false negative: array bounds errors not found when duplicate class names present) 2011-12-18 16:35:51 +01:00
Daniel Marjamäki 2bb5de4c89 Fixed #3425 (False positive: Null pointer dereference (pointer is checked in macro)) 2011-12-18 13:33:23 +01:00
Daniel Marjamäki 772b8cc37d Array index out of bounds: Avoid false positives when there are duplicate names for structs 2011-12-18 08:12:42 +01:00
Daniel Marjamäki 83cdf734fe Tokenizer: The tokenizer didn't handle '0x0E-7' correctly 2011-12-18 07:37:20 +01:00
Daniel Marjamäki 5f712cc213 Array index out of bounds: Fixed false positive when taking address beyond array using calculated array index 2011-12-17 21:35:12 +01:00
OGAWA KenIchi 3e9d8e6ae1 Fixed #3422 (Internal error in exceptRethrowCopy check) 2011-12-17 20:00:15 +01:00
Daniel Marjamäki d21ca7881c Fixed #3424 (Tokenizer: doesn't tokenize if-if-else-else correctly) 2011-12-17 19:05:14 +01:00
PKEuS f306246c7f Improved support for references and pointers in SymbolDatabase
Replaced several isPointer functions by Variable::isPointer function
Refactorizations & Make use of symbolDatabase more often
2011-12-17 19:04:03 +01:00
Daniel Marjamäki f09a5b408b Uninitialized variables: Fixed false positives when sizeof is used in condition. Ticket: #3369 2011-12-17 16:08:55 +01:00
Daniel Marjamäki 322f46c761 Fixed #3426 ((error) Invalid number of character ({) when these macros are defined:) 2011-12-17 15:23:55 +01:00
Daniel Marjamäki 95123854ba Array index out of bounds: Fixed false positive when size is not known. 2011-12-17 13:20:42 +01:00
Daniel Marjamäki e008a0508b Null pointers: Fixed false positive when sizeof without parentheses are used 2011-12-17 12:44:11 +01:00
PKEuS 4abee3a345 Refactorings. Use reportError instead of reportInconclusiveError. 2011-12-17 11:39:20 +01:00
PKEuS 009471f4ee Refactorizations for executionpath.cpp (rearranged code, added some else before if) 2011-12-17 11:26:20 +01:00
PKEuS 2fa0168e55 Patch that improves STL checking: Make use of SymbolDatabase, solved TODO (about returning .c_str() value), check for deleting iterators by value. 2011-12-17 11:21:34 +01:00
Daniel Marjamäki fe8393aafc Uninitialized variables: Fixed false positives in sizeof. Ticket: #3369 2011-12-17 09:51:45 +01:00
Daniel Marjamäki dfedb920f8 Uninitialized variables: Fixed false positive when address of variable is taken inside = { .. }. Ticket: #3369 2011-12-17 07:56:46 +01:00
Daniel Marjamäki 0572321572 Fixed #3423 (Uninitialized variable in operator>>) 2011-12-16 20:34:44 +01:00
Daniel Marjamäki 5f1fadec7b Uninitialized variables: Fixed false positives when many 'if' are used. Ticket: #3369 2011-12-16 19:56:32 +01:00
PKEuS a311904a0f Patch that fixes some bailouts for isEnabled('style') in both directions. Improved checkSizeofForNumericParameter's error message, made it 'warning', made it non-experimental. 2011-12-16 19:21:14 +01:00
Daniel Marjamäki 1f329d7b41 Uninitialized variables: Fixed false positive for x 'a[x=1]'. Ticket: #3369 2011-12-16 18:12:47 +01:00
Daniel Marjamäki e723ef0569 Uninitialized variables: Fix false positives for '= { .. }'. Ticket: #3369 2011-12-16 18:04:10 +01:00
Daniel Marjamäki d2d7e25f3f Uninitialized variables: Fixed false positive in for condition. Ticket: #3369 2011-12-15 20:48:26 +01:00
Daniel Marjamäki 40f2f4f7f6 Uninitialized variables: Fixed false positives when there are assembler code. Ticket: #3369 2011-12-15 20:29:57 +01:00
PKEuS e5427fe487 Fixed #3048, further improvements to const correctness check. 2011-12-15 20:18:52 +01:00
Daniel Marjamäki 167530bf60 Uninitialized variable: Fixed test failure. Ticket: #3369 2011-12-15 20:15:37 +01:00
Daniel Marjamäki f797307edc Uninitialized variables: Fix false positive if variable is used after return (goto). Ticket: #3369 2011-12-15 20:05:11 +01:00
Daniel Marjamäki 10228881c7 Uninitialized variables: Fixed false positives when taking address. Ticket: #3369 2011-12-15 19:38:06 +01:00
Daniel Marjamäki fd78816181 Fixed #3418 (preprocessor define assignment not propagated) 2011-12-15 18:49:35 +01:00
Daniel Marjamäki 6221145be8 Fixed #3414 (false positive: (error) Uninitialized variable: SOutput) 2011-12-15 18:30:59 +01:00
Daniel Marjamäki 005b1cff61 Fixed #3417 (False positive: Uninitialized variable when conditionally set) 2011-12-15 18:15:58 +01:00
Daniel Marjamäki 9e54714894 CheckNullPointer::isPointerDeref: better checking if pointer is not dereferenced 2011-12-15 17:01:39 +01:00
Daniel Marjamäki 3a432fa959 Uninitialized variables: better handling of initialization with >>. Ticket: #3369 2011-12-15 16:55:55 +01:00
Daniel Marjamäki b3c35d4b32 Fixed #3415 (Segmentation fault in new check for uninitialized variables) 2011-12-15 16:49:14 +01:00
PKEuS 00d6a0e877 refactorizations for CheckClass and for less false negatives related to derived classes 2011-12-14 21:11:40 +01:00
Daniel Marjamäki 295f486cde Uninitialized variables: Detect more errors when variable is given as array index. Ticket: #3369 2011-12-14 19:56:58 +01:00
Daniel Marjamäki 63e2f64b9c Uninitialized variables: Fixed false positives for loops. Ticket: #3369 2011-12-14 18:54:03 +01:00
Daniel Marjamäki 8e3e634ce0 Uninitialized variables: Detect more errors. Ticket: #3369 2011-12-14 18:28:30 +01:00
Daniel Marjamäki 419ae2a135 Uninitialized variables: Fixed false positive in new checking when variable is initialized in condition 2011-12-14 17:17:24 +01:00
Daniel Marjamäki 6a4b1127aa astyle formatting 2011-12-14 17:07:06 +01:00
PKEuS 8ed8206b44 Fixed #3296 (false positive (inconclusive): 'C::operator=' should return 'C &') 2011-12-14 15:37:43 +01:00
Daniel Marjamäki ba463295c2 Uninitialized variables: improved check to detect more errors. Ticket: #3369 2011-12-14 06:00:17 +01:00
Daniel Marjamäki c7ce87d060 Uninitialized variables: Fixed false positives for break/continue/throw 2011-12-14 05:45:52 +01:00
Edoardo Prezioso 40aa326065 Tokenizer: remove redundant 'done' condition, related to ticket #3409.
Add more possible letters to simplifyInitVar patterns.
Replace 'tokAt(1)' with 'next()' and 'linkAt(1)' with 'next()->link()'.
Little optimizing improvements to simplifyAsm.
2011-12-13 22:41:38 +01:00
Daniel Marjamäki 458fa0874a Uninitialized variables: Started writing a new check. Ticket: #3369 2011-12-13 21:57:27 +01:00
PKEuS c9f5117cf5 Fixed #3407 (False positive: (inconclusive) Found duplicate branches for if and else. (inline assembler)) 2011-12-13 21:42:38 +01:00
Daniel Marjamäki 34fba9e1ea Fixed #3405 ((error) Invalid number of character ({) when these macros are def ined: 'WIN32'.) 2011-12-13 21:14:41 +01:00
Edoardo Prezioso 4cad5d4df4 Workaround fixes to shut up some cppcheck '--inconclusive' whinings. 2011-12-13 00:24:34 +01:00
Edoardo Prezioso 81a2e62abd Tokenizer::simplifyGoto: fix another memory read error reported by Valgrind.
Also improvements to Tokenizer are done.
2011-12-12 22:03:25 +01:00
Edoardo Prezioso 79b82f115f Tokenizer: some changes to line numbers of some tokens:
simplifyAsm: change line number of newly added 'asm ( )' in order to be the same as next ';'.
simplifyIfAddBraces: Change line number of newly added '}' in order to be the same as next 'else', except for '{ ; } else'.
2011-12-12 20:55:25 +01:00
Reijo Tomperi dc59fc4391 astyle fix 2011-12-12 21:27:48 +02:00
Daniel Marjamäki c8f497a9b3 Fixed #3405 ((error) Invalid number of character ({) when these macros are def ined: 'WIN32'.) 2011-12-12 19:35:25 +01:00
Edoardo Prezioso 626f13ae7e Tokenizer: Fix another Valgrind error in simplifyErrNoInWhile. Add more jumping patterns to simplifyIfAddBraces and simplifyDoWhileAddBraces. 2011-12-12 13:15:35 +01:00
Daniel Marjamäki 5f5c912f3f temporary fix for inconclusive false warnings. there is not sufficient logic for determining when there is NOT a pointer dereference. 2011-12-12 07:43:33 +01:00
Daniel Marjamäki 2dbe7ca196 CheckNullPointer::isPointerDeRef: Skip inconclusive checking when --inconclusive hasn't been given. 2011-12-12 07:35:53 +01:00
Edoardo Prezioso 99d8ce3732 Fix Valgrind error in arraySize():
if there's code like: 'int [ ] a = { 1 , 5 , }', 'end' is last '}', when 'tok2' arrives to second ',' and cppcheck finds out that next token to 'tok2' is '}', remove this ',' with 'tok2->deleteThis()' but it causes (maybe) a memory corruption to 'end' which will gave problems later because 'tok' will be assigned to it or its next token.
2011-12-12 02:23:49 +01:00
Edoardo Prezioso 52620e6493 Tokenizer::simplifyDoWhileAddBraces:
1)rewrite fix for ticket #988 (just don't simplify inside macro parenthesis);
2)use a different organization of the code: start from last token and proceed backwards. This way 'simplifyDoWhileAddBracesHelper' can be called just once, hence the 'Helper' code can be improved and moved in the main function.
2011-12-12 00:20:46 +01:00
Edoardo Prezioso cf574072b6 Tokenizer::arraySize(): improve code structure, fixed 'tok2' for-looping which didn't stop to the ending '}' parenthesis. 2011-12-11 23:13:37 +01:00
Edoardo Prezioso 3c098839d1 simplifyIfAddBraces: Remove restriction for jumping opening parenthesis '(' as a fix to #2873, because even without this the original test case doesn't crash anymore. Add more jumping patterns.
simplifyFunctionParameters: Add more jumping patterns and an observation related to error message for equal parameter names, help needed.
Fix grammar mistake in comment.
2011-12-11 13:07:13 +01:00
Daniel Marjamäki ffb5d107be CheckNullPointer::isPointerDeRef: Tweaks to reduce false warnings when inconclusive is used. 2011-12-11 08:48:55 +01:00
Daniel Marjamäki 497c54a1a7 Fixed #3168 (false negative: buffer overflow in subfunction) 2011-12-11 08:16:58 +01:00
Edoardo Prezioso 27801b35eb Other improvements to tokenizer code.
Handle SQL code better, even when there's no ';' after 'EXEC SQL'.
simplifyVarDecl: Check with 'Token::Match' once when you have to check a pattern inside which there should be a number or a variable. Use '%any%' and after that check if that string is a number or a variable name later.
simplifyGoto: process also anonymous structs and unions which should have 'indentspecial' incremented, skip code like 'var = { ... }'.
2011-12-11 02:02:38 +01:00
Edoardo Prezioso 5134964026 Fix code in commit 5f522fb841 and reapply it again. 2011-12-10 23:49:56 +01:00
Daniel Marjamäki 04159b81b8 reverted 5f522fb841, to avoid hang in TestBufferOverrun::arrayInfo 2011-12-10 20:51:36 +01:00
Daniel Marjamäki ee39f6402c reverted fix for #3168, I'll rewrite it 2011-12-10 20:46:10 +01:00
Daniel Marjamäki 897e8637b4 Fixed #3168 (false negative: buffer overflow in subfunction) 2011-12-10 19:26:12 +01:00
Edoardo Prezioso 5f522fb841 Tokenizer: improve code and remove redundant checks.
In particular: improve 'double sharp' concatenation by handling also code which begins without the [{};]. Do the same with C# code. Also, in the labels simplification function, skip also '{}' when the open bracket is after a '='.
2011-12-10 18:45:27 +01:00
Daniel Marjamäki e870c68978 Check64BitPortability: Wiki formatting update 2011-12-10 18:41:09 +01:00
Daniel Marjamäki c5a1b5ecab --doc : don't write internal checks in the doc output 2011-12-10 18:39:25 +01:00
Edoardo Prezioso bf815ac1e4 Improve labels simplification code, remove redundant checking. 2011-12-10 14:13:48 +01:00
Daniel Marjamäki 93b447f7f6 1.52: Updated version 2011-12-10 12:55:40 +01:00
PKEuS 9fc7453917 Memory leaks: Code cleanups 2011-12-10 11:55:14 +01:00
Daniel Marjamäki 8624c0b9fd Merge pull request #67 from makulik/master
Fixed ticket #3389 '-U option doesn't supress include file handling for #include statements inside #ifdef code paths'
2011-12-10 02:44:01 -08:00
Daniel Marjamäki c2e86b867c Fixed #3386 (Syntax Error: 'int a[]={b<c?1:2,3};') 2011-12-10 11:34:27 +01:00
Edoardo Prezioso 51c1e2303f CheckBufferOverrun::checkInsecureCmdLineArgs(): Remove recently unused variable 'pattern'. 2011-12-09 23:24:08 +01:00
PKEuS 91a0a071d0 Take symbol database into use or improve its usage in some checks. 2011-12-09 23:28:10 +02:00
makulik 0a777dcb52 Fixed ticket #3389 '-U option doesn't supress include file handling for #include statements inside #ifdef code paths'
Signed-off-by: makulik <g-makulik@t-online.de>
2011-12-09 21:57:06 +01:00
PKEuS 9b685ba3c3 Code cleanup 2011-12-09 21:00:57 +01:00
Edoardo Prezioso 7d12951da0 1)Fixed ticket #3184 (Improve Tokenizer: improve simplifyMulAnd to simplify weirder code);
2)Fix a test case inside TestSimplifyTokens::flowControl.
2011-12-09 20:47:51 +01:00
PKEuS f46cf5fd65 Exception safety: refactorings, use the symbol database 2011-12-09 19:53:00 +01:00
Daniel Marjamäki 8ca8887849 C++ Builder : Fixed compiler error 2011-12-08 22:24:09 +01:00
Daniel Marjamäki b383bae4ab C++ Builder: Fixed compiler errors 2011-12-08 22:17:50 +01:00
Daniel Marjamäki 6029e23189 Preprocessor: Use const_iterator instead of iterator where possible 2011-12-08 22:14:11 +01:00
Daniel Marjamäki 60d828e778 C++ Builder: Fixed compiler error 2011-12-08 22:09:03 +01:00
PKEuS 167a7e3e51 Various code cleanups 2011-12-08 21:28:34 +01:00
Daniel Marjamäki e2dd085b60 Fixed #3394 (False positive: possible null pointer dereference) 2011-12-08 19:30:14 +01:00
PKEuS 1bef8d1247 Tokenizer: Code cleanups 2011-12-08 17:42:26 +01:00
Edoardo Prezioso 149ff355e2 Add more kind of code to process for 'removeExceptionSpecifications' (unions, anonymous unions and structs). 2011-12-08 02:50:05 +01:00
Edoardo Prezioso 4de5d87078 1)Remove newly copy of 'eraseTokens' and replace every occurrence with 'deleteNext' with right parameter.
2)General improvements to code.
2011-12-08 01:44:18 +01:00
Edoardo Prezioso 76972e8dd3 Extend 'Token::deleteNext' by introducing a new parameter which determines how many tokens should be deleted. It's still not used, though. 2011-12-07 23:36:11 +01:00
PKEuS 1c1c31bea0 Tokenizer: Refactorings and improvements. Better handling of [] 2011-12-07 21:15:00 +01:00
PKEuS 97eecb78a7 Fixed #3381 (false positive: (style) Statements following return, break, continue, goto or throw will never be executed) 2011-12-07 18:20:52 +01:00
Edoardo Prezioso 612b3c59ca 1)Implement another declaration of 'Token::eraseTokens' with parameters: the starting token and the number of times needed to call 'deleteNext'.
2)Use the overloaded 'eraseTokens' where needed instead of using consecutively 'deleteNext'.
3)Tokenizer: general optimizations about the deletion of some tokens.
4)Run astyle.
2011-12-07 02:29:03 +01:00
Edoardo Prezioso b9224439c1 Add 'exit' and 'abort' to the flow control list in order to simplify code after them. 2011-12-06 22:56:12 +01:00
Edoardo Prezioso eb5fe250ab Partial fix ticket #3385 ('throw' isn't removed if the argument of the function is type 'struct|class'). 2011-12-06 21:02:26 +01:00
Edoardo Prezioso 0504952950 Remove some redundant parenthesis - part 9 2011-12-06 16:53:57 +01:00
Edoardo Prezioso 1b4b8fbefe Tokenizer: use more 'deleteNext' instead of 'eraseTokens' where possible. 2011-12-05 18:52:34 +01:00
Edoardo Prezioso c8bbb77776 CheckMemoryLeakInFunction::simplifycode : use properly 'deleteNext' instead of 'deleteThis' or 'eraseTokens' and remove redundant conversion to 'std::string'. 2011-12-05 15:50:11 +01:00
Edoardo Prezioso 186ab3645e Oops. I should eventually keep ';', not 'typedef'. 2011-12-05 00:26:08 +01:00
Edoardo Prezioso 65213772df Tokenizer: use 'deleteNext()' or, even better, 'eraseTokens' instead of 'deleteThis()' where possible. 2011-12-05 00:08:50 +01:00
PKEuS 501d7ccb2d Optimize checkother.cpp by taking symbolDatabase into use. 2011-12-04 20:49:01 +02:00
Edoardo Prezioso 9cadd7c17a Remove some redundant semicolons - part 8 2011-12-04 19:11:51 +01:00
Edoardo Prezioso 4946b036ad Remove some redundant semicolons - part 7 2011-12-04 18:08:35 +01:00
Edoardo Prezioso 52a174fa9d Remove some redundant semicolons - part 6 2011-12-04 17:30:25 +01:00
Edoardo Prezioso b45d63a10a Remove some redundant semicolons - part 5 2011-12-04 17:15:53 +01:00
Edoardo Prezioso 2fc067e6ab Tokenizer::simplifyConst : handle also '%type% const' when the 'type' token is the first one in the list. 2011-12-04 16:59:19 +01:00
Edoardo Prezioso a363749a17 1) Remove some redundant semicolons - part 4 ('typedef' != _tokens.str());
2) Tokenizer: Use Token::eraseTokens instead of using the same instructions as the ones inside such function.
2011-12-04 15:40:05 +01:00
Daniel Marjamäki eeb6dc48a5 Fixed #3359 (False positive: array[idx++] += val triggers unexpected 'Array index out of bounds' error) 2011-12-04 12:22:21 +01:00
Daniel Marjamäki 49784a44e1 Tokenizer: improved handling of inner templates. Partial fix for #3226 2011-12-04 11:38:41 +01:00
Edoardo Prezioso f47ac539d6 Tokenizer::simplifyFlowControl: 1) remove consecutive 'break' or 'continue', since they don't influence the CheckOther results; 2) improve the code speed where possible;
Tokenizer::eraseDeadCode: Ditto.
2011-12-03 17:15:19 +01:00
Thomas Jarosch fcb6759f43 The usual astyle run 2011-12-03 17:01:56 +01:00
Daniel Marjamäki 50dfdf7c2e Fixed #3350 (Analysis failed) 2011-12-03 15:15:15 +01:00
Daniel Marjamäki c90558f730 Fixed #3358 (False null pointer dereference positive with ternary ?: operator) 2011-12-03 13:10:07 +01:00
Daniel Marjamäki b7988a3dab Fixed #3336 (False positive: Member function is not used (used by template function)) 2011-12-03 12:19:26 +01:00
PKEuS 1f438b0505 Fixed #3375 (Improve check: Detect unreachable code) 2011-12-03 11:43:23 +01:00
Daniel Marjamäki 69d3d4a17d Fixed gcc compiler warnings 2011-12-03 09:57:56 +01:00
Daniel Marjamäki fb3115a199 Fixed #3267 (False positive: resource leak in vdr-xinelib) 2011-12-03 09:53:36 +01:00
Edoardo Prezioso 00bae586e9 Add 'throw' to the flow control statements list for simplification of dead code. 2011-12-03 02:04:29 +01:00
Edoardo Prezioso 42a557432d Remove some redundant semicolons - part 3 2011-12-02 23:04:06 +01:00
Edoardo Prezioso c2ddb67316 Remove some redundant semicolons - part 2 2011-12-02 22:58:29 +01:00
Edoardo Prezioso ff1cb241a8 Remove some redundant semicolons - part 1 2011-12-02 22:39:33 +01:00
Daniel Marjamäki 9a84c5845a Fixed #3373 (False posititive: incorrect %* handling in sscanf) 2011-12-02 17:09:32 +01:00
Daniel Marjamäki 6763e596b9 Fixed #3345 (false positive: possible null pointer dereference (guarded by &&)) 2011-12-02 06:11:55 +01:00
Richard Quirk d2c8b9be56 Fix possible null pointer dereference 2011-12-01 19:57:04 +01:00
Richard Quirk b2ea78543b Fix false positive with non-const function calls 2011-12-01 19:57:04 +01:00
Richard Quirk a880469c5a Refactor the same expression check
Work out if a function is inconclusive when creating the entry in the
Expressions class instead of when checking the counts at the end. Store
the result in a new bool flag in the ExpressionTokens helper struct.

The pointer to symbol database and ref to list of const functions are
temporarily stored in  the Expressions helper class to avoid passing
them in too on every endExpr(tok) call.

Use a const reference to ExpressionTokens in the check loop to avoid
repeating the it->second several times, which clarifies what that code
does.
2011-12-01 19:57:04 +01:00
PKEuS 5017646488 Coding fixes and refactorings 2011-12-01 19:43:51 +01:00
Daniel Marjamäki c7e2a198cb Fixed Visual Studio compiler warnings 2011-12-01 18:32:14 +01:00
Daniel Marjamäki 93b21c6cc5 Fixed Visual Studio compiler warnings 2011-12-01 18:27:25 +01:00
Daniel Marjamäki 98480bf504 Fixed #3354 (Incorrect both sides of '||' expression match when using increment in expression.) 2011-12-01 17:46:33 +01:00
Daniel Marjamäki fddfd16758 checkDuplicateExpressions: validate tokens instead of string. Fix for my previous commit. 2011-12-01 17:43:29 +01:00
Daniel Marjamäki 31b576de3b Fixed #3334 (Test for same expression on both sides of '&' reports false positive) 2011-12-01 17:07:55 +01:00
Edoardo Prezioso 767413adad 1)internal check found a 'findmatch' with simple string argument;
2)Style: uniform 'while (...)' when inside it there's an assignment;
3)Replace '0' with 'NULL' where there's comparison with a pointer.
2011-12-01 12:04:47 +01:00
Zachary Blair 344d7e2f34 Fixed #3283 (False negative: array index out of bounds not found for constant string and known array index value) 2011-11-30 19:17:09 -08:00
Daniel Marjamäki 0bf17213ec Merge pull request #65 from makulik/master
Solution for ticket #3353 'Allow explicit undef's for configuration'
2011-11-30 12:42:11 -08:00
Daniel Marjamäki 323019c48f Fixed #3355 (False positive: member variable initialization (::ZeroMemory)) 2011-11-30 21:28:16 +01:00
Edoardo Prezioso 1084e4bece 1) Shut up GCC compiler for 'missing braces around assignment';
2) Tokenizer::simplifyGoto: Code refactoring in order to skip code inside '()|[]' parentheses without counting.
2011-11-30 20:58:39 +01:00
makulik 1e8fc71f8e Solution for ticket #3353 'Allow explicit undef's for configuration'
Signed-off-by: makulik <g-makulik@t-online.de>
2011-11-30 20:24:01 +01:00
PKEuS ee3e10ea97 Fixed #3364 (Crash in printf parsing) 2011-11-30 20:23:29 +01:00
Daniel Marjamäki d0247f3a8d Fixed #3268 (False positive: resource leak in vdr-xineliboutput) 2011-11-30 20:07:56 +01:00
Daniel Marjamäki dcd3f4fe3d Fixed #3267 (False positive (experimental): resource leak in vdr-xinelib) 2011-11-30 19:43:02 +01:00
Daniel Marjamäki 414e0ecc3c Uninitvar: Reactivated the checking 2011-11-30 18:57:52 +01:00
Daniel Marjamäki 0d48cd390b astyle formatting 2011-11-29 20:44:23 +01:00
Edoardo Prezioso 5c90c69ccf Fixed ticket #3366 (Build breakage) 2011-11-29 19:46:36 +01:00
Daniel Marjamäki b61c01c6a4 Fixed #3356 (false positive: (warning) Comparison of a boolean with integer that is neither 1 nor 0) 2011-11-29 18:14:57 +01:00
Daniel Marjamäki b538f49a6e Merge pull request #61 from richq/sameexpr
Fix for #3317 - same expression on both side of '&&' false positives
2011-11-29 08:50:02 -08:00
PKEuS be0acad11f Improvements to Nullpointer dereference on function call check:
printf format string parser improved (similar to my recent patch
on the argument counter), frexp/modf supported (#1572), Code
cleanup
2011-11-28 22:32:07 +02:00
Daniel Marjamäki 39af75abb4 Fixed #3303 (false positive: memory leak (reference count)) 2011-11-28 20:08:29 +01:00
Daniel Marjamäki 522da8d258 sizeof for numeric constant : disabled check. see ticket #3179 2011-11-27 18:50:21 +01:00
Marek Zmysłowski e0b50719f4 Fixed #909 (improve check: out of bounds of memchr function and out of bounds check) 2011-11-27 07:54:52 +01:00
PKEuS 2d3a232ef6 code refactoring 2011-11-27 07:30:58 +01:00
PKEuS 71c8669261 Fixed #3311, #3313 and #3339 (printf format string false positives) 2011-11-27 07:29:09 +01:00
PKEuS 6b1594244e code cleanups and refactorings 2011-11-26 21:15:16 +01:00
PKEuS 6b6f780057 code cleanups and refactorings 2011-11-26 21:02:04 +01:00
Daniel Marjamäki 50c320ef27 memory leaks: Made leak checking inconclusive instead of experimental 2011-11-25 14:47:45 +01:00
Marek Zmysłowski 3ae96600b5 Fixed #3212 (Simplify the double pointer cast) 2011-11-25 07:23:54 +01:00
Thomas Jarosch 5025d1019f Use Token::simpleMatch instead of Token::Match
"--enable=internal" reported:
[lib/tokenize.cpp:3563]: (warning) Found simple pattern inside Token::Match() call: ") ;"
2011-11-24 10:11:45 +01:00
Richard Quirk d28cf42d4c Fix ticket #3317 (same expression false positives)
Add a check for function calls that have no side effects. That means
known const methods and a list including strcmp, strlen, etc.

If the function is not known to be side effect-free then no style
warning is given.

Add test cases for the duplicate expressions.
2011-11-23 21:39:03 +01:00
Richard Quirk 511ac0ab1f Remove false positives for nested logic 2011-11-23 21:39:03 +01:00
Richard Quirk b0574cd02e Fix ticket #2233 (unused private static function) 2011-11-23 21:28:08 +01:00
Richard Quirk d76657fec8 Fix false positives for null pointer on exit 2011-11-23 21:27:15 +01:00
Daniel Marjamäki 2e08c8c5b1 DJGPP: Fixed a few compiler errors by using std::size_t instead of size_t 2011-11-22 21:14:14 +01:00
Daniel Marjamäki 345220b36f removed unused include 2011-11-22 19:54:15 +01:00
Daniel Marjamäki 1b1fd9d39c Fixed #3196 (False positive: member variable not initialized in constructor (union)) 2011-11-22 19:26:00 +01:00
Daniel Marjamäki add2b3706b Fixed #3352 (False positive: member variable not initialized (3D array)) 2011-11-22 18:45:25 +01:00
Daniel Marjamäki 17f891ad34 Tokenizer::setVarId: Fixed problem with class declarations with inheritance. skip them. 2011-11-21 21:18:56 +01:00
Daniel Marjamäki 0dd05e0d56 Fixed #3347 (False positive: unused function (taking address)) 2011-11-21 19:12:54 +01:00
Daniel Marjamäki 9aa8a49677 Tokenizer::setVarId: fixed 'using' bug 2011-11-21 18:04:42 +01:00
Daniel Marjamäki 648fcb9e42 operator= should return reference: Made check inconclusive. See ticket #3296 2011-11-21 08:00:10 +01:00
Daniel Marjamäki 5b5ea29f23 Mismatching format string parameters. Made check experimental. See tickets #3311, #3313 and #3339 2011-11-21 07:31:06 +01:00
Reijo Tomperi eebd1393ff "Internal error. Token::Match called with varid 0." didn't work when error was in a header file. Fixed that. 2011-11-21 00:41:26 +02:00
Reijo Tomperi 7d7d68b192 Make --debug-fp work with new exception also. 2011-11-21 00:04:09 +02:00
Reijo Tomperi 91e89380c2 astyle fix 2011-11-20 23:43:55 +02:00
Reijo Tomperi e0ea4228cd "Internal error. Token::Match called with varid 0." will now cause check to abort and write a proper error log with filename. Previously filename was empty and format was always xml. 2011-11-20 23:38:37 +02:00
Daniel Marjamäki 004dcf834b Fixed #3281 (Tokenizer::simplifyKnownVariables : static constant value is not used) 2011-11-20 21:50:26 +01:00
Marek Zmysłowski 9a8c48b36e Fixed #3255 (Error message for std::string::c_str() is not descriptive) 2011-11-20 19:26:07 +01:00
Edoardo Prezioso 6889a28d31 1) Run runastyle;
2) Clarify some comments in 'Tokenizer::simplifyFlowControl' and in 'Tokenizer::eraseDeadCode';
3) Add some 'const' variables inside 'Tokenizer::eraseDeadCode'.
2011-11-20 19:06:55 +01:00
Edoardo Prezioso d0d5a2fcd8 Completed ticket #3230 (Refactoring: add function to remove tokens when a label is found.) and fixed ticket #3264 (False positive: Variable is assigned a value that is never used). 2011-11-20 18:37:00 +01:00
Daniel Marjamäki 77925dc629 Class checking: made 'technically function x can be const' inconclusive 2011-11-20 16:54:06 +01:00
Daniel Marjamäki b26811cdf5 astyle formatting 2011-11-20 16:50:41 +01:00
Richard Quirk 91713ffe84 Fix false positives for %[ in scanf 2011-11-20 16:48:54 +01:00
Daniel Marjamäki 097637a66c Fixed #3316 (Cppcheck reporting internal errors - code compiles cleanly) 2011-11-20 16:22:21 +01:00
Edoardo Prezioso a32b05197d Change every 'tokAt(1)' to 'next()' and every 'tokAt(-1)' to 'previous()'.
Added a safety check to ensure that a 'previous()' call doesn't crash (not sure if it's needed or not).
2011-11-20 15:59:37 +01:00
Daniel Marjamäki b92959809c Uninitvar: Made checking experimental 2011-11-20 15:19:56 +01:00
Edoardo Prezioso 11dd3c09ce Change every 'tokAt(1)->' to 'next()->' because 'tokAt(1) == 0' is equivalent to 'next() == 0', hence the equivalent cppcheck crash. 2011-11-20 15:09:57 +01:00
Edoardo Prezioso 42e369a4b4 Change every 'tokAt(..)->link()' to 'linkAt(..)'. 2011-11-20 14:24:27 +01:00
Daniel Marjamäki 690702a742 Memory leaks: Made CheckMemoryLeakInFunction experimental 2011-11-20 14:11:22 +01:00
Daniel Marjamäki 1cf45a5cde Fixed #3280 (False positive: assigned value that is never used) 2011-11-20 12:09:07 +01:00
Daniel Marjamäki 8c091ff968 Fixed #3340 (Internal error. Token::Match called with varid 0... union is causing problems) 2011-11-20 08:13:28 +01:00
Daniel Marjamäki 2a5b4b1842 Fixed #3328 (False negative: out of bounds) 2011-11-19 15:28:06 +01:00
Daniel Marjamäki fc42fc956c Reverted previous commit. There are testrunner problems when the code is removed. 2011-11-19 15:14:45 +01:00
Daniel Marjamäki 5511f3fbfd removed cleanup code that will crash in some environments. it's somewhat redundant. 2011-11-19 14:50:04 +01:00
Daniel Marjamäki 13eecb9109 Fixed #3329 (cppcheck core dump on Sun machine) 2011-11-19 14:44:55 +01:00
Edoardo Prezioso c3b54066bd Merge branch 'master' of github.com:danmar/cppcheck 2011-11-19 13:36:05 +01:00
Edoardo Prezioso ccdb18f213 Add a sanity check and an error message to linkAt when the index is outside the tokens range. 2011-11-19 13:34:36 +01:00
Daniel Marjamäki c025bf9d57 Fixed #3332 (mismatching comparison: Hard to understand) 2011-11-19 08:38:54 +01:00
Daniel Marjamäki 033fef36da improved error message 'mismatching comparison' 2011-11-18 20:07:42 +01:00
Daniel Marjamäki e78131f9e6 Preprocessor: better handling of #define A 0 => #if A==0. ticket #3331 2011-11-17 19:19:43 +01:00
Marek Zmysłowski 994f08fdf0 Fixed #886 (new check: wrong value passed to isgraph function) 2011-11-17 16:31:16 +01:00
Stefan Weil 68a1b69d32 Preprocessor: Fix comments (backspace -> backslash)
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2011-11-15 19:30:43 +01:00
Stefan Weil 00ead7fb2e support any number of --append=<file> options
If one or more append files are given on the command line,
they are simply concatenated.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2011-11-15 19:27:36 +01:00
Stefan Weil 785bc3d04b Optimize handling of --append=<file> option (execution time, memory)
Whitespace was removed from the append data for every configuration
and every file: n(configuration) * n(files).

Removing whitespace immediately after the append data was read can
significantly reduce the execution time and memory usage.
It also allows further improvement because copies to the temporary
object appendCode are no longer needed.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2011-11-15 19:27:36 +01:00
Stefan Weil d11f18b5df cmdlineparser: terminate with error message if --append=<filename> fails
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2011-11-15 19:27:36 +01:00
Thomas Jarosch c317c8979c Run astyle 2011-11-14 09:21:42 +01:00
Thomas Jarosch a645235d5a Adapt Token::strAt() to return a const reference like Token::str() does
Saves us a complete conversion from string.c_str() back to std::string.
2011-11-14 09:19:46 +01:00
Richard Quirk 527236b321 Fix false positives for delete of known nulls 2011-11-13 22:38:34 +01:00
Edoardo Prezioso 2c64d299ca Change every 'tokAt(...)->str()' to 'strAt(...)'. 2011-11-13 13:10:59 +01:00
Edoardo Prezioso b28a44dc3b Change: 'next()->next()'->'tokAt(2)', 'previous()->previous()'->'tokAt(-2)'. 2011-11-12 22:33:03 +01:00
Edoardo Prezioso ed6a0e14c4 Add simplification of the consecutive braces before the end of 'tokenize()' function. 2011-11-12 16:59:20 +01:00
Edoardo Prezioso 5cbfbe31c1 Add removal of consecutive braces, i.e.: '{ { ... } }'->'{ ... }'.
Changed a little bit the dead code tests.
2011-11-12 12:07:10 +01:00
Edoardo Prezioso 2aceb623ae 1)Add 'Token' function 'linkAt', which simplifies the writing 'tokAt(i)->link()' to 'linkAt(i)'.
It's still unused, though.
2)Fix one grammatical mistake inside token.h
3)Style change to token.cpp: remove the whitespace between '!' and 'begin'.
2011-11-11 21:55:37 +01:00
Thomas Jarosch 283c2e508e Remove check for "this" inside Token class
The check hides real memory problems and is
also useless in most cases.
2011-11-11 17:19:08 +01:00
Daniel Marjamäki 5a35beebf7 added todo comment 2011-11-11 11:07:03 +01:00
Daniel Marjamäki 34e40502c6 Fixed #3314 (cppcheck incorrectly reporting Syntax error.) 2011-11-11 10:53:49 +01:00
Daniel Marjamäki 8bbd535267 Fixed #3290 (False positive: Null pointer dereference (typeid)) 2011-11-11 09:58:17 +01:00
Daniel Marjamäki 688e290332 Memory leaks: Fixed false positive for 'char *p = strcpy(malloc(10),str);' 2011-11-11 09:07:02 +01:00
Daniel Marjamäki 410b11c00f Merge pull request #60 from richq/varid0
Fix varid 0 with function pointer and virtual methods
2011-11-09 14:28:54 -08:00
Thomas Jarosch 1a454256dc Cache result of tok->isStandardType()
Also contains test order improvements from Johan Samuelson (#3116).

Run time went down from 15.15s to 14.95s for the case below.

Benchmarked using these settings:
- CXXFLAGS="-O2 -g -NDEBUG"
- time -p cppcheck.git -q --std=posix --enable=all --inconclusive -Dfoo .

on the "rpm" codebase.
2011-11-09 21:56:30 +01:00
Richard Quirk f56aa19fac Fix varid 0 with function pointer and virtual methods 2011-11-09 21:07:55 +01:00
Thomas Jarosch c010ca33a5 Run astyle 2011-11-09 20:34:58 +01:00
Daniel Marjamäki 2d00cabee1 Fixed #3279 (Token::Match called with varid 0) 2011-11-09 18:49:17 +01:00
Daniel Marjamäki b7cc9779c4 Merge pull request #59 from richq/sameexpr
Improved same expression check for ticket #3274
2011-11-08 23:56:36 -08:00
Daniel Marjamäki 3b11ae3fac Merge pull request #58 from richq/autoptr
Fix namespaced types for auto_ptr new[] errors
2011-11-08 23:49:59 -08:00
Reijo Tomperi 7a294c1f79 Fix #3307 (Invalid format string/parameter mismatch warning)
http://sourceforge.net/apps/trac/cppcheck/ticket/3307
2011-11-09 00:16:37 +02:00
Edoardo Prezioso 0569953753 Fixed ticket #3309 (false positive: (style) Boolean result is used in bitwise operation. Clarify expression with parentheses) 2011-11-08 22:48:14 +01:00
Richard Quirk d5c7c5d098 Remove duplicate expressions on both sides of || 2011-11-08 21:56:54 +01:00
Richard Quirk d1bc8819f9 Fix for same expression separated by commas
The code branch tested by the previous check for && is now different, so
I've changed the test to use == instead. There was also a missing case
when the expression was followed by a comma instead of being preceded by
one.
2011-11-08 21:56:54 +01:00
Richard Quirk d5664dd6cf Improved %or% and & checks 2011-11-08 21:56:54 +01:00
Richard Quirk 4cb97edbaf Improved same expression check for ticket #3274
Expand the logic for the check for the same expression on both sides of
the || and && operators. Now expressions can be more complex, with the
"alt" variable helping to fudge operator precedence to avoid false
positives.
2011-11-08 21:54:42 +01:00
Edoardo Prezioso 3cc9a333c9 Fixed tokenizer: don't change '*(str+num)' if '*' means a product with a previous variable or number.
Ditto for '&str[num]' (still commented).
2011-11-08 18:14:43 +01:00
Edoardo Prezioso a546fc6e9d Fixed ticket #3310 (segmentation fault of cppcheck) 2011-11-08 17:37:24 +01:00
Edoardo Prezioso aaa77c4709 Improve tokenizer: remove more redundant parenthesis and add a prototype code for: '&str[num]'=>'(str+num)' with reporting non obvious test failures. 2011-11-07 23:40:06 +01:00
Marek Zmysłowski fed875f4a4 Fix #70 (Locate memory leaks when alloc happens in function parameter)
http://sourceforge.net/apps/trac/cppcheck/ticket/70
2011-11-07 23:50:57 +02:00
Reijo Tomperi 7b7e072b88 Fix #3278 (FP: Possible null pointer dereference with for loop)
http://sourceforge.net/apps/trac/cppcheck/ticket/3278
Bail out if token "for" is encountered.
2011-11-07 22:10:21 +02:00
Edoardo Prezioso 5cf7cb9ff5 Conforming style: always use 'std::' namespace where needed. This removes the mixing style inside the code. 2011-11-07 00:54:00 +01:00
Thomas Jarosch a83c47d9cf Fix false positive of %or% match in alternative pattern match code
%or% triggered on code using "|=" or "||".
2011-11-06 22:12:31 +01:00
Richard Quirk 7f88b66842 Fix namespaced types for auto_ptr new[] errors
This fixes false negatives for code such as:

    std::auto_ptr<foo::bar> p(new foo::bar[10]);

The idea is to find a "new", search for the end token ";", then see if
the declaration ends in a closing square bracket. Also fixes other cases
that checked for "new %type% [" so that they work with namespaces.
2011-11-06 21:20:24 +01:00
Daniel Marjamäki fa076598ad Fixed #3233 (false positive: (style) Checking if unsigned variable 'i' is less than zero.) 2011-11-06 18:24:37 +01:00
Thomas Jarosch 19c9c97608 Fix single %op% operator not working at all
When parsing the Token::Match pattern, we accesed
the wrong character in the pattern and never
executed the %op% check.

In addition the unit test function for %op%
wasn't registered in the test suite. Ups.

All fixed now and also provide a complete
check for all operators %op% supports.
2011-11-06 18:02:18 +01:00
Edoardo Prezioso 6e2f2816de Improve same expression check: remove '%op%' pattern and add ',' for the same expressions as an argument inside a function.
Improve compound assignment simplification: use already defined 'isAssignmentOp' and extend the adding parenthesis to a generic operator, not only to the arithmetical ones. See: http://en.cppreference.com/w/cpp/language/operator_precedence
2011-11-06 14:35:53 +01:00
Daniel Marjamäki f092779a4d Fixed #3282 (Invalid report that an array index is of type char.) 2011-11-06 11:26:28 +01:00
Daniel Marjamäki ed97b62610 Fixed #3275 (Missing includes always reported) 2011-11-06 08:59:07 +01:00
Daniel Marjamäki e11c1f7975 Fixed #3265 (false positive: comparison of bool with nonzero integer) 2011-11-06 08:21:34 +01:00
Edoardo Prezioso 99463d3368 Improve same expression check: take count of operations and assignments before the same expression and add missing 'return' pattern to the struct member variable part of the check. 2011-11-05 22:25:01 +01:00
Daniel Marjamäki d4a8184339 Fixed #3251 (Redundant code: Found a statement that begins with numeric constant) 2011-11-05 20:28:52 +01:00
Daniel Marjamäki 9903c8c0d9 astyle formatting 2011-11-05 20:00:18 +01:00
Daniel Marjamäki 2f32965bdf Token: assert that multicompare patterns don't begin with some %% command 2011-11-05 19:59:48 +01:00
Daniel Marjamäki 5edf153602 Fixed #3294 (Token::Match multi compare false negative) 2011-11-05 19:24:21 +01:00
Daniel Marjamäki 580fef6951 Merge pull request #55 from richq/sameexpr
Improve for same expression on both sides of operator
2011-11-05 10:28:14 -07:00
Richard Quirk a3f2c1e651 Improve for same expression on both sides of operator 2011-11-05 15:46:11 +01:00
Richard Quirk 68202d8ffb Extra check for auto_ptr new[]
This fixes cases like this:

   auto_ptr<foo> bar(new foo[10]);

which previously did not work correctly.
2011-11-05 15:45:59 +01:00
Daniel Marjamaki b96ab6ba26 Fixed #3188 (Function parser false positive) 2011-11-05 12:23:05 +01:00
Daniel Marjamäki 085a6285fa Fixed #3117 (Tokenizer::simplifyKnownVariables : Don't simplify static variable that is changed) 2011-11-05 08:30:11 +01:00
Daniel Marjamäki d3b27c40fc fixed --doc output 2011-11-05 07:45:30 +01:00
PKEuS 0c469bae41 Fixed #3089 (New Check: Detect wrong usage of printf/scanf) 2011-11-05 07:29:53 +01:00
Thomas Jarosch 4342fd254c Fixed #3266 (False positive on dangerous usage of .c_str()) 2011-11-04 19:21:19 +01:00
Reijo Tomperi 682aae3196 Improve internal error print out, print line number with the error message. 2011-11-03 22:43:13 +02:00
Daniel Marjamäki 9b8ffe7219 Fixed #3248 (Tokenizer: better handling of char constants that are compared with numeric constants) 2011-11-03 20:03:31 +01:00
Daniel Marjamäki 73f3b2074b Fixed #3285 (wrong #elif behaviour) 2011-11-03 19:05:48 +01:00
Daniel Marjamaki b6b5416b42 Tokenizer: Fixed failed unit test 2011-11-02 20:42:38 +01:00
Daniel Marjamaki dfcbc38466 Preprocessor: Don't warn about missing system headers during 'normal' preprocessing 2011-11-02 18:40:56 +01:00
Daniel Marjamaki 0884204c2f Fixed #3279 (Token::Match called with varid 0) 2011-11-02 18:31:13 +01:00
Daniel Marjamäki af7bf5c805 removed 'explicit constructors' check. see comments in pull request #51 for the reasons. 2011-11-02 17:12:46 +01:00
Daniel Marjamaki 937a4497ca Fixed #3272 (Internal error) 2011-11-01 18:03:32 +01:00
Edoardo Prezioso 9dd3360cd6 Fix some complainted choices made in my older commits.
Note: probably you should do 'make clean' before using 'make' to rebuild it again. Maybe it's me but 'make' reports various errors when linking.
2011-11-01 13:23:47 +01:00
Daniel Marjamäki b18778129c STL: updated error messages for 'useless call to find/swap/substr'. Ticket: #3258 2011-10-31 21:32:30 +01:00
Daniel Marjamäki 7d7a54d89c Merge pull request #53 from gansb/master
Add missing newline
2011-10-31 11:53:33 -07:00
Daniel Marjamäki a7f27a83a7 Fixed #3271 (Regression: something related to symbol database / varid) 2011-10-31 18:33:15 +01:00
Benjamin Goose f22f9fcc0e Add newline at end of file! 2011-10-31 15:12:29 +01:00
Edoardo Prezioso 4295439e53 Fixed ticket #3269 (Regression, I think it's somehow related to symbol database) 2011-10-31 15:05:52 +01:00
Edoardo Prezioso ba5909ef1d General code tweaking, nothing strange. 2011-10-31 02:24:59 +01:00
Daniel Marjamaki f2199adc3f Preprocessor: Bailout #include if it is recursive 2011-10-30 19:00:11 +01:00
Daniel Marjamäki 278ba0ab3a Preprocessor: Enable 'normal' preprocessing whenever any defines are given. The special define CPPCHECK-TEST isn't needed anymore. 2011-10-30 18:40:59 +01:00
Edoardo Prezioso 433f4640a9 Fix some GCC warnings regarding the sign conversion. 2011-10-30 18:34:49 +01:00
Daniel Marjamäki f7fe665b00 Fixed #3231 (False positive: uninitialized variable '({...})') 2011-10-30 18:19:09 +01:00
Daniel Marjamäki 63937f592e Fixed #3228 (false positive: possible null pointer dereference) 2011-10-30 17:59:38 +01:00
Daniel Marjamäki 7035d4cdd2 astyle formatting 2011-10-30 17:41:05 +01:00
Daniel Marjamaki 71f08d0a66 Fixed #3222 (false positive: Uninitialized variable with function pointer) 2011-10-30 17:22:30 +01:00
Edoardo Prezioso 4fc7e86d7d Fixed: with checkConst and checkVariableScope wanted still required "information" settings instead of "style". 2011-10-30 10:58:15 +01:00
Daniel Marjamaki 132f0e12d1 CheckClass: Added classInfo about explicit checking 2011-10-30 09:54:02 +01:00
Daniel Marjamaki 8514466c68 Visual Studio: Fixed compiler error 2011-10-30 09:53:14 +01:00
Daniel Marjamäki 0d1046eeeb Merge pull request #51 from richq/explicit
Explicit constructors
2011-10-30 01:38:26 -07:00
Edoardo Prezioso 42fd4e2f52 Tokenizer: Change 'var++|--;' into '++|--var;' and remove redundant 'tokAt(0)'. 2011-10-29 22:25:49 +02:00
Daniel Marjamäki 92333b585a Fixed #3092 (Tokenizer::setVarId : shadow variable in member function gets the wrong varid) 2011-10-29 21:25:58 +02:00
Daniel Marjamäki d7be62a6f9 Fixed #3221 (FP: Array 'arr[2147483648]' index 0 out of bounds in loop when size unknown to cppcheck) 2011-10-29 20:26:24 +02:00
Daniel Marjamäki 24a2b6e6ba Fixed #3195 (operator() from a functor-struct is never used) 2011-10-29 20:04:43 +02:00
Daniel Marjamäki a809bb3471 astyle formatting 2011-10-29 19:51:11 +02:00
Daniel Marjamäki acaa9c456f Fixed #3152 (Tokenizer: template constructor is removed) 2011-10-29 19:45:47 +02:00
Daniel Marjamäki 316aa920eb Fixed #3245 (False positive: Dangerous usage of 'string' (strncpy doesn't always 0-terminate it)) 2011-10-29 19:11:42 +02:00
Richard Quirk a0a5b36667 Ensure single-argument constructors are explicit 2011-10-29 18:24:30 +02:00
Richard Quirk 2ca932a3ae Add checks for explicit constructors
Single-argument constructors should be explicit. Constructors with
multiple arguments should not be marked explicit.
2011-10-29 18:24:16 +02:00
Daniel Marjamäki 8f49eb6a7e Tokenizer: Make sure that friend classes don't get varid. Ticket: #2962 2011-10-29 18:22:58 +02:00
Daniel Marjamäki d75ef01d2b Null pointer: Added inconclusive error message when calling member function of NULL object. 2011-10-29 15:48:54 +02:00
Daniel Marjamäki 3c509589b5 use reportInconclusiveError instead of reportError if checking is inconclusive 2011-10-29 15:16:27 +02:00
Reijo Tomperi 12a10a7297 Fix related to previously fixed #3256 (Null pointer dereference not detected)
Use reportInconclusiveError() instead of reportError().
2011-10-29 15:55:52 +03:00
Daniel Marjamäki a79b5a5c36 astyle formatting 2011-10-29 12:53:08 +02:00
Daniel Marjamäki f04210ad9f updated comment. removed a inconclusive condition, I don't think it's needed. 2011-10-29 12:52:46 +02:00
Thomas Jarosch ad40586e96 Disable internal checks if NDEBUG is defined (release build) 2011-10-29 12:47:12 +02:00
Daniel Marjamäki 6c02de151f strncmp sizeof: tweaked the check. 2011-10-29 12:27:19 +02:00
Thomas Jarosch 3d438003ff Add internal check that searches Token::Match() patterns for missing % end charaters
Example: "%type" or "foo %var bar"
2011-10-29 12:22:26 +02:00
Daniel Marjamäki 8416768e03 Merge pull request #50 from richq/strncmp
Improved strncmp checks
 * strings are always the same
 * inconclusive: using sizeof(char *) as size parameter
2011-10-29 03:13:21 -07:00
Thomas Jarosch 2b8da1241b Add missing percent end character 2011-10-29 12:08:36 +02:00
Richard Quirk 45d0709ed5 Only run sizeof(char*) check if inconclusive is set 2011-10-29 11:59:24 +02:00
Richard Quirk c2d7824130 Move string comparison out of the report function 2011-10-29 11:52:19 +02:00
Reijo Tomperi 5e0e2c4782 Fix #3256 (Null pointer dereference not detected)
http://sourceforge.net/apps/trac/cppcheck/ticket/3256
It is now detected if --inconclusive command line argument is given (the argument is unofficial currently)
2011-10-29 11:35:31 +03:00
Marek Zmysłowski 950460c0a7 Fixed #3261 (Function 'find' useless call. The variable 'str' is using function 'find' against itself) 2011-10-29 09:24:05 +02:00
Edoardo Prezioso 5d868766c7 Tokenizer time improvements (time says real: -1 second)
1)change tokAt(1|-1) with next()|previous() with conditions where necessary;
2)change strAt(1|-1) with next()|previous()->str() with conditions where necessary;
3)change tokAt(n)->str(), with n != -1,1, to strat(n);
4)change simplifyFuncInWhile implementation because it was too slow and stupid.
2011-10-29 01:57:53 +02:00
Edoardo Prezioso dd719b41bf Definitely check correctly 'sizeof %num%' when '%num%' has '-' sign. 2011-10-29 00:11:38 +02:00
Thomas Jarosch dee03a09e4 Fix logic glitch
Reported by Pc-Lint 9.x :o)

The code was working before as the AND operation
also matched in that specific case.

I verified that code is in use by commenting
it out and checked how many tests failed.
2011-10-28 23:36:30 +02:00
Thomas Jarosch f6e68914ea Add check for cppcheck's internal API usage (#3263)
First checks:
- Simple pattern used inside Token::Match()
- Complex pattern used inside Token::simpleMatch()

The checks get enabled by passing "--enable=internal".
It's not included in "--enable=all".

If you see something that needs further tweaking, just go for it!
2011-10-28 22:46:07 +02:00
Richard Quirk 665cdfabdc Warn when sizeof is used in strncmp ticket #2095
This checks for the case where the user thought sizeof(buf) gave the
size in bytes of 'buf' in code like the following:

  const char *buf = "Hello World";
  strncmp(buf, other, sizeof(buf));
2011-10-28 22:14:55 +02:00
Richard Quirk 90c7db15a0 Add check for comparison of identical string variables 2011-10-28 22:12:51 +02:00
Richard Quirk 4ba6ac7332 Add strncmp to the list of static string comparison functions 2011-10-28 22:12:51 +02:00
Edoardo Prezioso 979f3b051c Improve nextArgument by returning 0 if there's an unexpected ';'. 2011-10-28 18:57:10 +02:00
Thomas Jarosch ef8f49bbf3 Use new findsimplematch API for simple patterns 2011-10-28 12:49:03 +02:00
Edoardo Prezioso bab740289c Complete todo: convert 'for' into 'while'.
It's not possible to enable this code because of the disaster it will be created for all the checks with the 'for' pattern.
2011-10-28 00:50:54 +02:00
PKEuS 49fd057e17 Tokenizer: Simplify 'foo(void)' to 'foo()' 2011-10-27 19:56:59 +02:00
PKEuS 845e5d259a Improved isJavaOrCSharp, isC and isCPP. Fixed isC for files with includes. 2011-10-27 19:18:54 +02:00
Thomas Jarosch 22251d50bb Bugfix: Use Token::Match instead of Token::simpleMatch because it's a complex pattern
This bug was in here before my recent refactoring.

(And yes, I wrote a check for cppcheck's Token::Match invocation ;))
2011-10-27 16:43:04 +02:00
Thomas Jarosch 434fb933a8 Implement Token::findsimplematch und use it for simple patterns 2011-10-27 15:59:22 +02:00
Thomas Jarosch 54adb910ec Use Token::simpleMatch instead of Token::Match for simple patterns 2011-10-27 15:59:22 +02:00
Daniel Marjamaki 5f4c882b08 minor formatting updates of --doc output 2011-10-27 10:50:40 +02:00
Edoardo Prezioso 9bb1a1b7a5 Added code for simplification of 'for ( a; b; c;); -> '{ a; for (; b; c;) ; }'.
It's not enabled because it fails many tests with testrunner.
2011-10-27 02:59:50 +02:00
Edoardo Prezioso 1be1af4afb Move the simplification of 'strlen' in simplifyTokenList.
This way it's possible to omit the call to simplifyKnownVariables before 'strlen'.
2011-10-27 01:24:35 +02:00
seb777 aa74761e8d fix isC method (.C files are C code files) 2011-10-26 22:54:00 +02:00
Thomas Jarosch 43e9c1f0bd STL check: Detect return of implict string conversion + .c_str()
Examples are:

    std::string msg;
    return ("ERROR: " + msg).c_str();

or

    return ("ERROR: " + std::string("crash me")).c_str();
2011-10-26 22:14:47 +02:00
Thomas Jarosch c4dabd61e9 STL check: Check if someone tries to return std::string(crash_me).c_str() 2011-10-26 21:45:27 +02:00
Thomas Jarosch 84a763d3b0 Run astyle 2011-10-26 21:15:44 +02:00
Thomas Jarosch 03fd308dbf STL check: Look for string.c_str() / stringstream.str().c_str() "return" usage (object is destroyed on return) 2011-10-26 21:12:06 +02:00
seb777 de71c41379 Fixed Ticket 2144 (false negatives: Old Style Pointer Cast apply only on .cpp files) 2011-10-26 21:17:27 +02:00
Daniel Marjamaki 4b57a146fb Preprocessor: Unit test #error and missing includes. Ticket: #2131 2011-10-25 19:55:47 +02:00
Daniel Marjamaki 40dcab0b6b Preprocessor: Report missing includes during 'normal' preprocessing. Ticket: #2131 2011-10-25 18:16:03 +02:00
Marek Zmysłowski 190139f441 Fixed #3174 (New check: Useless calls of STL functions) 2011-10-24 23:25:23 +02:00
Daniel Marjamäki a076b24dc6 astyle formatting 2011-10-24 21:57:49 +02:00
Thomas Jarosch 3413ffef3e Refactor readlink() buffer check to also handle readlinkat() 2011-10-24 21:23:18 +02:00
Daniel Marjamaki 7fa58b455b Preprocessor: Make it possible to use the 'normal' preprocessor by using special command -DCPPCHECK-TEST. Ticket: #2131 2011-10-24 20:59:46 +02:00
Daniel Marjamaki 0eb4e3032a Preprocessor: handle '#undef' better. Ticket: #2131 2011-10-24 19:51:00 +02:00
Daniel Marjamaki 08ba378730 Preprocessor: Improved 'normal' preprocessing. better handling of multiple #elif and #else blocks 2011-10-24 08:11:44 +02:00
Daniel Marjamaki 3de70a7244 Preprocessor: Better 'normal' preprocessing. Simple handling of '#elif' 2011-10-24 07:37:47 +02:00
Edoardo Prezioso df5d26901c Add new warning option to check for dead code and change the order of some struct members to reduce structure padding. 2011-10-24 03:02:00 +02:00
Thomas Jarosch 55a079a7c4 Clarify Token::concatStr() documentation 2011-10-23 22:47:49 +02:00
Thomas Jarosch 1ccb57e595 Document and test Token::concatStr() 2011-10-23 21:21:42 +02:00
Thomas Jarosch 5b97cc1440 Bugfix: Update token properties on string changes 2011-10-23 21:06:56 +02:00
Daniel Marjamaki 9e50b7cb68 Preprocessor: updates to 'normal' preprocessing 2011-10-23 19:17:29 +02:00
PKEuS cdfe0d74e4 Make checkSprintfCall using nextArguments() 2011-10-23 17:47:48 +02:00
PKEuS dfedeeb5c1 Bugfix: checknullpointer worked incorrect for complex first 2011-10-23 15:23:36 +02:00
Thomas Jarosch db8c7deb30 Fixed #3232 (Check if container is modified inside BOOST_FOREACH) 2011-10-23 13:07:43 +02:00
Thomas Jarosch 6047a28902 Fixed #3185 (Add three more exit functions) 2011-10-23 12:23:53 +02:00
PKEuS 54b3d72ee3 Added Token::nextArgument() 2011-10-23 11:23:48 +02:00
Erik Lax b7ab1e7d7e Fixed #3237 (Bug in parser of class operator functions) 2011-10-23 10:25:14 +02:00
Reijo Tomperi bf2759118b Added support for C++11's cend/crend/cbegin/crbegin functions in some STL checks
Patch from: PKEuS <philipp.kloke@web.de>
2011-10-22 23:38:03 +03:00
Reijo Tomperi 3568b5a841 Improved memset with 0 bytes check. TODO done (unit test).
Patch from: PKEuS <philipp.kloke@web.de>
2011-10-22 23:34:10 +03:00
Edoardo Prezioso 91c6608175 Improve fix of #934 (be careful of macros code). 2011-10-22 20:43:42 +02:00
PKEuS 20179673ce Fixed #934 (new check: missuse of std::cout) 2011-10-22 17:12:52 +02:00
Edoardo Prezioso 12f6ce46f8 Add more warnings and fix the ones reported by them. 2011-10-22 15:05:43 +02:00
Johan Samuelson 3d8fa2f76e Fixed #3123 ([False Positive] Shadowed enum) 2011-10-22 13:43:53 +02:00
Daniel Marjamäki 32e20d4e31 made 'variableHidingTypedef' inconclusive. See ticket #3199 2011-10-22 13:26:33 +02:00
Erik Lax 2b54f00c87 Fixed #3238 (Crash in obsolete functions check.) 2011-10-22 12:36:45 +02:00
PKEuS ccf087d2ea checkMathFunctions: Refactoring the check 2011-10-22 12:31:47 +02:00
Thomas Jarosch 55d9f0873a Fix #3243 (Improve non reentrant function check)
- Use std::map instead of linear std::list walk
  and run fast tests like tok->isName() first.

  Global speed up is 4.8% (profiled with google-perftools)

- Catch function invocations in global namespace
  and ignore other namespaces except "std".

  std::localtime() and others are also non-thread safe on POSIX.

  Note: The check matches f.e. also on "std::getrpcbyname()",
  but that would result in a compile error anyway.
  No need to have an extra "std::xxxxx" whitelist.

- Remove double listed "rand" and "getrpcbyname" function names
2011-10-22 11:54:52 +02:00
Daniel Marjamäki a9d2d45fbc astyle formatting 2011-10-22 11:11:54 +02:00
Marek Zmysłowski 8157799e10 Fixed #3204 (Refactor standards support in Settings) 2011-10-22 10:34:04 +02:00
Daniel Marjamäki cde95d09a3 Merge pull request #41 from gansb/master
std::istream used but not declared.
2011-10-22 00:54:04 -07:00
Daniel Marjamäki ab827e3631 Merge pull request #40 from joshbeck/master
Added option to set #ifdef configuration check limit
2011-10-22 00:51:05 -07:00
Marek Zmysłowski b332ea8222 Fixed #3204 (Refactor standards support in Settings) 2011-10-22 09:45:48 +02:00
Benjamin Goose 3f25bd9530 Qualify fill_n properly.
Relying on ADL isn't a good idea as it's not always well implemented.
2011-10-20 09:02:20 +02:00
Benjamin Goose 463b105d98 Add condition for HP-UX. 2011-10-20 09:01:58 +02:00
Benjamin Goose 7d6b76e1d1 Include <iosfwd> for std::istream. 2011-10-20 08:46:29 +02:00
seb777 41d9daa03d Fixed ticket #3133 (Improve Check: Found obsolete function)
- add check for std::gets
- improve check when multiple obsolete functions are used
- remove false positive (declared functions)
2011-10-19 20:21:50 +02:00
Edoardo Prezioso 9257e82475 Improve tokenizer: don't confuse between a label and the case/default statements. 2011-10-19 18:49:02 +02:00
Edoardo Prezioso 882b0c15a0 Improve tokenizing of "do{ ... } while(0)".
The simplification will be the same for every combination, except for the 'continue' and the 'break'. In that case, keep the block braces.
2011-10-19 18:20:29 +02:00
Edoardo Prezioso c9ee19c654 Complete 'disable the rules by default' for other platforms. 2011-10-19 15:14:39 +02:00
Edoardo Prezioso 4f256ef314 Runastyle + removal of useless conditions after previous commit. 2011-10-19 14:48:08 +02:00
Edoardo Prezioso 73f0e2c5b9 Fixed ticket #3227 (Improve tokenizer: labels are not handled correctly after a case or another label instruction)
Moved the labels simplification after combining the tokens and moved the case/default simplification inside the labels.
2011-10-19 14:20:09 +02:00
Joshua Beck 56561835f8 Add option to set #ifdef configuration check limit 2011-10-18 19:52:55 -05:00
Edoardo Prezioso f4cdf57955 Fixed ticket #3229 (Segfault with goto):
Don't handle labels, gotos, returns and indentations inside the round braces. This is applied not only for simplifyGoto, but also to simplifyFlowControl.
Rewrite enum badly handled by astyle inside mathlib.cpp and move simplifyFlowControl at the end of the simplifyTokenList in order to catch more dead code, not related to the ticket.
2011-10-18 23:56:35 +02:00
PKEuS dc15641954 Fixed #3223 (Improve check: Check more STL algorithms for missmatching containers check) 2011-10-18 21:55:41 +02:00
PKEuS ea02bd905a Fixed #3225 (Boolean comparison with string literals) 2011-10-18 21:37:03 +02:00
Daniel Marjamäki 3d18fdfa3f Fixed #3220 (False positive: possible null pointer dereference: 'SwDoc *pDoc = NULL; pDoc->do_something();') 2011-10-18 19:34:14 +02:00
Daniel Marjamäki 03ff25f152 gcc: fixed compiler warnings/errors 2011-10-17 20:32:59 +02:00
Daniel Marjamaki bf0386c938 Preprocessor: Started working on new preprocessing that uses -D information better. Ticket: #2131 2011-10-17 20:12:46 +02:00
Edoardo Prezioso de8eb48a5c Remove redundant function findmatch inside tokenize.cpp.
There's Token::findmatch which is already used inside other Tokenizer functions.
2011-10-17 13:46:27 +02:00
Edoardo Prezioso c3caade3ca - Fixed mispelled function name;
changed variable name inside simplifyFlowControl for consistency;
improved simplifyFlowControl to handle better this kind of code:
"return; { { } { label : ; ok ( ) ; } }"->"return ; { { label: ok ( ) ; } }".
2011-10-17 02:16:49 +02:00
Daniel Marjamäki 4705026242 fixed a few doxygen warnings 2011-10-16 17:16:07 +02:00
Ettl Martin 1a710e5761 fixed regression on linux due to missing include 2011-10-16 14:16:35 +02:00
PKEuS f8074b71d2 Fixed #2470 (False negative: Possible null pointer dereference (C++0x keyword 'nullptr')) 2011-10-16 12:54:58 +02:00
Daniel Marjamäki 32496fb009 Token: Updated comments 2011-10-16 08:25:11 +02:00
Thomas Jarosch a52b73f9f9 Fix #3208 (Simplify pointer to standard type, C only)
The symbol database is unavailable during token simplification
and &data[0] might return something completely different for C++.

Moved code_is_c() from checkOther to Tokenizer.
2011-10-16 08:09:57 +02:00
Daniel Marjamäki 1ec32e27db Borland: Fixed compiler errors 2011-10-16 07:52:54 +02:00
Daniel Marjamäki d5883ef0c4 astyle formatting 2011-10-16 07:50:34 +02:00
PKEuS 71a1d98693 Fixed ##3211 (Crash in gitHEAD when arglist count is smaller than format string) 2011-10-16 07:06:18 +02:00