Commit Graph

5524 Commits

Author SHA1 Message Date
orbitcowboy 9c08885caf MathLib:IsNullValue(): using a Finite State Machine to determine a string value contains a numeric NULL value. The NULL value can be Integer, Binary, Hex, Octal. The corresponding unit test cases are also included. 2014-04-11 01:27:05 +02:00
orbitcowboy 66329fe8b8 posix.cfg: Fixed FP for isatty() function and added unit cases. 2014-04-10 17:53:04 +02:00
Robert Reif 7eb3988415 Fixed #5659 (False negative: mismatching allocation / deallocation whith using namespace) 2014-04-11 05:40:37 +02:00
Alexander Mai ab2f8bfba3 Tidy up MathLib::isInt() - using a state machine approach 2014-04-10 22:46:55 +02:00
PKEuS b10fce304e Don't suggestInitializationList for arrays used as initializer (#5640) 2014-04-10 22:28:02 +02:00
PKEuS c33498fa0b Fixed false positive redundantAssignment when operator() is called (#5568) 2014-04-10 21:56:30 +02:00
Alexander Mai 559a2bc2c8 Avoid FP exceptThrowInNoThrowFunction and exceptThrowInNoexecptFunction 2014-04-10 21:55:49 +02:00
PKEuS e39b89efc3 Throw more syntaxErrors from SymbolDatabase, fixing #5663 2014-04-10 20:11:03 +02:00
PKEuS 25b1f2f541 Fixed #5643 (crash on address-of-operator& in condition) as suggested by serval2412 2014-04-10 19:49:21 +02:00
Alexander Mai e19129a409 Fix #4724 (Error in calculation shift operation: wrong sign: 1UL << 63) 2014-04-10 19:22:14 +02:00
Robert Reif b0af67f369 Fixed #5486 (false positive: (warning) %zd in format string (no. 1) requires 'ssize_t' but the argument type is 'ssize_t {aka long}'.) 2014-04-10 17:25:11 +02:00
Robert Reif 847d28d283 Fixed #5638 (is there any plan to check noexcept correctness?) 2014-04-10 16:17:10 +02:00
Robert Reif 4ae204e46b Fixed #5659 (False negative: mismatching allocation / deallocation whith using namespace) 2014-04-10 16:11:11 +02:00
Daniel Marjamäki c8ae1e4751 Fixed #5658 (false positive: (error) Uninitialized variable: s) 2014-04-10 15:59:37 +02:00
orbitcowboy baf8d09a0d Fixed FP for nullpointer dereference when using putchar. 2014-04-09 17:02:17 +02:00
Daniel Marjamäki 9b1d058410 Fixed #5660 (false positive: (error) Uninitialized variable: result) 2014-04-10 06:40:53 +02:00
Daniel Marjamäki 59cd1879db Fixed #5467 (False positive incorrectly claiming use after erase) 2014-04-09 10:32:56 +02:00
orbitcowboy dd61c5db47 Fixed FP, nullpointer for memchr. 2014-04-08 18:39:50 +02:00
Alexander Mai 89dc652af9 #5631 Typo and misleading error message in negativeMemoryAllocationSize 2014-04-08 20:23:00 +02:00
Alexander Mai a06371e063 Fixes for Doxygen + code formatting 2014-04-07 20:39:19 +02:00
unknown 9ae59290dd #5645 False positive Null pointer derefence about first argument to fputc() 2014-04-07 12:08:34 +02:00
Daniel Marjamäki d7e2e3bd5e Fixed #5502 (FP: Dereferencing 'b' after it is deallocated / released) 2014-04-06 18:45:24 +02:00
Daniel Marjamäki 049d68ae7d AST: Fixed bad syntax tree for 'if (x()[0]==1);' 2014-04-05 08:03:24 +02:00
Alexander Mai 173a2e9ea2 #5641 fix crash within CheckClass::initializeVarList() 2014-04-04 22:13:51 +02:00
Daniel Marjamäki 71fda0ea0c Fixed GCC warning about shadowed variable settings 2014-04-04 07:02:36 +02:00
Daniel Marjamäki 8dcb3bae47 Refactoring checks of overlapping conditions in if and else-if 2014-04-03 19:35:50 +02:00
PKEuS d4765bccc3 Refactorized inefficient usage of std::string and const char[] (part 2). 2014-04-03 14:56:14 +02:00
Daniel Marjamäki a6557f8c74 Null pointer: Fixed false positive discovered by Travis when self-checking cppcheck 2014-04-02 19:39:42 +02:00
Daniel Marjamäki bc9bb17025 Refactor CheckOther::oppositeInnerCondition() using AST and isSameExpression() 2014-04-02 16:54:01 +02:00
PKEuS e9411e05ba Refactorized inefficient usage of std::string and const char[]. 2014-04-02 13:56:34 +02:00
Daniel Marjamäki 830249d72e Fixed #5510 (FP: nullPointer - variable initialized in function call) 2014-04-01 07:06:20 +02:00
PKEuS e0574feabd Fixed problems with unknown macros for inline class methods in SymbolDatabase (#5621) 2014-03-31 21:04:01 +02:00
PKEuS 025850d961 Support unknown THROW()-style macros in symboldatabase; Fixed #5056.
Simplified related code.
2014-03-31 20:33:01 +02:00
Daniel Marjamäki 484483bd5d AST: fixed ast for 'for (*x=0;y;z)' 2014-03-31 17:16:13 +02:00
Daniel Marjamäki 225fb96554 Fixed #5627 (False positive assignBoolToPointer) 2014-03-31 15:55:54 +02:00
Daniel Marjamäki 963a8b51cc "automatic conversion from iso-8859-1 formatting to utf-8" 2014-03-31 00:33:43 +00:00
PKEuS 060f9035c9 Fixed crashs on garbage code (#5604) 2014-03-30 11:38:01 +02:00
PKEuS 345a80f4d5 Fixed #5621 and slightly simplified symboldatabase code. 2014-03-30 11:06:44 +02:00
Alexander Mai 70885c78e4 Fix endless recursion within CheckClass::isConstMemberFunc() caused by incomplete/missing template declaration 2014-03-30 10:09:57 +02:00
Alexander Mai bf335217cd Fix #5605 part 2 - now endless recursion within CheckClass::isMemberFunc() 2014-03-30 08:31:02 +02:00
Daniel Marjamäki e5301b2b7a ValueFlow: Improved valueflow of for loop 'for (i=a; i<10; i++)' => unknown start value but end value is known 2014-03-29 20:20:22 +01:00
Daniel Marjamäki 407c9fdf9d Refactored checkNegativeBitwiseShift() so it uses ast and valueflow 2014-03-29 13:01:30 +01:00
Alexander Mai d1b1699bb0 Fix #5606 - Endless recursion in CheckClass::isMemberVar(). New function Type::hasCircularDependencies() is supposed to detect loops within the class hierarchy which was causing the problem 2014-03-29 12:21:35 +01:00
Alexander Mai d6888410ec Ticket #3322: Add test cases. The bug got fixed long time ago 2014-03-28 20:09:22 +01:00
PKEuS a01bfcb62d Fixed a few cppcheck messages 2014-03-28 18:55:16 +01:00
PKEuS a16d631813 Further improvements to setVarId and function/array pointer detection in SymbolDatabase (#2872) 2014-03-28 17:43:40 +01:00
PKEuS 1c58628223 Handle pointer/reference to array in setVarId (#2645) 2014-03-28 16:10:27 +01:00
PKEuS 50a94885ce Fixed oppositeInnerCondition check:
- Resolved false positives #4170 and #4186, as well as numerous other potential false positives
- Improved message to point to both locations
- Inner condition could also be a while loop; Outer if could also be 'else if'
- Made the check non-experimental again (#3645)
2014-03-28 14:55:17 +01:00
Matthias Krüger e1f759b5b8 run dmake 2014-03-28 13:50:02 +01:00
PKEuS c078b3fced Added testing of samples/ to testrunner (#3515). 2014-03-28 13:06:38 +01:00
PKEuS 838cac5a3a Added unit test for #1473. 2014-03-28 11:34:23 +01:00
PKEuS 3950a62ef2 Added unit test for #2626 2014-03-28 10:06:24 +01:00
PKEuS 63254b33f9 Fixed uncaught exception in testbufferoverrun.cpp 2014-03-27 19:55:11 +01:00
PKEuS 825b8b7c66 Unit test for #3589 2014-03-27 19:16:30 +01:00
PKEuS a6ca3cf2cf Throw syntaxError when encounter one in symboldatabase (fixes #5572) 2014-03-27 19:06:13 +01:00
PKEuS efe3f834be Refactorized handling of syntaxError: Print debug output, removed a few return values that are no longer required 2014-03-27 18:41:52 +01:00
Daniel Marjamäki 581886636d CheckBool::checkComparisonOfBoolExpressionWithInt: Rewrite the check using AST instead of token list 2014-03-27 16:10:43 +01:00
PKEuS 9b307cf8e0 Improved readability of testsuite output when ASSERT_EQUALS_MSG fails.
Fixed another true positive in checkbufferoverrun.cpp
AStyle
2014-03-27 16:06:30 +01:00
PKEuS 7e4081f7f5 Treat syntaxError and cppcheckError as InternalErrors (throw as exception, #4268) 2014-03-27 13:15:21 +01:00
PKEuS b23aebf2f0 Show redundantCopyLocalConst for STL types (#4331) 2014-03-27 11:15:17 +01:00
PKEuS 379807a8ea Fixed TODO_ASSERT_EQUAL and #5614 caused by bad simplification of return values. 2014-03-27 11:04:31 +01:00
Daniel Marjamäki 2248cdfea0 CheckBool::checkAssignBoolToPointer: Refactor to use AST. 2014-03-27 05:39:48 +01:00
PKEuS f71a4ad216 Improved information message on missing headers when included with <> (#4772) 2014-03-26 15:22:22 +01:00
PKEuS 6c4e8761c8 Fixed false positive "unused function" #5113. 2014-03-26 12:34:21 +01:00
PKEuS 1677e2913e Regression test for #5061. 2014-03-26 12:17:27 +01:00
PKEuS 848d079c71 Refactorized detection of function usage in CheckUnusedFunction, fixed #5358 2014-03-26 09:12:41 +01:00
PKEuS 02f38772cc Refactorization: Use SymbolDatabase to find functions in CheckUnusedFunctions 2014-03-26 08:54:56 +01:00
Daniel Marjamäki 6da9cca4ab fixed unit test that I broke by mistake 2014-03-25 21:45:25 +01:00
Daniel Marjamäki 87daf5783e buffer overflow: clean up old checking for negative index 2014-03-25 20:37:32 +01:00
Daniel Marjamäki c8004a8d31 Buffer overruns: Use ValueFlow to detect negative index 2014-03-25 18:22:22 +01:00
PKEuS 9b4b90f6a0 Avoid loading libraries multiple times in test suite
-> Massive speedup for test suite (especially on slow systems)
2014-03-24 09:59:05 +01:00
Daniel Marjamäki aa05bf0f16 ValueFlow: Improved abstract interpretation 2014-03-24 06:48:06 +01:00
Daniel Marjamäki 2a0716449f Fixed #5498 (C++0x11 default values for class fields and missing constructor) 2014-03-24 06:15:51 +01:00
Daniel Marjamäki dbc8273cb7 ValueFlow: improved abstract interpretation of for loops 2014-03-24 00:16:02 +01:00
Daniel Marjamäki c14a3d67bb ValueFlow: Handle division by zero better in abstract interpretation 2014-03-23 20:37:56 +01:00
PKEuS 1be7bfa7fe Fixed crash on invalid code (#5603) 2014-03-23 20:08:16 +01:00
Daniel Marjamäki 30fa187b30 Fixed #5549 (ValueFlow: Handle static variables better in valueFlowAfterAssign) 2014-03-23 17:57:27 +01:00
PKEuS 5f2067e401 Refactorized dead code elimination:
- Use library to get noreturn functions
- Fixed do-while simplification (#4940)
2014-03-23 10:59:41 +01:00
PKEuS 77c17100ec Bailout in private function usage checking for operators (#5059). 2014-03-23 10:06:14 +01:00
PKEuS 8d5be8c4a4 Fixed related issues to #5601 2014-03-22 22:35:20 +01:00
PKEuS 58c2f372b9 Fixed false positive when noreturn function is defined (#5601, second attempt) 2014-03-22 19:55:13 +01:00
PKEuS 6395cb9b95 Syntax error on invalid enum (#5600) 2014-03-22 19:31:01 +01:00
Daniel Marjamäki b6276058da Value Flow: Improved abstract interpretation of arithmetical expressions 2014-03-22 19:02:33 +01:00
PKEuS 77c871035b Fixed false positive when noreturn function is defined (#5601) 2014-03-22 18:57:19 +01:00
Daniel Marjamäki 7d2357de8d Refactoring. Use astIsFloat() 2014-03-22 18:42:29 +01:00
PKEuS 560cf397d3 Fixed C++11 right angle bracket issue #5150 2014-03-22 13:34:15 +01:00
Alexander Mai 6a08c27183 Fix segfault in variableIsUsedInScope() - loop variable not check against NULL 2014-03-22 11:14:11 +01:00
Alexander Mai e1c565357a Invalid code cause SIGSEGV since loop variable tok2 was not checked properly 2014-03-22 10:32:24 +01:00
Alexander Mai 37befc75ef In case of a loop within the class hierarchie Function::isImplicitlyVirtual_rec() was entering an endless loop. Tracking the previously analyzed types shall prevent this. 2014-03-22 08:49:28 +01:00
Martin Ettl e00f50b850 Fixed #5597 and added abort() support to stdcfg. 2014-03-21 17:36:48 +01:00
PKEuS 49b25b05d9 Fixed crash in CheckBufferOverrun on garbage code (#5595) 2014-03-21 13:20:44 +01:00
orbitcowboy 6507824a34 Added support for putchar() to std.cfg. 2014-03-20 05:49:38 +01:00
orbitcowboy 80e3b49cfc Added support for ftell() and puts() to std.cfg. 2014-03-20 04:10:41 +01:00
Daniel Marjamäki fc014f055f ValueFlow: Removed wrong bailout 2014-03-21 08:33:45 +01:00
orbitcowboy 30006cf06f Added support for fputs() to std.cfg. 2014-03-20 02:13:41 +01:00
Daniel Marjamäki 54e7f34f4a Fixed #5584 (FP: Division by zero when function not declared) 2014-03-20 16:12:58 +01:00
orbitcowboy b37e9601c1 Added support for fgetc() to std.cfg. 2014-03-20 00:59:52 +01:00
Daniel Marjamäki 8de4246713 Uninitialized variables: Improved handling of function calls when struct members are checked 2014-03-20 06:48:17 +01:00
Martin Ettl fe1b46c174 Extended std.cfg 2014-03-19 21:08:48 +01:00
Robert Reif 5c88934431 CheckIo: Fixed FIXME 2014-03-19 20:57:33 +01:00
Daniel Marjamäki d939aa63a6 Tokenizer: Added test case for fixed crash to prevent regressions later 2014-03-19 16:47:11 +01:00
Robert Reif 806ef44509 Fixed #5328 (Does not handle __attribute((xxx)) in typedefs) 2014-03-19 05:38:23 +01:00
Daniel Marjamäki 01c29ed15f Fixed #5518 (FP regression in 1.64: Array accessed out of bounds) 2014-03-18 17:04:33 +01:00
PKEuS a3f5beb75d Fixed problems with code "enum class { };" (which is valid C) 2014-03-18 16:23:30 +01:00
XhmikosR fc54e6acc4 Trim tailing spaces and convert tabs to spaces. 2014-03-18 17:00:28 +02:00
PKEuS 3a4b7e5c07 Fixed false positive #5578 2014-03-18 13:44:27 +01:00
PKEuS af161fc361 Rewrote CheckStl::readingEmptyStlContainer(), resolving all its false positives shown on CppChecks own code 2014-03-18 12:38:22 +01:00
Daniel Marjamäki 177bf6fcb3 Fixed #5244 (FP: (error) Uninitialized variable: ptr - initialization within if-clause) 2014-03-18 06:37:19 +01:00
Robert Reif 7b5a96dc06 Partial fix for #5536 (printf/scanf argument tests failing on Windows x64) 2014-03-18 06:12:09 +01:00
Daniel Marjamäki e240282443 Value Flow: Another try with the abstract interpretation of for loops 2014-03-17 18:43:47 +01:00
PKEuS 2568baa473 #5528: Raise duplicateExpressionError on operators /, % and -. 2014-03-17 18:35:36 +01:00
PKEuS fab6b56360 Improved check (#5553): Detect stricmp(var.c_str(), var.c_str()) 2014-03-17 17:41:45 +01:00
PKEuS 5f67bc1b0a Fixed varId problem #5293 (and its duplicate #5577): Classes inside functions are non-executable scopes. 2014-03-17 16:15:42 +01:00
Daniel Marjamäki 06618b31bb Fixed #5574 (False positive: mismatchAllocDealloc using realloc() and free) 2014-03-17 16:10:54 +01:00
PKEuS 521734faa2 Fixed setVarId-Bugs #5294 and #5295. 2014-03-17 14:19:46 +01:00
PKEuS ebd0b43c4f Fixed #5382: False positive "scope can be reduced" when initializing two-dimensional array. 2014-03-17 12:34:39 +01:00
PKEuS d325d14b11 Fixed false positive #5535: Reference named like its type. 2014-03-17 12:01:39 +01:00
PKEuS 50f6bb5d36 Fixed crash #5511. 2014-03-17 11:50:45 +01:00
PKEuS 86e6bb430a New check: Warning, if positioning operation (fseek) is performed on a file opened in "a" mode 2014-03-17 11:02:03 +01:00
PKEuS 1e57f54917 Fixed #5481: std::array is POD, so using memcpy (etc.) is allowed on it. 2014-03-16 19:55:32 +01:00
Martin Ettl 80b1271d01 Astyle running and added test cases for functions in std.cfg. 2014-03-10 02:21:44 +01:00
Lucas Manuel Rodriguez 9a08da17be Fixed #4928 (C++ operator aliases result in false 'assigned a value that is never used' warning) 2014-03-16 14:51:05 -03:00
PKEuS e05fb847df Fixed #3852: Support simplification of C++11 "enum class", fixed existing simplifications 2014-03-16 18:24:46 +01:00
PKEuS 6b16b519a2 Fixed crash on wrong __attribute__((constructor)) syntax 2014-03-16 16:39:07 +01:00
Alexander Mai cba1879fee Fixed #5571 (Clean up MathLib::isInt()) 2014-03-16 11:55:44 +01:00
Daniel Marjamäki 8c3f2c2ad9 Revert 894a65b0. abstract interpretation of for loops. there was some crashes and performance problems. I will fix those problems when I have time and recommit. 2014-03-16 08:38:52 +01:00
Alexander Mai 40ddcabab6 Fixed #4461 (Warn about memset/memcpy on class with references as members) 2014-03-15 18:22:29 +01:00
Daniel Marjamäki 894a65b0b1 ValueFlow: Refactor the for-loop handling. Use abstract interpretation. 2014-03-15 11:29:33 +01:00
Robert Reif 2ba3a36f2c Partial fix for #5555. Improved pure/const attributes handling 2014-03-14 19:06:05 +01:00
Robert Reif e26bd5b99c Fixed #5563 (add __attribute__((destructor)) and improve __attribute__((constructor)) support) 2014-03-14 18:17:21 +01:00
Daniel Marjamäki 8c7cf090c4 Merge pull request #261 from orbitcowboy/master
MathLib:isHex(): fix detection of missing suffixes (U,L).
2014-03-14 13:00:35 +01:00
Daniel Marjamäki 8d8913a168 Partial fix for #5555. Add const,pure attributes to library. 2014-03-14 06:38:45 +01:00
Robert Reif cb1fc06a80 Fixed #5079 (CheckIO::checkFileUsage doesn't support wide char and microsoft functions) 2014-03-12 19:22:44 +01:00
Frank Zingsheim b1dc51ba9c Fixed #4796 (Missing semicolon after simplified template class) 2014-03-12 06:09:45 +01:00
Robert Reif d1eb04c539 Fixed #4302 (Member variable not initialized in public delegate constructor) 2014-03-12 05:48:13 +01:00
Daniel Marjamäki 618c26f6bf Merge pull request #260 from orbitcowboy/master
MathLib::isOct() fix missing detection of U and L suffix combinations an...
2014-03-12 05:30:35 +01:00
Daniel Marjamäki 3b4d024e06 Reverted info message that only applies to CLI 2014-03-11 20:55:02 +01:00
orbitcowboy ed793793db MathLib:isHex(): fix detection of missing suffixes (U,L). 2014-03-11 20:02:04 +01:00
Daniel Marjamäki 94454df14f Fixed #2732 (Make it easier for users to tell 'How to supply header files') 2014-03-11 16:05:19 +01:00
Daniel Marjamäki af0cf9bbc1 Merge pull request #258 from orbitcowboy/master
MathLib::isBin(): fix missing detection of U and L suffix combinations. ...
2014-03-11 06:36:31 +01:00
orbitcowboy 5b4ece4f9c MathLib::isBin(): fix missing detection of U and L suffix combinations. Added missing test cases. 2014-03-10 17:23:07 +01:00
Martin Ettl 0360840753 MathLib::isOct() fix missing detection of U and L suffix combinations and unittests. 2014-03-09 21:14:14 +01:00
Daniel Marjamäki 4d06bc086d astyle formatting 2014-03-09 08:49:32 +01:00
Daniel Marjamäki 7fa73c0d64 Merge pull request #256 from xypron/5505
5505: FP: Array accessed out of bounds
2014-03-09 08:47:18 +01:00
Daniel Marjamäki c7f09d4350 Merge pull request #257 from simartin/ticket_5373_2
Ticket #5373: delete can match %type% in C (take #2)
2014-03-09 08:26:06 +01:00
Alexander Mai 3f30753122 Fixed #5537 (crash: clang ./lib/Basic/FileManager.cpp , since 354e84e7c8 , /lib/symboldatabase.h:288) 2014-03-09 08:17:24 +01:00
Simon Martin a3d1cac79c Ticket #5373: Keep track whether tokens come from a C or C++ file to properly handle %type% in Token::Match with "delete" 2014-03-08 21:26:06 +01:00
Heinrich Schuchardt bd67db96f1 5505: FP: Array accessed out of bounds
CheckBufferOverrun::checkFunctionParameter alreacy considered usage of a
function parameter inside an if block as a special case.

With the patch the same is done for switch statements.

A test is added.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2014-03-07 19:51:13 +01:00
Alexander Mai 29d401ff38 Fixed #3098 (false negative: unitialized variable being passed to strcoll()) 2014-03-06 16:31:31 +01:00
Alexander Mai 354e84e7c8 Fixed #2298 (new check: passing stack-address to free()) 2014-03-06 06:32:30 +01:00