Daniel Marjamäki
e0e53cbd66
alwaysTrueFalse: Don't warn when condition is 0 or 1
2016-10-09 15:20:43 +02:00
Harald Scheidl
58eb644003
Improved Check: Warn about number and char literals in boolean expressions ( #7750 )
2016-10-09 13:21:00 +02:00
Daniel Marjamäki
0e48625ff4
Fixed false positive when self-checking Cppcheck 'boolean result used in bitwise operation' when using boolean variables.
2016-08-29 04:09:36 +02:00
Daniel Marjamäki
706877df2d
astyle formatting
...
[ci skip]
2016-08-24 12:43:45 +02:00
Roberto Martelloni
4c6f4f6708
CWE mapping of functionConst, functionStatic, initializerList, badBitmaskCheck, knownConditionTrueFalse, invalidTestForOverflow, unhandledExceptionSpecification, coutCerrMisusage,
...
invalidPrintfArgType_int
2016-08-23 16:48:36 +01:00
Bartlomiej Grzeskowiak
09a83f2cc8
Fixed #7567 ("(a | 7) > 6U" is always true)
2016-08-07 16:58:39 +02:00
Daniel Marjamäki
5611a71820
Fixed #7543 (False positive boolean result used in bitwise operation)
2016-07-29 18:46:43 +02:00
Daniel Marjamäki
89be630156
Fixed #7543 (False positive boolean result used in bitwise operation)
2016-07-29 17:24:22 +02:00
Daniel Marjamäki
9bda97975a
Fixed #7037 (32bit (-m32): testsuite fails)
2016-07-19 12:14:55 +02:00
Bartlomiej Grzeskowiak
a5cfa2b12c
- #7522 and #7428 revisited. ((a&7)>7U) is always false and ((X|7)>=6) is correct (X can be negative).
2016-06-17 12:12:53 +02:00
PKEuS
f2ae295f1e
Support char literals in CheckCondition::checkIncorrectLogicOperator() ( #5912 )
2016-05-24 15:08:48 +02:00
PKEuS
5d5886b464
Properly detect binary & in CheckCondition::clarifyCondition() (fixes false positives when self-checking cppcheck)
2016-05-06 17:39:41 +02:00
PKEuS
3366a74bb0
Refactorized CheckCondition::clarifyCondition():
...
- Reimplemented parts of the check based on ValueType
- Merged two loops
Fixed some type conversion messages
2016-05-06 15:22:45 +02:00
Daniel Marjamäki
00a584d8d1
astyle formatting
2016-04-22 06:01:34 +02:00
Bartlomiej Grzeskowiak
7e020e1d92
- fix for #7428 false negative: Statement is always false
2016-04-14 14:50:08 +02:00
Alexander Mai
0533d7bf9c
Run astyle + minor refactoring
2016-02-27 16:03:50 +01:00
Roberto Martelloni
d3645d874e
Mapped toomanyconfigs ,AssignmentAddressToInteger
...
,AssignmentIntegerToAddress ,CastIntegerToAddressAtReturn
,CastAddressToIntegerAtReturn ,assertWithSideEffect ,assignmentInAssert
,uselessAssignmentArg ,uselessAssignmentPtrArg
,comparisonOfFuncReturningBoolError
,comparisonOfTwoFuncsReturningBoolError ,comparisonOfBoolWithBoolError
,incrementboolean ,comparisonOfBoolWithInt ,compareBoolExpressionWithInt
,negativeIndex ,pointerOutOfBounds ,arrayIndexThenCheck
,possibleBufferAccessOutOfBounds ,argumentSize
,arrayIndexOutOfBoundsCond ,noConstructor ,copyCtorPointerCopying
,noCopyConstructor ,uninitMemberVar ,operatorEqVarError
,unusedPrivateFunction ,memsetClassFloat ,mallocOnClassWarning
,operatorEq ,thisSubtraction ,operatorEqRetRefThis ,operatorEqToSelf
,useInitializationList ,duplInheritedMember ,assignIfError
,comparisonError ,multiCondition ,mismatchingBitAnd
,oppositeInnerCondition ,incorrectLogicOperator ,redundantCondition
,moduloAlwaysTrueFalse to their CWEs ids.
2016-02-26 23:53:52 +00:00
Daniel Marjamäki
7bd034c009
Fixed #7369 (False positive knownConditionTrueFalse - assertions)
2016-02-06 14:37:44 +01:00
Daniel Marjamäki
6faa637fc7
Fixed #6537 (False positive badBitmaskCheck - error in valueflow)
2016-01-24 13:45:44 +01:00
Lauri Nurmi
996c9244d8
Update copyright year to 2007-2016.
2016-01-01 15:34:45 +02:00
Daniel Marjamäki
8171154e12
Fixed #7230 (Confusing code snippet in error message)
2015-12-31 01:15:49 +01:00
Daniel Marjamäki
24438c326e
Fixed #7233 (Fasle negative 'unknownEvaluationOrder in case of macro)
2015-12-25 18:31:21 +01:00
Daniel Marjamäki
8f27cec991
Revert "minor tweak of comment"
...
This reverts commit b1d1869f22
.
2015-12-14 20:29:29 +01:00
Daniel Marjamäki
b1d1869f22
minor tweak of comment
2015-12-14 20:03:40 +01:00
Daniel Marjamäki
1b0bb02f1d
invalidTestForOverflow: Fixed some false negatives ( #7184 )
2015-11-30 11:12:51 +01:00
Daniel Marjamäki
fb8cce647c
invalidTestForOverflow: Refactor; move from checkother to checkcondition
2015-11-30 08:51:15 +01:00
PKEuS
00bdc89f98
Refactorizations:
...
- Rely on SymbolDatabase to detect string types
- Loop over variable list instead of token list
- Fixed two comments claiming that the AST is experimental
2015-11-20 11:20:42 +01:00
Daniel Marjamäki
0f9d90d2be
Changed Copyrights. Removed my name.
2015-11-18 20:04:50 +01:00
Daniel Marjamäki
b9b0964dab
Fixed #7006 (False positive Mismatching assignment and comparison (variable is changed in loop))
2015-11-11 13:45:28 +01:00
Aleksandr Pikalev
2d0ecc08c1
Check pointers for NULL before utilizing and do not check it later
2015-11-06 20:24:09 +01:00
Simon Martin
f273323cd0
Fixed TODO-test for CheckCondition::checkBadBitmaskCheck by handling functions return bool.
2015-09-03 21:07:03 +02:00
PKEuS
4d80df2f4a
Added pointer to Type to Token (similar to Token::Variable() and Token::function()):
...
- Accessible via Token::type()
- Renamed former Token::type() to Token::tokType()
- Removed SymbolDatabase::isClassOrStruct()
2015-08-15 11:19:21 +02:00
Dmitry-Me
ce96a5e84f
Run cheaper checks first
2015-08-07 16:25:47 +03:00
Daniel Marjamäki
a51acc8abd
minor tweak of 'Redundant condition' error message
2015-08-05 11:30:58 +02:00
Daniel Marjamäki
eda5272dfd
Fixed #6875 (Improve 'Redundant condition' error message)
2015-08-05 11:15:54 +02:00
Daniel Marjamäki
e598b07a6d
Moved functions to astutils
2015-08-03 09:20:50 +02:00
Alexander Mai
96c3c111fc
Refactoring: Move some AST related functions to distinct source file
2015-08-02 21:57:32 +02:00
Matthias Krüger
87891b4128
CheckCondition::checkIncorrectLogicOperator put conditions in single quotes
2015-07-31 15:28:48 +02:00
Matthias Krüger
21ed807f8d
CheckCondition::alwaysTrueFalseError: put condition in single quotes.
2015-07-31 15:28:37 +02:00
amai2012
249a05126b
#6895 segmentation fault (invalid code) in CheckCondition::isOppositeCond
2015-07-30 17:19:19 +02:00
Daniel Marjamäki
1752c4f4f0
Avoid 'Condition always true/false' FP when part of the condition is an expanded macro
2015-07-30 13:30:16 +02:00
Daniel Marjamäki
120f3072eb
alwaysTrueFalse: Dont write warning when comparison is made in macro
2015-07-29 12:51:00 +02:00
Daniel Marjamäki
afd9f071c0
simplified the code for ValueFlow Known/Possible values
2015-07-25 19:36:29 +02:00
Daniel Marjamäki
eda3fdc96a
CheckCondition: Refactoring function parameter lookup
2015-07-23 12:06:33 +02:00
Daniel Marjamäki
f711520892
Fixed #6852 (false negative: logical conjunction 'x == 0')
2015-07-21 22:26:22 +02:00
Daniel Marjamäki
1b8252181d
Tokenizer: Removed Tokenizer::simplifyIfNotNull ( #6072 )
2015-07-21 17:58:44 +02:00
Daniel Marjamäki
cb04dfbd37
Fixed #4842 (condition is always true (variable is assigned constant value and then used in condition))
2015-07-17 15:30:23 +02:00
Daniel Marjamäki
15a8e4d2df
Temporarily revert "Fixed #4842 (condition is always true (variable is assigned constant value and then used in condition))"
...
This reverts commit a3fbad50cb
.
The ValueFlow must be updated before this can be re-added.
2015-07-16 21:10:46 +02:00
Daniel Marjamäki
a3fbad50cb
Fixed #4842 (condition is always true (variable is assigned constant value and then used in condition))
2015-07-16 20:17:57 +02:00
Daniel Marjamäki
1a872a2c9f
Fixed #6019 (false negative: Expression is always true/false '!(v!=10) && !(v!=20)')
2015-07-13 20:53:49 +02:00
amai2012
5814c3b84c
Fix some compiler warnings with VS
...
Minor refactoring on Windows SEH code.
2015-06-28 19:20:16 +02:00
Alexander Mai
56e90f95d9
Corrections for non-Microsoft compilers
2015-06-28 12:34:08 +02:00
amai2012
649a89d308
Refactoring: Expose some previously local functions to public and add Tokenizer as argument to distinguish between C and C++ code (e.g. in isSameExpression).
...
Refactoring: Improve type-safety for TestFixture::assertEquals to allow tests with types which were not handled correctly (e.g. unsigned long long)
2015-06-28 12:08:36 +02:00
Daniel Marjamäki
1d49334398
Fixed #6662 (False positive assignIfError (assignment in while condition))
2015-06-20 16:23:16 +02:00
Daniel Marjamäki
af4a4663e2
Fixed #6764 (False positive redundantCondition - !(i>1) is not i<1)
2015-06-19 19:49:05 +02:00
Alexander Mai
60f5bd97df
Refactoring: missing include added, (potential) multi-threading issue fixed, expose static method to allow unit testing
2015-06-18 19:07:51 +02:00
Matthias Krüger
baaf3213e4
checkcondition: only print style message "A && (!A || B)' is equivalent to 'A || B'" if --enable=style is given.
2015-06-18 13:23:48 +02:00
Daniel Marjamäki
d571d5db6f
Fixed compiler warning -Wfloat-equal in template when type is double and there is equality comparison
2015-06-14 20:25:52 +02:00
Daniel Marjamäki
1e1ba6b4a9
Fixed #6574 (False positive oppositeInnerCondition - unknown variable)
2015-06-14 20:06:05 +02:00
Alexander Mai
a7b82b5c28
Refactoring to address some issues from #5895 (handling of unsigned numbers). Also adding a TODO testcase since the real issue (FP) is still not fixed
2015-06-13 18:08:13 +02:00
Dmitry-Me
cae605b1ec
New warning: warn about redundant code in condition.
2015-06-10 18:53:55 +02:00
Matthias Krüger
42f0955e3f
Move more setting checks out of loops and use const bools instead. Reorder a few related checks.
...
Follow up to eedcb6abcb
.
2015-04-10 14:31:19 +02:00
Matthias Krüger
eedcb6abcb
move setting flags checks out of for loops, make them const.
2015-04-07 07:23:28 +02:00
PKEuS
0d127f15a5
Fixed grammar mistake; fixed two VS2013 code analysis messages; removed redundant Token::Match call
2015-03-15 10:06:56 +01:00
Dmitry-Me
22b0f37aaf
Cache and reuse value
2015-02-26 14:34:18 +03:00
Alexander Mai
b9cc5b5c6b
#6543 crash: CheckCondition::checkBadBitmaskCheck ; wine dlls/gdi32/dibdrv/primitives.c. Run astyle.
2015-02-23 22:06:55 +01:00
PKEuS
bedc935ab0
New check: Warn about constant expression if ( unknown | non_null_constant) ( #6519 )
2015-02-22 13:09:39 +01:00
Dmitry-Me
77aa385384
Remove completely redundant code
2015-02-10 13:52:04 +03:00
Daniel Marjamäki
eec938dbad
Fixed #6249 (False positive: Incorrect detection of (assignment + comparison) inside for-clause)
2015-02-05 20:17:30 +01:00
Daniel Marjamäki
d6c94e3828
isOppositeCond: Fixed FN
2015-02-01 13:03:38 +01:00
Daniel Marjamäki
d091639080
Fixed #6482 (False positive multiCondition)
2015-02-01 12:58:06 +01: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
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
ff11ba9847
Updated copyright year to 2015
2015-01-03 12:14:58 +01:00
Alexander Mai
d2caf89706
#6385 crash in Variable::getFlag(). Catch token without variable in fix for #6095 .
2014-12-31 18:19:10 +01:00
Daniel Marjamäki
5c2a2a5c22
Fixed #6095 (False positive oppositeInnerCondition - neglecting statements with side-effects)
2014-12-31 15:14:22 +01:00
Dmitry-Me
a6219adc9b
Move cheap checks earlier to avoid more expensive ones
2014-09-01 12:52:27 +04:00
Daniel Marjamäki
97005d7d87
remove redundant declaration of isSameExpression. fixes gcc compiler warning.
2014-08-30 19:23:31 +02:00
PKEuS
06a92e8981
Moved several condition checks from checkOther to checkCondition (former checkAssignIf)
2014-08-29 17:06:46 +02:00