Commit Graph

157 Commits

Author SHA1 Message Date
Paul Fultz II 1ffcc6b730 Add initial lifetime checker (#1448)
* Inital valueflow lifetime checker

* Forward values

* Add initial tests

* Fix deplicate messages

* Fix traversing nested lambdas

* Turn test case into a todo

* Skip if returning a container

* Fix FP when using references

* Add missing header

* Fix FP from broken scopes

* Fix FP with static variable

* Add test for more FPs

* Parse lambda functions

* Check for capture by value

* Add tests for using a container and lambda together

* Fix cppcheck errors

* Add test for nextAfterAstRightmostLeaf

* Add valueflow tests

* Update error message

* Check for correct lambda token

* Improve error path reporting

* Fix hang when parsing arrays that look almlost like lambdas
2018-11-10 16:40:40 +01:00
Daniel Marjamäki fb76ef1db1 Fixed testrunner 2018-11-03 18:59:55 +01:00
Daniel Marjamäki 66ca03fa0c Fixed #8826 (false negative: Invalid memory address freed) 2018-11-03 18:55:20 +01:00
Daniel Marjamäki 43233e72b2 Fixed #8691 (False negative for uselessAssignmentArg) 2018-08-17 19:56:36 +02:00
Daniel Marjamäki a4fdef8d9e Refactoring; Use Token::isUnaryOp() to clarify code 2018-07-13 23:02:52 +02:00
Daniel Marjamäki d0819e4792 Reuse isVariableChanged() in auto variables 2018-06-24 08:55:23 +02:00
Daniel Marjamäki cde63c7573 Use Variable::valueType instead of Variable::typeStartToken in auto variables 2018-06-24 08:25:19 +02:00
Daniel Marjamäki 79ffe1d4fc Rename _tokenizer, _settings, _errorLogger 2018-06-16 16:10:28 +02:00
Daniel Marjamäki f336c2efe7 Refactoring; Renamed Scope::classStart and Scope::classEnd 2018-04-27 22:36:30 +02:00
Daniel Marjamäki 2073bd02d8 Refactoring: Use range for loop 2018-04-20 22:13:05 +02:00
Daniel Marjamäki a0906140a6 Suppressions: New extensible Suppressions xml format that allow more attributes. To start with it also allows symbolName. 2018-04-09 06:43:48 +02:00
Daniel Marjamäki c110770481 Fixed #8325 (False negative: address of auto variable being returned when assigned to another variable first) 2018-01-27 14:48:45 +01:00
Daniel Marjamäki cb297a00fc Auto variables: Assign address of local variable to global pointer (#6825) 2018-01-25 22:50:41 +01:00
Daniel Marjamäki 599e038282 AutoVariables: Warn when address of local array is assigned to global pointer and pointer is not reassigned 2018-01-24 21:33:58 +01:00
Daniel Marjamäki c4caee6b18 Updated copyright year 2018-01-14 15:37:52 +01:00
PKEuS 817f66d74d Fixed crash on garbage code (#8317) 2018-01-07 12:52:28 +01:00
Ayaz Salikhov 64eccd780c Don't use static where not needed (#952) 2017-09-07 13:01:07 +02:00
Daniel Marjamäki 59034e17f1 Refactoring, reuse code to skip lambda functions 2017-08-29 22:35:55 +02:00
Ayaz Salikhov 3cd2f2d092 Don't cast bool to bool 2017-06-01 01:49:40 +03:00
Ayaz Salikhov 28aa939d69 iwyu - include what you use 2017-05-27 04:33:47 +02:00
PKEuS b1f4bd7504 Refactorization: Reimplemented Settings::_enabled as a bitfeld instead of std::set (#7995) 2017-04-11 11:49:26 +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 f68fa72095 Fixed #7583 (Defect: False positive '(error) Reference to temporary returned') 2017-02-26 13:41:49 +01:00
PKEuS ea53bd22b7 Fixed false positive returnTempReference with operator++ (#7874) 2016-12-22 11:49:59 +01:00
Daniel Marjamäki aaf19c1e4f Fixed #7839 (Prefix increment triggers parameter modification warning) 2016-12-19 15:25:36 +01:00
Daniel Marjamäki 4388435ce1 Revert "checkautovariable: fix #7818, crash when accessing nullpointer tok2->next()."
This reverts commit a5d32aa7a5.
2016-11-20 17:21:56 +01:00
Matthias Krüger a5d32aa7a5 checkautovariable: fix #7818, crash when accessing nullpointer tok2->next().
Not test case added yet because I failed to add it as .h files to testgarbage.
2016-11-16 14:46:37 +01:00
Daniel Marjamäki 4732667488 ValueFlow: allow more value types 2016-11-13 22:33:39 +01:00
PKEuS 1715969f6f Support prefix-increment/decrement in CheckAutoVariables::assignFunctionArg() (#3177) 2016-10-10 21:34:40 +02:00
Alexander Mai d492500f34 #5844 False positive: returnReference fp for inner lambda function 2016-05-20 23:46:56 +02: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
PKEuS 23ad881c64 Fixed false positive returnLocalVariable (#7180) 2016-01-30 20:18:12 +01:00
Daniel Marjamäki 5e10e680da CWE: refactoring. use constants instead of magic numbers. 2016-01-25 20:01:48 +01:00
Roberto Martelloni bb6880919c CWE mapping 2016-01-15 17:07:14 +01:00
Lauri Nurmi 996c9244d8 Update copyright year to 2007-2016. 2016-01-01 15:34:45 +02:00
Daniel Marjamäki 0f9d90d2be Changed Copyrights. Removed my name. 2015-11-18 20:04:50 +01:00
Daniel Marjamäki 71bf0f076f CheckAutoVariables: Handle 'x-y' better in isAutoVarArray 2015-11-15 19:34:36 +01:00
Daniel Marjamäki 4e578af603 CheckAutoVar: Improved usage of AST and ValueFlow 2015-11-15 14:48:13 +01:00
Daniel Marjamäki c10a10c26f CheckAutoVariables: use ValueFlow to detect more errors when pointer aliases are used 2015-11-15 12:10:35 +01:00
Daniel Marjamäki ad0d23036c Fixed some cppcheck warnings about methods that can be static/const 2015-11-14 18:43:07 +01:00
PKEuS a8cf63239a Fixed false positive autovarInvalidDeallocation if deallocting result of member function (#6551) 2015-11-11 16:59:31 +01:00
Daniel Marjamäki 47f64df8aa minor refactoring 2015-09-09 10:08:37 +02:00
Simon Martin 59abb04042 Ticket #6596: Address of local variables can also be assigned to pointer-pointer arguments using the ptr[] syntax. 2015-08-28 20:29:51 +02:00
PKEuS 7bb79562e9 Skip inner classes in CheckAutoVariables::returnReference() (#6951) 2015-08-26 13:31:51 +02:00
PKEuS 6b4a0a5ed7 Merge pull request #652 from Dmitry-Me/mergeIdenticalMAtches
Merge identical matches
2015-08-26 11:38:50 +02:00
Dmitry-Me 77317c3373 Merge identical matches 2015-08-26 10:43:15 +03:00
Simon Martin 6fb19b02d0 Properly differentiate arrays of pointers and pointers to arrays. 2015-08-25 21:19:19 +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
PKEuS a297a03b64 Fixed false positive #6787: Skip over lambdas in CheckAutoVariables::returnReference() 2015-08-14 13:03:07 +02:00
Daniel Marjamäki 9627fccdc5 assignFunctionArg: don't warn when there is self assignment. There is a separate warning for self assignments. 2015-08-09 14:51:23 +02:00