Commit Graph

1210 Commits

Author SHA1 Message Date
Matthias Krüger 988acf11b4 don't print warning message if --enable=warning is not given.
message was of type:
(warning) Passing value 0 to foo() leads to implementation-defined result.
2015-04-06 13:37:27 +02:00
Dmitry-Me ba423185b8 Omit uneeded checks 2015-04-02 10:26:19 +03:00
PKEuS d6751a7987 Merge pull request #537 from Dmitry-Me/decouplePatternMatchingFromOtherChecks
Decouple pattern matching from other checks
2015-03-15 08:50:59 +01:00
Dmitry-Me 43a19dee8b Remove unneded deep copy, make reference const 2015-03-14 13:45:21 +03:00
Dmitry-Me 74417699db Remove redundant break 2015-03-06 18:55:47 +01:00
Daniel Marjamäki 6646a896f9 Fixed #6446 (FP zerodivcond on double arithmetics) 2015-03-03 15:50:31 +01:00
Dmitry-Me 10b762da98 Decouple pattern matching from other checks 2015-02-27 13:09:06 +03:00
Dmitry-Me d7365519a5 Cache and reuse value 2015-02-26 11:48:15 +03:00
Daniel Marjamäki fb5cc6fded Fixed #5905 (isSameExpression: comparisons 'a<b' and 'a>b' are same) 2015-02-23 16:38:55 +01:00
PKEuS 5f31242ee8 CheckOther::checkRedundantAssignment(): Bail out on inline assembly (#6525) 2015-02-22 12:03:53 +01:00
PKEuS bae95b4560 Fixed noise in CheckOther::checkLibraryMatchFunctions(). 2015-02-21 12:39:02 +01:00
PKEuS 6227abac73 Fixed GCC (testsymboldatabase.cpp) and MSVC (checkother.cpp) warnings 2015-02-18 21:19:36 +01:00
Alexander Mai 0a6babea74 #6181 Drop redundantGetAndSetUserId. Ensure (style-) warnings are issued if setuid()/getuid() and some related functions are ignored. Move strdupa()/strndupa() from posix.cfg to gnu.cfg 2015-02-16 22:19:51 +01:00
Dmitry-Me 56747e4af9 Reorder checks 2015-02-16 12:11:13 +03:00
Dmitry-Me 5674b3c49d early break in loop for readability 2015-02-13 16:36:20 +01:00
Dmitry-Me 1f31dd749b Break loop early 2015-02-04 10:47:58 +03:00
PKEuS b2835051df Refactorization: Renamed Token::Match pattern %var% to %name%, implement new pattern %var% which is true if varId > 0. 2015-01-31 12:32:04 +01:00
PKEuS 0488f45a5f Removed standalone check CheckOther::checkDoubleFree(), integrated (most of) the functionality into CheckLeakAutoVar. Added support for new/delete to checkLeakAutoVar. 2015-01-28 17:38:43 +01:00
Daniel Marjamäki 3285f85ebf Fixed #6460 (Library: better function/type matching) 2015-01-27 17:55:18 +01:00
Thomas Jarosch 58cb6cc116 Add new "style" check to catch redundant pointer operations
Doing "&*some_ptr_var" is redundant and might be the remainder
of a refactoring. Warnings for expanded macros are excluded though:
They are often used with and without pointers and
do something like this: "func(&(*macroarg))".

The new check is fully AST based and was given
strong false positive testing on a large code base.
2015-01-18 00:34:07 +01:00
Daniel Marjamäki 6a8293a8b7 Library: More strict matching of functions 2015-01-08 19:31:41 +01:00
Robert Reif ba1c24ee65 Fixed #6422 (symbol database: put function flags into a single flag variable) 2015-01-08 05:45:31 +01:00
Daniel Marjamäki fb685f096a CheckOther:checkNegativeBitwiseShift: Fix FP when shift is protected by ?: 2015-01-05 10:01:04 +01:00
PKEuS 267552779d Improved check (#6391): Detect identical code in both branches of ternary operator 2015-01-03 18:01:49 +01:00
Daniel Marjamäki ff11ba9847 Updated copyright year to 2015 2015-01-03 12:14:58 +01:00
PKEuS a3fbc5aee5 Refactorization: Avoid stringification of second branch if first branch was empty in CheckOther::checkDuplicateBranch() 2015-01-02 11:24:28 +01:00
PKEuS 9e8a66ee40 Fixed #6373: Support bitops in clarifyCalculation check 2014-12-30 17:55:29 +01:00
PKEuS 990d14f3e2 Fixed #6328: Use isAttributeNoreturn() whereever we also check Library::isnoreturn(). 2014-12-27 11:07:36 +01:00
Daniel Marjamäki 0c086cf247 Incomplete statement: tweaked bailout for '0;' statement using isExpandedMacro() 2014-12-24 21:47:37 +01:00
Daniel Marjamäki 90bd38a972 Renamed isCasted to isCast 2014-12-24 10:35:40 +01:00
Daniel Marjamäki de1a91f30d Incomplete statement: tweaked bailout for '(void*)0' using isCasted() 2014-12-23 18:19:33 +01:00
Thomas Jarosch d5e10c18d3 checkUnreachableCode(): fix FP for statements that just hide compiler warnings about unused function arguments
Seen throughout the rockbox codebase.
2014-12-22 11:18:23 +01:00
Daniel Marjamäki 293dc1efc7 Fixed #6327 (Unwanted constStatement on (void)0) 2014-12-21 13:42:21 +01:00
Dmitry-Me c0d2933ec7 Reorder checks to avoid redundant actions 2014-11-30 16:14:53 +03:00
PKEuS 4163f1e122 Fixed #6260 - C++11 style array initialization 2014-11-18 19:50:09 +01:00
Dmitry-Me 353b885948 CheckOther::invalidPointerCast: Incorrect interpretation of settings 2014-11-14 20:22:17 +01:00
Dmitry-Me fefb0ca912 Reuse previously computed values 2014-11-14 13:24:56 +03:00
Dmitry-Me cb9a6c1cb5 Don't show warning for same expressions alongside == in static_assert 2014-11-13 16:04:34 +01:00
Frank Zingsheim 7e0fc3d481 Fixed #6252 (False positive "freed twice")
--HG--
extra : rebase_source : 24f801452fbefa3a59ab2cca62c3cf02aea513b6
2014-11-03 21:24:34 +01:00
PKEuS 662283cab8 Refactorization: Avoid iterations over whole token list, limited several checks to function scopes. 2014-10-31 11:42:54 +01:00
PKEuS b5ea677180 Some fixes for CheckOther::checkIgnoredReturnValue():
- Fixed name of the function
- Fixed false positive for code like "class strcmp { strcmp() {} };"
- Fixed FP #6233 on checking side (no AST generated for function call)
2014-10-30 23:24:13 +01:00
PKEuS b7996bd0b0 Handle overloads and custom implementations of functions checkReturnIgnoredReturnValue() to avoid false positives 2014-10-30 21:26:32 +01:00
Daniel Marjamäki 0a1a34b9b7 Fixed Cppcheck warning, possible null pointer dereference of tok. 2014-10-18 10:59:48 +02:00
Samuel Degrande 96e8b83bf8 Fixed newline in verbose message 2014-10-16 09:08:39 +02:00
orbitcowboy 5a4526e997 Fixed typos in comments, no functional changes. 2014-10-02 04:39:41 +02:00
PKEuS 374ea8f039 Fixed false positive ignoredReturnValue on unknown member function log() (#6197) 2014-09-29 19:55:32 +02:00
Martin Ettl a7c870bdc8 Fixed crash on garbage code in CheckOther::checkVariableScope(). The corresponding backtrace is hosted at https://github.com/orbitcowboy/cppcheck_crash_files/blob/master/crash223.cpp 2014-09-29 19:44:25 +02:00
PKEuS 1495a411eb Fixed false positive ignoredReturnValue for variables initialized with constructor syntax (#6194) 2014-09-29 10:15:29 +02:00
PKEuS 03b1afc28c Loops over all varIds should start at 1. 2014-09-28 09:47:11 +02:00
PKEuS 210294443e New check: Check for unused return values (#653) 2014-09-27 21:31:04 +02:00
PKEuS cafddcb109 Fixed wrong function log10 being recommended instead of log1p 2014-09-14 13:36:12 +02:00
Daniel Marjamäki 0e55f12140 Fixed #6165 (Remove old checkUnsignedDivision checker that uses neither AST nor ValueFlow. The CheckType::checkSignConversion should be much more accurate) 2014-09-12 16:59:16 +02:00
PKEuS 6f92557478 Use information about pure/leak-ignore from library to improve accuracy of several bailouts 2014-09-11 20:27:07 +02:00
PKEuS c1b0bfe4ee Simplified code 2014-09-11 20:27:01 +02:00
PKEuS fb0d145b34 Don't show inconclusive message redundantCopyLocalConst if --inconclusive is not set.
Ran AStyle
2014-09-11 19:45:52 +02:00
Daniel Marjamäki 7847263451 Fixed #6158 (New check: dangerous sign conversion) 2014-09-11 18:10:19 +02:00
PKEuS 865fc9aa67 Fixed #6154: Don't suggest to reduce scope if inner scope is a lambda. 2014-09-10 20:56:34 +02:00
Daniel Marjamäki a46f5c00a8 Minor tweaks for new CheckOther::checkIntegerOverflow checker 2014-09-10 17:26:20 +02:00
Daniel Marjamäki 974c8688c3 Fixed #1751 (Undefined Behavior: Signed integer overflow) 2014-09-10 17:02:18 +02:00
Daniel Marjamäki a36b0e55be CheckOther::checkTooBigBitwiseShift: improving error messages 2014-09-09 17:06:45 +02:00
Daniel Marjamäki f111a89639 Fixed #1757 (Undefined Behavior: Shift too many bits) 2014-09-09 07:24:59 +02:00
Martin Ettl 0ced0c33e5 Fixed #6149: (gcc) warning: comparing floating point with == or != is unsafe. Using Tokenizer::isOneNumber function to compare a floating point number being 1.0. 2014-09-08 20:02:04 +02:00
PKEuS 301b668eb5 Fixed internal warning of cppcheck 2014-09-07 11:47:40 +02:00
PKEuS ff4fc6a234 New check: Recommend expm1, log1p, erfc (#5392) 2014-09-07 11:38:49 +02:00
Alexander Mai efab840b50 #5230 Explicit reinterpret_cast should not give a warning. Lower all invalidPointerCast messages to 'portability' 2014-09-06 13:09:02 +02:00
Alexander Mai 29b46cb505 #6132 crash: daca: kvirc CheckOther::checkRedundantAssignment() 2014-09-05 20:03:34 +02:00
PKEuS e8f7279039 Refactorization: Moved detection of STL strings to SymbolDatabase 2014-09-05 12:03:08 +02:00
PKEuS 800b57d87e Merge pull request #415 from Dmitry-Me/reducePatternsDuplication
Reduce patterns duplication
2014-09-04 07:46:59 +02:00
Alexander Mai 45dc4ca6be Fix compiler warning. Re-order if-expression for performance reasons 2014-09-02 19:18:30 +02:00
Dmitry-Me 46d24c7bfb Reduce patterns duplication 2014-09-02 19:51:22 +04:00
PKEuS ddc19febb5 Merge pull request #413 from Dmitry-Me/improveCStyleCastsDetection
Improve C style casts detection
2014-09-02 08:07:53 +02:00
PKEuS 428f7a6f26 Attempt to fix crashs on clang test suite. 2014-09-01 23:29:15 +02:00
PKEuS 00044aabb0 Handle ternary operator in redundantAssignment check (#5964) 2014-09-01 23:16:52 +02:00
Alexander Mai a4ff30301a #5805 'Passing value -1.0 to sqrt() leads to undefined result' is incorrect. Degrade wrongmathcall from error to warning, since it deals with implementation-defined behaviour 2014-09-01 19:31:32 +02:00
Dmitry-Me f937dde1e0 Improve C style casts detection 2014-09-01 16:40:28 +04:00
PKEuS c92230dfee Fixed crash on garbage code introduced by recent commit. 2014-09-01 12:41:30 +02:00
PKEuS 20a066bb14 Run unreachableCode checking only on executable scopes (#5789) 2014-09-01 11:29:39 +02:00
PKEuS b5e064e737 Fixed unreachableCode message if a lambda is returned (#6008). 2014-09-01 11:10:42 +02:00
PKEuS 353a9e9a64 Bailout for duplicateBranch check if branches are empty (#5354) 2014-09-01 10:19:14 +02:00
PKEuS e9fdfc6cd0 Fix on checking side for #6099 2014-08-30 11:18:48 +02:00
PKEuS 06a92e8981 Moved several condition checks from checkOther to checkCondition (former checkAssignIf) 2014-08-29 17:06:46 +02:00
PKEuS eba8c6f6c5 Refactorization:
- Added missing separating comments between checks in checkother.cpp
- Moved checks related to strings into own file
2014-08-27 09:42:09 +02:00
PKEuS 7f2be2f57c Fixed template bracket linkage in while loop simplification
Ran AStyle
2014-08-23 12:28:54 +02:00
amai2012 976966fe81 #5639 String literal compared with char buffer in a struct. 2014-08-23 09:41:40 +02:00
PKEuS 0bf7b03f96 Refactorization: Support :: in some places in checkother.cpp 2014-08-18 10:25:30 +02:00
Daniel Marjamäki d44d6ad94a incorrect logic operator: fixed crashes 2014-08-18 05:37:07 +02:00
Daniel Marjamäki ebc0b6cd44 astIsFloat: Fix crash when there is no second operand for '.' 2014-08-17 14:28:31 +02:00
Daniel Marjamäki f7f44f24c7 Fixed #5132 (False negative: incorrectLogicOperator in simple if-clause) 2014-08-17 14:04:40 +02:00
Daniel Marjamäki 364c975701 Fixed #5557 (astIsFloat: better handling of '.') 2014-08-15 16:48:53 +02:00
PKEuS 5d302716e7 Refactorized Variable::isIntegralType() and Variable::isFloatType():
- Cached property
- Make use of it in several checks
- float* is flagged as floating point type
2014-08-09 11:45:13 +02:00
PKEuS c3577bc8dd Fixed crash, simplified code in testassert.cpp 2014-08-06 12:24:21 +02:00
PKEuS d3a567bf96 Fixed false positive #5824: Variables that might be used for va_start() must not be passed by reference. 2014-08-06 12:06:36 +02:00
PKEuS 4a3d719386 Fixed recently introduced FP when C-Style casting nullpointers 2014-08-04 11:42:14 +02:00
PKEuS 4c80ca4e8e Improved cstyleCast check:
- Detect casting of literals
- Check initializer lists (#3630)
2014-08-04 11:21:25 +02:00
Daniel Marjamäki 8a1c5d6fce Fixed #6011 (crash: libreoffice/binfilter svt_enhwmf.cxx) 2014-07-28 16:33:42 +02:00
Daniel Marjamäki fdfea717c6 Suspicious string comparison: Refactoring using AST. Fixed FP in Lac. 2014-07-28 14:27:35 +02:00
Daniel Marjamäki 76020d2ad0 astIsFloat: expression 'floatvar ? 0x40 : 0' is not float 2014-07-26 09:09:58 +02:00
Dmitry-Me 07c120f1af Cache option flags and check them first. 2014-07-23 17:06:27 +04:00
Daniel Marjamäki 2cc31acabb Fixed #5922 (FP: passedByValue for std::string::value_type) 2014-07-18 15:51:59 +02:00
Daniel Marjamäki bf5b4d9ece astyle formatting
[ci skip]
2014-07-14 14:38:40 +02:00
Dmitry-Me 9829e0b48a Clearer variable names, fix typo in comment. 2014-07-11 11:33:09 +04:00
Dmitry-Me ba3757dfd3 Bring variables decalaration to where they are really needed. 2014-07-10 11:23:14 +04:00
Daniel Marjamäki d40b77dce2 Removed special 'else if' handling. this is redundant since these are simplified. 2014-07-02 16:16:19 +02:00
Daniel Marjamäki 5e9e90b1c1 Fixed Token::Match pattern. In x|y|.. patterns, all %cmd% should be placed before plain-text operands. 2014-07-01 15:55:29 +02:00
Daniel Marjamäki 41baffdda1 Fixed #5850 (Wrong Message on self assignment) 2014-06-28 15:26:22 +02:00
orbitcowboy 16352ca674 Reverted fix 6d0f490138, but keeping the testcase in the testsuite. 2014-06-06 14:44:22 +02:00
orbitcowboy 6d0f490138 #5895 - Fixed potential signed integer overflow in Checkother:getvalue. Added regression test. 2014-06-05 16:41:10 +02:00
orbitcowboy e9144d1a78 Fixed #5890 - crash: wesnoth desktop_util.cpp / unicode.hpp. 2014-05-29 02:58:18 +02:00
Daniel Marjamäki 66ad3c97b9 Fixed #5857 (strPlusChar: Crash on invalid code 'int+;') 2014-05-31 10:34:00 +02:00
Daniel Marjamäki 70b4c945de Fixed #5874 (False positive: 'opposite conditions in nested if' with arrays) 2014-05-30 19:19:24 +02:00
Daniel Marjamäki bc2ba1706b cleanup redundant valueflow check. if there are no values the getValue will return NULL. 2014-05-28 21:03:16 +02:00
PKEuS 8f79dc3ff8 Cleaned up includes and forward declarations in checkers:
- Removed definitely unnecessary forward declarations (e.g. "class Token"; token.h is already included by check.h, so a definition is unnecessary)
 - Removed unused includes
2014-05-24 12:50:03 +02:00
PKEuS b78131cfcf Improved cast detection in AST:
-> Make use of it in checkother.cpp

Use tokenizer simplification instead of reimplementation for test suite
2014-05-24 11:29:32 +02:00
orbitcowboy 85496cfadc Fixed CID 1192595: Dereference null return value in checkother. 2014-05-23 18:11:44 +02:00
PKEuS bc0682d1e9 Enhancements related to duplicate expression checking:
- Fixed astIsFloat() for complex expressions
- Enhanced support for commutative operators (#5260)
2014-05-22 21:46:48 +02:00
PKEuS 9dd4ac68c0 Refactorization in CheckNullPointer:
- Use AST to detect dereferences
- Added more unit tests
- Removed handling of unknown constructs in CheckNullPointer::isPointerDeRef()

Added link to verbose message cstyleCast.
2014-05-22 19:48:00 +02:00
PKEuS f1c303d399 Fixed recently introduced verbose message for cstyleCast
[ci skip]
2014-05-22 15:46:28 +02:00
PKEuS 35528ca708 Added verbose message for "C-style pointer casting" (#4140) 2014-05-22 08:57:45 +02:00
PKEuS 4cad064c3c Fixed false positive on C code introduced by last commit 2014-05-21 20:36:19 +02:00
PKEuS d19eabde42 New Check: Compare pointer with '\0' (#4070) 2014-05-21 19:12:07 +02:00
PKEuS cdfed32500 Merged checkSelfAssignment() into checkDuplicateExpression():
- Fixed false negatives on self assignments of more complex expressions like "a.b"
- New false negative on self assignment in initialization
- Support this->... pattern in isSameExpression()
- Fixed #5819: Check type of operands
2014-05-21 18:19:42 +02:00
PKEuS 48c3d02fc3 Fixed false positives and false negatives in 'oppositeInnerCondition' (among others: #5808) 2014-05-21 14:38:41 +02:00
PKEuS 5fbd58d98d Fixed messages of CheckInternal, fixed a false positive. 2014-05-18 20:39:52 +02:00
PKEuS e713ad45cb Refactorizations:
- Simplified pattern ".|->" to "."
- Use nextArgument() where appropriate
2014-05-18 17:07:21 +02:00
PKEuS 780719665f Fixed crash when checking tinyxml introduced by previous commit 2014-05-18 13:40:49 +02:00
PKEuS 20753f4697 Refactorization: Use AST in CheckOther::checkRedundantCopy(), CheckOther::clarifyStatement() and CheckPostfixOperator::postfixOperator(). 2014-05-18 13:00:58 +02:00
Daniel Marjamäki 7ecdb30308 Fixed #5771 (false positive: (warning) When using 'char' variables in bit operations, sign extension can generate unexpected results.) 2014-05-13 15:53:31 +02:00
PKEuS 70dfb55f21 Simplified some Token::Match patterns 2014-05-11 17:50:58 +02:00
Daniel Marjamäki 827cfac91e Refactoring of CheckOther::checkModuloAlwaysTrueFalse using AST 2014-05-10 20:49:29 +02:00
PKEuS c0fc47643f Fixed false positive #5772: Use AST to check if modulo operation is preceded by an arithmetical operation. 2014-05-09 21:58:28 +02:00
Daniel Marjamäki cb43bee10d Same expression: don't warn for same expressions when there is assignment 2014-05-09 06:16:27 +02:00
Daniel Marjamäki b354de6b23 Fixed #5750 (FP:Opposite conditions in nested 'if' blocks lead to a dead code block) 2014-05-06 16:15:12 +02:00
Alexander Mai d3e8bbdc51 #5618 False positive: (performance) Use const reference for 'temp' to avoid unnecessary data copying. - redundantCopyLocalConst/CheckOther::checkRedundantCopy() is prone to false positives. As a quick fix that check becomes inconclusive. 2014-05-02 20:09:38 +02:00
orbitcowboy a6af8f5dcf #5748: Fixed FP (wrongmathcall) do not warn if an object calls a function foo.log(0). 2014-04-23 01:23:38 +02:00
Daniel Marjamäki fc24d491cc Fixed #5560 (false positive: C-style pointer casting) 2014-04-29 06:21:30 +02:00
PKEuS 866ab1ce14 Fixed false positive #5689: Care about usage of return values of memory functions 2014-04-27 12:18:33 +02:00
Daniel Marjamäki bde6698bcd Fixed #5731 (False positive with opposite conditions) 2014-04-27 10:21:20 +02:00
Daniel Marjamäki 7317785e32 astyle formatting
[ci skip]
2014-04-27 10:20:21 +02:00
Alexander Mai 17ec0af6a7 #5734 A FP literalWithCharPtrCompare was issued upon comparison with a char referenced within a string literal 2014-04-27 09:40:13 +02:00
Daniel Marjamäki d144197d7e Fixed segfault 2014-04-23 19:49:16 +02:00
Daniel Marjamäki 272fcc18d8 Don't warn about redundant number statement in '({ do_something(); 0; })' 2014-04-23 16:23:19 +02:00
Frank Zingsheim 87354bf9d2 Fixed #5707 (false negative: unreachable code is not detected (code after return)) 2014-04-23 07:58:43 +02:00
Daniel Marjamäki 3c5cf299e3 Fixed #5708 (Improve oppositeInnerCondition) 2014-04-23 07:57:13 +02:00
Alexander Mai ccba934cb1 #5684 The scope of the variable 'p' can be reduced - But it can not. 2014-04-17 21:32:56 +02:00
Daniel Marjamäki 8d5a9893d5 Fixed #5682 (False positive: (style) Same expression on both sides of '&&') 2014-04-16 16:04:46 +02:00
PKEuS 076f7a7542 Fixed some coverity findings about dead code, fixed a misleading comment 2014-04-14 22:46:51 +02:00
Philipp Kloke dfd9d32c4b Refactorization: Removed whitespaces at the end of a token
Removed a redundant 'void'
2014-04-12 23:41:46 +02:00
Philipp Kloke ddf34440b6 Refactorization: Replaced several Token::findmatch calls by symboldatabase usage 2014-04-12 23:41:46 +02:00
PKEuS 7ffc313748 Save "->" in Token::originalName if simplified to "."; Fix false positive #4890. 2014-04-12 12:04:56 +02:00
Philipp Kloke 1fafc7f4dc Refactorization: use MathLib::isNullValue in CheckOther::checkMemsetInvalid2ndParam(); Fixed it to support also float literals like "0.f" 2014-04-11 14:17:36 +02:00
Philipp Kloke cf30fab413 Refactorized inefficient usage of Token::findmatch in two checks in checkother.cpp 2014-04-11 14:17:35 +02:00
Philipp Kloke 20c3a5baf0 Refactorized switchCaseFallThrough: Removed lots of obsolete code 2014-04-11 14:17:35 +02:00
PKEuS c33498fa0b Fixed false positive redundantAssignment when operator() is called (#5568) 2014-04-10 21:56:30 +02:00
Daniel Marjamäki 0788e64eb8 Removed unused function expressionsHasSideEffects() 2014-04-04 07:04:19 +02:00
Daniel Marjamäki 8dcb3bae47 Refactoring checks of overlapping conditions in if and else-if 2014-04-03 19:35:50 +02:00
Daniel Marjamäki 1a83338faf Refactoring. Created utility function isOppositeCond() 2014-04-03 17:08:42 +02:00
Daniel Marjamäki 110f956029 code cleanup for invertOperatorForOperandSwap() 2014-04-03 16:22:07 +02:00
Daniel Marjamäki ffac614f7e Fix Cppcheck warning. Use reference to avoid redundant data-copy 2014-04-03 16:16:39 +02:00
Daniel Marjamäki 9f80f3a4e8 Small cleanups in the code 2014-04-03 06:37:02 +02:00
Daniel Marjamäki a115bbbbb5 Refactoring CheckOther::checkCharVariable() using AST 2014-04-03 06:27:29 +02:00
Daniel Marjamäki bc9bb17025 Refactor CheckOther::oppositeInnerCondition() using AST and isSameExpression() 2014-04-02 16:54:01 +02:00
Daniel Marjamäki 3c64c70ce2 ValueFlow: Added utility functions getValueLE and getValueGE to simplify usage 2014-04-02 06:49:28 +02:00
Daniel Marjamäki f4cdb2c46a CheckOther::checkCharVariable: Refactoring using AST 2014-04-01 19:16:06 +02:00
Daniel Marjamäki 348c26f59c fixed segmentation fault in case typeStartToken() returns 0 2014-03-29 21:01:21 +01:00
Daniel Marjamäki efc84ac310 Fix segmentation fault when checking build/tokenize.cpp 2014-03-29 20:41:17 +01:00
Daniel Marjamäki 407c9fdf9d Refactored checkNegativeBitwiseShift() so it uses ast and valueflow 2014-03-29 13:01:30 +01:00
Daniel Marjamäki 502ba95383 Simplification. Code 'else if ..' is simplified to 'else { if ..' 2014-03-28 18:21:56 +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
PKEuS e8c7a723f5 Fixed five new true positives in cppcheck, silenced one new false positive (see #5618) 2014-03-27 15:50:30 +01:00
PKEuS b23aebf2f0 Show redundantCopyLocalConst for STL types (#4331) 2014-03-27 11:15:17 +01:00
PKEuS 5083dd4273 Fixed two visual studio warnings 2014-03-24 18:14:23 +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 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
Daniel Marjamäki 54e7f34f4a Fixed #5584 (FP: Division by zero when function not declared) 2014-03-20 16:12:58 +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 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
Daniel Marjamäki ce1aa1e011 Library: I had misunderstood const/pure a little so I corrected cfg and code 2014-03-14 20:08:34 +01:00
Daniel Marjamäki b2708987c3 Merge pull request #264 from thomasjfox/simplematch
Use simple match where possible
2014-03-14 17:51:45 +01:00
Daniel Marjamäki a929b2146e Improved checking of const functions in checkIncorrectLogicOperator 2014-03-14 17:37:53 +01:00
Thomas Jarosch 93341f4449 Use simple match where possible
Fixes these warnings found by "--enable=internal":

[lib/checkclass.cpp:972]: (warning) Found simple pattern inside Token::Match() call: "* *"
[lib/checkbufferoverrun.cpp:635]: (warning) Found simple pattern inside Token::Match() call: "."
[lib/checkbufferoverrun.cpp:1397]: (warning) Found simple pattern inside Token::Match() call: ";"
[lib/checksizeof.cpp:299]: (warning) Found simple pattern inside Token::Match() call: "."
[lib/checksizeof.cpp:301]: (warning) Found simple pattern inside Token::Match() call: ")"
[lib/checksizeof.cpp:303]: (warning) Found simple pattern inside Token::Match() call: "]"
[lib/checksizeof.cpp:318]: (warning) Found simple pattern inside Token::Match() call: ")"
[lib/checknullpointer.cpp:413]: (warning) Found simple pattern inside Token::Match() call: "delete"
[lib/checkio.cpp:1336]: (warning) Found simple pattern inside Token::Match() call: "> ("
[lib/checkstl.cpp:1509]: (warning) Found simple pattern inside Token::findmatch() call: ";"
[lib/checkstl.cpp:1512]: (warning) Found simple pattern inside Token::findmatch() call: ";"
[lib/checkstl.cpp:1594]: (warning) Found simple pattern inside Token::Match() call: "="
[lib/checkstl.cpp:1598]: (warning) Found simple pattern inside Token::Match() call: "] ="
[lib/checkunusedvar.cpp:755]: (warning) Found simple pattern inside Token::Match() call: "goto"
[lib/checkunusedvar.cpp:793]: (warning) Found simple pattern inside Token::Match() call: "="
[lib/checkuninitvar.cpp:376]: (warning) Found simple pattern inside Token::Match() call: "> ("
[lib/checkother.cpp:86]: (warning) Found simple pattern inside Token::Match() call: "> ("
[lib/checkother.cpp:2181]: (warning) Found simple pattern inside Token::Match() call: "> {"
[lib/valueflow.cpp:54]: (warning) Found simple pattern inside Token::Match() call: "&"
[lib/valueflow.cpp:409]: (warning) Found simple pattern inside Token::Match() call: "do"
[lib/valueflow.cpp:425]: (warning) Found simple pattern inside Token::Match() call: ") {"
[lib/valueflow.cpp:487]: (warning) Found simple pattern inside Token::Match() call: ") {"
[lib/valueflow.cpp:511]: (warning) Found simple pattern inside Token::Match() call: "} else {"
[lib/valueflow.cpp:615]: (warning) Found simple pattern inside Token::Match() call: "for ("
[lib/symboldatabase.cpp:80]: (warning) Found simple pattern inside Token::Match() call: "= {"
[lib/symboldatabase.cpp:1069]: (warning) Found simple pattern inside Token::Match() call: "std ::"
[lib/tokenize.cpp:2207]: (warning) Found simple pattern inside Token::Match() call: "< >"
[lib/tokenize.cpp:2730]: (warning) Found simple pattern inside Token::Match() call: ";"
[lib/tokenize.cpp:4234]: (warning) Found simple pattern inside Token::Match() call: "try {"
[lib/tokenize.cpp:4235]: (warning) Found simple pattern inside Token::Match() call: "} catch ("
[lib/tokenize.cpp:5500]: (warning) Found simple pattern inside Token::Match() call: "INT8"
[lib/tokenize.cpp:5752]: (warning) Found simple pattern inside Token::Match() call: "}"
[lib/tokenize.cpp:5752]: (warning) Found simple pattern inside Token::Match() call: "do"
2014-03-14 16:27:47 +01:00
Daniel Marjamäki 8d8913a168 Partial fix for #5555. Add const,pure attributes to library. 2014-03-14 06:38:45 +01:00
Frank Zingsheim 5e0a575091 Optimization: tokenlist::addtoken 2014-03-09 17:54:49 +01:00
Alexander Mai 50a184c3e9 Fixed #5166 (segmentation fault (invalid code) in lib/checkother.cpp:329 ( void * f { } void b ( ) { * f } )) 2014-02-27 18:24:51 +01:00
Daniel Marjamäki 7dbfd67da3 Fixed #5493 (False positive: Found a statement that begins with numeric constant / string constant - in the presence of initialization list.) 2014-02-26 06:18:52 +01:00
Daniel Marjamäki 8dd7f02e45 Fixed #5381 (Some false positives that came up when using --enable=performance file.c) 2014-02-23 11:02:39 +01:00
Daniel Marjamäki d37359217c Merge pull request #241 from lanurmi/more-nullptr
Change some more 0 literals into nullptr.
2014-02-16 23:29:23 +01:00
Lauri Nurmi 70a67eaf85 Change some more 0 literals into nullptr. 2014-02-16 13:38:50 +02:00
Daniel Marjamäki fdcb325d70 DuplicateBranch: Made warning inconclusive since it's in most cases noise 2014-02-16 11:04:27 +01:00
Lucas Manuel Rodriguez 052840f8f5 Fixed #4818 (New check: Check memset() 2nd parameter) 2014-02-15 15:06:00 -03:00
Daniel Marjamäki fb5c2d4b48 use nullptr in lib/checkother.cpp 2014-02-15 08:46:28 +01:00
Daniel Marjamäki fd3a8a2a18 Update copyright 2014-02-15 07:45:39 +01:00
Daniel Marjamäki 486a3192c0 Fixed #5246 (false positive: (warning) Logical conjunction always evaluates to false: t > 0 && t < 1.) 2014-02-04 06:50:29 +01:00
Lucas Manuel Rodriguez ad0269eeeb Refactor checks using Variable::isStlType() 2014-01-30 01:26:48 -03:00
Daniel Marjamäki 69109784e8 value flow: cleanup usage of valueflow. utility function Token::getValue was added. 2014-01-20 06:49:45 +01:00
Daniel Marjamäki add84187cc CheckOther: Removed old zero division check 2014-01-20 06:31:13 +01:00
Daniel Marjamäki b2b5590f2b Refactoring: Moved astStringify to the Token class and renamed it to expressionString. This can often be useful when reporting error messages that contains source code. 2014-01-17 18:37:49 +01:00