Ayaz Salikhov
b8cd7dbb5c
Use nullptr instead of 0 or NULL ( #936 )
2017-08-09 20:00:26 +02:00
orbitcowboy
0e575ce12c
Modernize: make use of 'nullptr' and added a rule-file for finding non-nullptr (zero) initializations.
2017-07-28 15:20:43 +02:00
Andreas Pokorny
b802b98136
Do not warn when unique pointers are passed by value
...
A unique pointer should only be passed by value or by const reference.
Passing by value means transferring ownership it makes no sense to have a pass by value Warning for unique_ptr
Signed-off-by: Andreas Pokorny <andreas.pokorny@siemens.com>
2017-07-25 11:17:56 +02:00
Stas Cymbalov
ff38cc5c13
Set struct size cutoff in passedByValue check to 2*sizeof_pointer
...
Struct arguments are either pushed to the stack or passed in the
registers. Since both methods operate on machine words it is logical to
tie the maximum size of a struct argument that doesn't trigger
passedByValue diagnostic to the size of the machine word.
Also guessed size of STL classes is set to 3*sizeof_pointer, this better
represents reality and ensures that structs containing them will still
trigger passedByValue.
2017-06-06 08:48:11 +02:00
Ayaz Salikhov
28aa939d69
iwyu - include what you use
2017-05-27 04:33:47 +02:00
Daniel Marjamäki
f7cda81c0c
Refactoring: ValueFlow::Value::errorSeverity() will have the logic if value is 'error' or 'warning'
2017-05-23 11:43:56 +02:00
Daniel Marjamäki
55ae206ecc
ErrorPath: better output
2017-05-19 17:29:16 +02:00
Matthias Krüger
a2c716fa3b
CheckOther::checkDuplicateExpression(): be lazier if style-reports are not enabled. NFCI.
2017-05-19 00:54:55 +02:00
Daniel Marjamäki
c617851567
ErrorLogger: Added ErrorPath where each item has token and info
2017-05-16 22:38:13 +02:00
Daniel Marjamäki
f92e7b3bfc
Emit better errorpath in CheckBufferOverrun::negativeIndexError
2017-05-16 19:08:47 +02:00
Daniel Marjamäki
8d75d1b920
Partial fix for #8028 (ValueFlow: Origin/callstack of value)
2017-05-15 20:05:11 +02:00
Daniel Marjamäki
101dc28afa
Refactoring: Moved checkMemset.. from CheckOther to CheckFunctions
2017-04-23 07:53:41 +02:00
Daniel Marjamäki
f6ab204dc6
Refactorings in CheckOther
2017-04-23 07:19:44 +02:00
PKEuS
b1f4bd7504
Refactorization: Reimplemented Settings::_enabled as a bitfeld instead of std::set ( #7995 )
2017-04-11 11:49:26 +02:00
Roberto Martelloni
35d1479d05
CWE mapping of funcArgOrderDifferent, funcArgNamesDifferent ( #885 )
...
Add an optional extended description…
2017-04-01 08:36:46 +02:00
PKEuS
3c8f5b85ae
Refactorization: Allocate Token::_values (ValueFlow information) dynamically, reducing size of each token by around 10%
2017-03-27 18:48:34 +02:00
Daniel Marjamäki
f5d56fd303
Fixed #7961 (Hang in CheckOther::checkFuncArgNamesDifferent)
2017-03-24 22:01:05 +01:00
PKEuS
00904ba32a
Fixed false negatives in CheckOther::checkPassByReference() when assignment operator is used.
2017-03-07 21:49:28 +01:00
PKEuS
3da1de7893
Do not exclude std::shared_ptr and std::unique_ptr from checkPassByReference() ( #7834 )
...
These two types are larger than one pointer. Hence, passing by reference is faster.
2017-03-07 21:18:08 +01:00
PKEuS
1c3f010935
Fixed false positive: Exclude STL shared pointers from checkPassByReference() ( #7834 )
2017-03-07 21:04:19 +01:00
Daniel Marjamäki
ecc59859e1
Don't simplify _Bool in TokenList
2017-03-04 11:13:28 +01:00
Daniel Marjamäki
b1ce229006
Small refactoring
2017-03-03 19:09:32 +01:00
Daniel Marjamäki
59c1c76a97
Fixed #7466 (Reference variable does not count side-effects (FP variableScope))
2017-03-03 19:07:00 +01:00
Ville Skyttä
2ccd5aec1a
Comment spelling fixes
...
Add an optional extended description…
2017-02-28 12:22:59 +01:00
PKEuS
3022d74801
Do not suggest pass by reference for std::initializer_list
2017-01-19 11:14:55 +01:00
Robert Reif
139071d88b
Fixed #7875 (New check: function declaration and definition argument names don't match)
2017-01-05 08:52:11 +01:00
Daniel Marjamäki
770abcf453
Fixed #5398 (False positive: Scope of variable can be reduced does not account for other variables not reduceable)
2016-12-26 14:14:40 +01:00
Roberto Martelloni
04f24b4220
CWE mapping of accessMoved, accessForwarded, nullPointerArithmeticRedundantCheck, nullPointerArithmetic
2016-12-24 23:07:37 +00:00
Daniel Marjamäki
df6ae9f3b4
Fixed #7847 (Can't detect shift negative values when some op is executed)
2016-12-22 09:40:19 +01:00
Frank Zingsheim
9a871d33f7
Improve Fix #6180 ("reset" and "clear" clears the move status)
2016-12-17 16:39:30 +01:00
PKEuS
2f6350a0d0
Refactorized Library
2016-12-06 14:09:28 +01:00
Matthias Krüger
4cf85b72b6
CheckOther::checkAccessOfMovedVariable: don't warn if --enable=warning is not given.
2016-11-20 18:44:37 +01:00
Frank Zingsheim
c8ff96fe8f
Fixed #6180 (Usage of variable after std::move or std::forward)
2016-11-20 15:14:49 +01:00
PKEuS
e23dc5c1e2
Fixed wrong message shown if unused label appears directly after a switch() scope
2016-11-20 14:43:54 +01:00
orbitcowboy
919f8ac323
Fixed typos. There are no real changes.
2016-11-04 15:01:05 +01:00
Daniel Marjamäki
a85eacc157
cstyleCast: don't warn about '(const Variable *)nullptr'
2016-10-18 22:56:33 +02:00
Boris Egorov
0154d39bf6
Show struct member in unsignedLessThanZeroError warning
...
Before:
[/tmp/test.c:8]: (style) Checking if unsigned variable '.' is less than zero.
[/tmp/test.c:12]: (style) Checking if unsigned variable '.' is less than zero.
After:
[/tmp/test.c:8]: (style) Checking if unsigned variable 'd.n' is less than zero.
[/tmp/test.c:12]: (style) Checking if unsigned variable 'd.n' is less than zero.
2016-09-22 08:03:30 +07:00
Matthias Krüger
2f39ed6f88
redundantPointerOpError: put pointer name into single quotes in the error message.
2016-09-16 22:18:24 +02:00
Daniel Marjamäki
24c6d92667
astyle formatting
...
[ci skip]
2016-08-29 04:08:38 +02:00
Daniel Marjamäki
939b42df06
Fixed #7134 (False positive redundantAssignment - assignment to local variable of unknown type)
2016-08-29 03:48:08 +02:00
orbitcowboy
87409ea6b3
Running astyle; Improved testing of std::find; std.cfg: Added support for istream::read and ifstream::read.
2016-08-25 19:17:07 +02:00
Roberto Martelloni
1db24ee070
CWE mapping of signedCharArrayIndex, unknownSignCharArrayIndex, suspiciousCase, suspiciousEqualityComparison, duplicateBranch, duplicateExpressionTernary, suspiciousSemicolon, incompleteArrayFill, redundantPointerOp, unusedLabelSwitch, unusedLabel, unknownEvaluationOrder, stlIfFind, useAutoPointerCopy
2016-08-25 15:40:23 +01:00
Roberto Martelloni
01ee9ee5e6
CWE mapping of invalidLengthModifierError, leakUnsafeArgAlloc, nullPointerDefaultArg, nullPointerRedundantCheck, raceAfterInterlockedDecrement.
2016-08-24 15:37:14 +01:00
Daniel Marjamäki
bd21cd7c85
Fixed #6309 (FP: checkRedundantAssignment should not warn for pointer alias)
2016-08-08 21:43:00 +02:00
PKEuS
ad96f7b519
Fixed wrong variable being used in CheckOther::checkPassByReference()
2016-08-04 15:30:59 +02:00
PKEuS
452ecc7ceb
Improved check: Detect passedByValue even for arguments that are not declared as "const"
2016-07-28 19:37:10 +02:00
Daniel Marjamäki
0767284ca1
Fixed #7630 (FP: dead store, modifying array, index var modified)
2016-07-25 07:35:33 +02:00
Daniel Marjamäki
03d2829fb9
Merge simplecpp branch
2016-07-20 12:21:00 +02:00
Daniel Marjamäki
f55040a987
Fix segfault when there is no ast generated in lambda function
2016-07-18 14:08:44 +02:00
Daniel Marjamäki
0ddeac0429
refactor (use ast) and improve CheckOther::checkRedundantAssignment (warn about global variables unless they are volatile, handle arrays in lhs better)
2016-07-18 12:43:23 +02:00
PKEuS
7a183779e2
CheckOther::checkMemsetZeroBytes(): Support wmemset()
2016-07-16 21:53:25 +02:00
Daniel Marjamäki
d1f06ff47c
Fixed #7175 (False positive performance warning (buffer overwritten before its old content has been used))
2016-06-13 15:46:43 +02:00
Roberto Martelloni
dce7128f30
CWE mapping of duplicateExpression, duplicateBreak (CWE561), unreachableCode, unsignedLessThanZero, unsignedPositive, pointerLessThanZero, pointerPositive, varFuncNullUB, nanInArithmeticExpression, commaSeparatedReturn, ( #797 )
...
ignoredReturnValue
2016-05-22 13:17:38 +02:00
Roberto Martelloni
afa8ad0ebe
CWE mapping of selfAssignment, wrongmathcall, unpreciseMathCall, memsetZeroBytes, memsetFloat, memsetValueOutOfRange, clarifyCalculation, clarifyStatement
2016-05-14 10:13:33 +01:00
PKEuS
0bf85f9aa5
ValueType: Support integers defined in libraries ( #7394 )
2016-05-04 15:39:56 +02:00
Roberto Martelloni
01aaa56740
CWE mapping of redundantCopy, redundantAssignment, constStatement, charBitOp, variableScope, redundantAssignInSwitch, redundantCopyInSwitch, switchCaseFallThrough
2016-04-29 18:01:37 +01:00
Daniel Marjamäki
dc2a92263a
Fixed #7426 (RFC: time to replace simplifyEnum?)
2016-04-22 06:02:54 +02:00
Daniel Marjamäki
00a584d8d1
astyle formatting
2016-04-22 06:01:34 +02:00
Roberto Martelloni
e89cd1b8a4
CWE mapping of unsafeClassCanLeak, zerodivcond, invalidPointerCast, redundantCopy, redundantAssignment, comparisonFunctionIsAlwaysTrueOrFalse, checkCastIntToCharAndBack, cstyleCast, passedByValue, clarifyCondition, exceptThrowInDestructor, exceptDeallocThrow, exceptRethrowCopy, catchExceptionByValue, fflushOnInputStream, seekOnAppendedFile, publicAllocationError
...
CWE mapping of unsafeClassCanLeak, zerodivcond, invalidPointerCast, redundantCopy, redundantAssignment, comparisonFunctionIsAlwaysTrueOrFalse, checkCastIntToCharAndBack, cstyleCast, passedByValue, clarifyCondition, exceptThrowInDestructor, exceptDeallocThrow, exceptRethrowCopy, catchExceptionByValue, fflushOnInputStream, seekOnAppendedFile, publicAllocationError
2016-04-12 19:29:40 +02:00
Dmitry-Me
1f27c4b76b
Merge pull request #771 from Dmitry-Me/charUsedAsArrayIndex
...
Portability warning when 'char' type is used as array index
2016-02-10 20:11:38 +03:00
Dmitry-Me
c3399493ef
Portability warning when 'char' type is used as array index
2016-02-08 10:08:35 +03:00
PKEuS
b3a0d418e6
Refactorization: Compare only as much characters as necessary in Preprocessor
...
Fixed internal message
2016-02-05 21:06:07 +01:00
PKEuS
c66db46f66
Use ValueType in CheckOther::checkSignOfUnsignedVariable()
...
Fixed travis: replaced std::string::pop_back by std::string::substr
2016-02-05 20:43:06 +01:00
PKEuS
b4b38fb7ce
Use ValueType in CheckOther::invalidPointerCast()
...
False negative: operator new is currently not supported by ValueType.
2016-02-05 20:28:43 +01:00
PKEuS
841f17776b
Set ValueType for assignment operators, detect division by zero for %= and /= again ( #7322 )
2016-02-02 17:17:55 +01:00
PKEuS
9d2258677d
Improved CheckOther::checkUnusedLabel(): Write a warning instead of a style message if it happens inside a switch()
2016-01-31 12:07:24 +01:00
Daniel Marjamäki
5e10e680da
CWE: refactoring. use constants instead of magic numbers.
2016-01-25 20:01:48 +01:00
Roberto Martelloni
5ce69da02d
Mapped 26 errors to their CWEs ID.
2016-01-24 20:53:05 +00:00
Daniel Marjamäki
79aec559d5
Fixed #7243 (False positive unknownEvaluationOrder - comma operator inside while-clause)
2016-01-18 16:10:51 +01:00
Matthias Krüger
7b1710a44f
redundantAssignment: change from severity 'performance' to 'style' since avoiding unneccessary stores is a basic optimization done by compilers.
2016-01-15 22:01:40 +01:00
Matthias Krüger
e9e496199c
CheckOther::memsetZeroBytesError: remove now unused parameter.
...
was:
lib/checkother.cpp:1116:76: warning: unused parameter ‘varname’ [-Wunused-parameter]
void CheckOther::memsetZeroBytesError(const Token *tok, const std::string &varname)
^
2016-01-12 23:55:02 +01:00
Alexander Mai
7802517a69
#7285 wrong var name: memset() called to fill 0 bytes of '&' memset with pointer: remove var name from message. Correct some entries in posix.cfg.
2016-01-12 23:20:48 +01:00
Daniel Marjamäki
b2386fa011
minor refactoring, use 'else if' when appropriate
2016-01-06 15:49: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
bd1037e95b
Fixed #7242 (False positive unknownEvaluationOrder - comma expression in function argument)
2015-12-29 12:06:42 +01:00
Daniel Marjamäki
0ddb5c12ce
Fixed #7238 (False positive unknownEvaluationOrder for comma operator on C code)
2015-12-28 13:45:55 +01:00
Daniel Marjamäki
908bc664a4
Evaluation order: ignore usage in sizeof
2015-12-27 14:08:16 +01:00
Daniel Marjamäki
c672210e06
Evaluation order: don't warn for 'dostuff(expr++, &expr)'
2015-12-26 15:48:43 +01:00
Daniel Marjamäki
e6ff77d825
Evaluation order: Don't use this checker on C++11 code
2015-12-25 18:57:59 +01:00
Daniel Marjamäki
90148ce2a1
Evaluation order: Only use this checker on non-C++11 code
2015-12-25 18:49:34 +01:00
Daniel Marjamäki
55779a5772
Evaluation order: Only use this checker on non-C++11 code
2015-12-25 18:45:46 +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
27af1bcfd8
Fixed #7229 (Improve check; unknown evaluation order, write different message for self assignment)
2015-12-25 18:00:19 +01:00
Daniel Marjamäki
90a54b1fae
Fixed #7232 (False positive unknownEvaluationOrder on id = Remap( id += 42 );)
2015-12-25 16:45:11 +01:00
PKEuS
940d569980
Refactorization: Removed redundant %any% patterns.
2015-12-24 14:40:48 +01:00
Daniel Marjamäki
81f0597316
Fixed #3206 and #7226 (New check: Undefined execution order)
2015-12-24 09:13:20 +01:00
Daniel Marjamäki
0baad496f2
Fixed #6383 (FP shiftNegative - value converted to unsigned in function argument)
2015-12-14 10:55:23 +01:00
PKEuS
57e9954390
Merge pull request #715 from Dmitry-Me/eliminateRepeatedLookup3
...
Remove repeated lookup
2015-12-07 10:47:37 +01:00
Dmitry-Me
f00a73f1a1
Remove repeated lookup
2015-12-07 11:57:04 +03:00
Alexander Mai
9d8dffbd79
#6269 false positives in case of overloaded standard library functions. Detect memset() with proper argument cound, using new function numberOfArguments()
2015-12-06 12:50:05 +01:00
PKEuS
b8d39a2229
Refactorizations:
...
- Improve performance of simplifyTypedef by using Token::simpleMatch by ~15%
- Simplified code in simplifyTypedef
- Ran AStyle
2015-12-02 23:32:50 +01:00
Dmitry-Me
0a3959f201
Remove duplicate check
2015-12-02 17:28:21 +03:00
Dmitry-Me
8f8a0097fe
Detect more non-interlocked accesses
2015-12-02 10:58:57 +03:00
Daniel Marjamäki
fb8cce647c
invalidTestForOverflow: Refactor; move from checkother to checkcondition
2015-11-30 08:51:15 +01:00
Daniel Marjamäki
f6f4f27636
CheckOther::checkInvalidTestForOverflow: minor fix, only warn when warnings are enabled.
2015-11-29 22:03:42 +01:00
Daniel Marjamäki
26a07265a8
Fixed #7184 (Invalid test for overflow 'p + x < p')
2015-11-29 20:59:50 +01:00
Daniel Marjamäki
4fa888ec44
Warn when shifting a negative value, it is UB. ( #4931 )
2015-11-29 16:28:55 +01:00
PKEuS
e8522c7883
Small refactorizations:
...
- #include cleanup
- Use std::array instead of std::vector
- Do not create a stringstream to concatenate 4 strings
- Use std::cout instead of printf
2015-11-29 10:56:44 +01:00
PKEuS
f516de8633
Moved a few checks from CheckOther to CheckFunctions
2015-11-22 13:49:10 +01:00