Commit Graph

10082 Commits

Author SHA1 Message Date
Daniel Marjamäki a8cbbe0e16 Fixed #8816 (FP shadowLocal - variable shadows a template function?) 2018-11-19 07:00:15 +01:00
Daniel Marjamäki 9ef3c79bc6 Fixed #8851 (Crash in valueFlowContainerForward (daca@home: pbbam)) 2018-11-18 20:18:55 +01:00
Daniel Marjamäki f2b26a488a relative paths: another fix for {code} 2018-11-18 16:15:09 +01:00
Daniel Marjamäki 982f7dc2b3 relative paths: show {code} properly when there are relative paths 2018-11-18 16:08:08 +01:00
Paul Fultz II 7ef119cbfc Fix FPs in lifetime checker
This fixes several FPs in the lifetime checker. It also fixes issue [8846](https://trac.cppcheck.net/ticket/8846):

```cpp
int * f(int a[])
{
        return a;
}
```
2018-11-17 09:41:59 +01:00
Paul Fultz II d376e9f245 Track variable lifetime through function calls (#1481) 2018-11-16 06:12:28 +01:00
Daniel Marjamäki 5d086d60ad Fixed #8844 (snd: Wrong varid and ast) 2018-11-14 21:05:09 +01:00
Daniel Marjamäki 69f2e0938a VarId: Improved varids for struct members (#8844) 2018-11-14 19:11:35 +01:00
Daniel Marjamäki 39c04b650d astyle formatting
[ci skip]
2018-11-14 19:10:52 +01:00
Daniel Marjamäki 69f6100d83 Fixed #8339 (false positive: unread variable despite delete is used on it) 2018-11-14 17:04:21 +01:00
Paul Fultz II 54453c5802 Fix FP when copying pointer to string (#1479) 2018-11-14 06:59:25 +01:00
Daniel Marjamäki ac242b69d6 Refactoring: Use range for loops 2018-11-14 06:58:21 +01:00
Paul Fultz II f0c86b9d14 Fix issue 8842: Crash in valueFlowTerminatingCondition on incomplete code (#1480) 2018-11-14 06:23:45 +01:00
Paul Fultz II e839001f3d Fix warnings (#1478) 2018-11-14 06:14:04 +01:00
Daniel Marjamäki d97851b9db change severity for 'unknown macro' to error for now. 2018-11-13 21:08:45 +01:00
Daniel Marjamäki 152be6df63 Report 'unknown macro' as information message with id unknownMacro 2018-11-13 20:14:56 +01:00
Daniel Marjamäki a50eb56d8d Extend 'Unknown macro' check 2018-11-13 18:30:40 +01:00
Daniel Marjamäki e6a5e0f752 Warn when there is a unknown macro 2018-11-13 16:49:15 +01:00
Daniel Marjamäki 69e7392ce2 Fixed #8449 (False positive 'constStatement' when initializing std::unordered_map) 2018-11-12 18:10:34 +01:00
Daniel Marjamäki 3d629944da Fixed #8100 (False positive when method/function defines lambda with pointer return value) 2018-11-12 11:28:38 +01:00
Daniel Marjamäki f096d7f474 astyle formatting
[ci skip]
2018-11-12 10:08:57 +01:00
Paul Fultz II 0e11bb07c8 Extend lifetime analysis to pointer usage (#1477)
* Use lifetime analysis for pointers as well

* Fix issue 1143: Pointer to local array

* Update message when using pointers

* Avoid infinite loop in tracing lifetimes
2018-11-12 10:08:17 +01:00
Daniel Marjamäki 717a2d370c astyle formatting
[ci skip]
2018-11-12 06:32:02 +01:00
Daniel Marjamäki 58882b1f14 Fixed #8261 (False positive "Statements following return, break, continue, goto or throw will never be executed.") 2018-11-12 06:31:17 +01:00
Paul Fultz II 5bda102897 Fix warnings (#1476) 2018-11-12 06:08:57 +01:00
Paul Fultz II 68d6b96878 Diagnose invalid lifetimes (#1475)
* Add check for invalid lifetimes

* Fix FP with member variables

* Dont forward lifetime values in subfunction

* Update message to use out of scope
2018-11-11 16:43:54 +01:00
Daniel Marjamäki bdd4623124 valueFlowLibraryFunction: fix crash found with daca@home 2018-11-11 16:41:01 +01:00
Daniel Marjamäki 3f55707b30 Fixed #8064 (Taking the address of a moved variable is not accessing it) 2018-11-11 12:47:27 +01:00
Paul Fultz II e46691597e Fix issue 8841: FP knownConditionTrueFalse - Dont treat unknown function as noreturn (#1474)
* Fix issue 8841: Dont treat unknown function as noreturn

* Add a parameter to set default value when the function is unknown
2018-11-11 08:04:01 +01:00
Daniel Marjamäki ee2dfb6604 Fixed #8058 (False positive returnAddressOfAutoVariable within lambda) 2018-11-11 07:52:38 +01:00
Daniel Marjamäki 93cde415a7 Fixed #7988 (variable in condition gets wrong varid) 2018-11-11 07:50:25 +01:00
Daniel Marjamäki 148f257c6b Fixed #8838 (False positive on overridden virtual function that is marked both const and final) 2018-11-10 21:57:50 +01:00
Daniel Marjamäki 8327aab127 Fixed #8628 (Wrong AST in case) 2018-11-10 21:32:06 +01:00
Daniel Marjamäki d5a478d5c5 astyle formatting
[ci skip]
2018-11-10 21:30:01 +01:00
Daniel Marjamäki 4cef2e94e7 Fixed #8368 (FP redundantAssignment - assignment has unknown side-effects) 2018-11-10 18:42:13 +01:00
IOBYTE 69e6e11844 Fix a template simplifier namespace bug in #7145 (#1473)
* Fix a template simplifier namespace bug in #7145

* Refactor template simplifier to only call getTemplateDeclarations once per loop.
2018-11-10 16:41:14 +01:00
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
IOBYTE e302e6e7a1 Fix symbol database argsMatch to skip all redundant type information (class, struct, union, enum) (#1472) 2018-11-09 15:54:17 +01:00
rikardfalkeborn a3e717bea9 Use functions instead of comparing with enum (#1471)
* Use isComparisonOp() instead of enum

* Use isAssignmentOp() instead of enum
2018-11-09 06:30:41 +01:00
IOBYTE 67fe99fcd9 Fix symbol database argsMatch function and its usage so qualified types are handled properly. (#1470)
* Fix symbol database argsMatch function and its usage so qualified types are handled properly.

* Remove assert.
2018-11-09 06:11:48 +01:00
Paul Fultz II 36e663e250 Fix issue 8839: FP knownConditionTrueFalse - condition inside a while-clause (#1469) 2018-11-09 06:09:51 +01:00
IOBYTE 17a8a4898d Fix another template simplifier namespace bug. (#1467)
* Fix another template simplifier namespace bug.

* Add missing forward declarations caused by token bug.
2018-11-07 21:25:42 +01:00
Paul Fultz II 7373be2bfa Add a pass in valueflow for terminating conditions (#1323)
* Add valueflow for terminating conditions

* Add valueflow test

* Dont check for same expressions for now to avoid double diagnostics

* Check nesting

* Add more tests

* Ensure conditions happen in order

* Check for null

* Add error path

* Support same expression check as well

* Use early continue

* Skip checking the same token

* Avoid double condtion diagnosis

* Fix FP when in switch statements

* Fix FP when time function

* Skip conditional escapes

* Use simpleMatch

* Fix naming

* Fix typo
2018-11-07 06:49:07 +01:00
Daniel Marjamäki 35d18be311 ValueFlow: Refactoring, removed redundant assignment 2018-11-06 07:02:20 +01:00
IOBYTE c966f31183 Fixed #8835 (friend class and non-empty constructor: Uninitialized members not reported) (#1466) 2018-11-06 06:44:08 +01:00
Daniel Marjamäki 00340efc57 ValueFlow: Refactoring valueFlowCallFunction 2018-11-06 06:38:26 +01:00
IOBYTE 9b67e680ae Fix template simplifier namespace support. (#1464) 2018-11-05 19:55:21 +01:00
Daniel Marjamäki ca19894a04 ValueFlow: In evaluate handle correlated values 2018-11-05 18:07:35 +01:00
Daniel Marjamäki da44ce0b5d ValueFlow: evaluate strlen and char literals better 2018-11-05 16:52:12 +01:00
Daniel Marjamäki 307a19d17e Refactoring: Use range for loop 2018-11-05 09:49:28 +01:00