Paul Fultz II
6ea4f60600
Enable valueFlowSubfunction for multiple parameters ( #2550 )
2020-03-01 16:46:20 +01:00
Paul Fultz II
392060aefe
Fix issue 7804: ValueFlow: possible value in second if body ( #2543 )
2020-02-19 07:55:04 +01:00
Paul Fultz II
921887a281
Use valueFlowGeneric for valueFlowForwardExpression ( #2537 )
2020-02-16 16:02:22 +01:00
Paul Fultz II
7368a54629
Add generic valueflow forward analysis ( #2511 )
2020-02-13 16:27:06 +01:00
amai2012
b621c35539
Astyle formatting [ci skip]
2020-01-05 17:00:34 +01:00
Paul Fultz II
90f82d0374
Fix issue 9541: false negative: knownConditionTrueFalse ( #2473 )
...
* Fix issue 9541: false negative: knownConditionTrueFalse
* Add another test case
* Add another test
* Fix FPs
* Format
* Fix compile error
* Remove double conditions
* Fix compile error
2020-01-05 16:25:33 +01:00
Daniel Marjamäki
36f369473e
isPointerDeref: Return false for function declarations
2019-12-15 16:36:46 +01:00
Paul Fultz II
36977becba
Fix issue 9196: Lambda confuses check ( #2415 )
2019-12-03 18:30:52 +01:00
Paul Fultz II
a71f58ffc2
Fix issue 9441: false positive: new(std::nothrow) and nullPointerRedundantCheck ( #2403 )
...
* Fix issue 9441: false positive: new(std::nothrow) and nullPointerRedundantCheck
* Skip new if it is a variable
2019-12-01 12:16:31 +01:00
Paul Fultz II
79a2e61721
Fix issue 6850: Valueflow: pointer alias, conditional value ( #2402 )
2019-11-30 09:22:03 +01:00
Sebastian
fd900ab8b2
testnullpointer.cpp: Add test for dereferencing returned NULL pointer ( #2401 )
...
This adds a regression test to make sure that directly dereferencing a
returned NULL pointer issues a warning.
This has been asked on Stack Overflow:
https://stackoverflow.com/q/58981369
Cppcheck 1.89 does not warn for such a code, but 1.90 dev does. So it
is a good idea to make sure it is detected in the future too I guess.
2019-11-27 19:41:36 +01:00
Sebastian
c3c3d6770c
Fix #9478 : Valueflow: printf does not change value ( #2388 )
...
Format-string arguments are now marked to have `in` direction, except
for `scan`-functions (like `scanf`) where these arguments are explicitly
marked to have `out` direction.
2019-11-24 01:40:31 +01:00
Paul Fultz II
6f29e299fc
Fix issue 9439: false positive: unique_ptr and nullPointerRedundantCheck ( #2346 )
2019-11-10 09:44:59 +01:00
Paul Fultz II
c75bbbe253
Fix issue 9404: False positive: Either the condition 'if(x)' is redundant or there is possible null pointer dereference: a->x ( #2322 )
...
* Fix issue 9404: False positive: Either the condition 'if(x)' is redundant or there is possible null pointer dereference: a->x
* Use simpleMatch
* Add a test case for the FP
* Check if expression is changed
* Check for no return scope
* Use simpleMatch
2019-11-08 08:11:41 +01:00
Paul Fultz II
acd2a92efc
Fix issue 9395 and 9423: False positive: nullPointerRedundantCheck ( #2323 )
2019-11-04 07:02:25 +01:00
Daniel Marjamäki
78c02f0505
ValueFlow: Fixed false positives after escape scope
2019-10-20 20:57:16 +02:00
Daniel Marjamäki
e50b9e2bef
Fixed #8784 (False positive uninitialized variable)
2019-10-20 15:20:05 +02:00
orbitcowboy
f05e21efa8
Formatted the code, there are no functional changes [ci skip].
2019-10-01 08:39:08 +02:00
Paul Fultz II
166bd2bafc
Fix issue 2153: valueFlowAfterCondition: struct member ( #2228 )
...
* Fix issue 2153: valueFlowAfterCondition: struct member
* Fix null pointer dereference
* Formatting
* Check for another null pointer
* Initialize variables
* Remove redundant condition
* Format
* Add missing initialization to copy constructor
* Format
2019-09-30 21:04:43 +02:00
Daniel Marjamäki
049f6475ee
astyle formatting
...
[ci skip]
2019-09-20 15:07:27 +02:00
Paul Fultz II
ad8abdb0c3
Add impossible values to ValueFlow ( #2186 )
...
* Add impossible category
* Replace values
* Try to adjust known values
* Add ! for impossible values
* Add impossible with possible values
* Remove contradictions
* Add values when the branch is not dead
* Only copy possible values
* Dont bail on while loops
* Load std lib in valueflow
* Check for function calls
* Fix stl errors
* Fix incorrect impossible check
* Fix heap-after-use error
* Remove impossible values when they are lowered
* Show the bound and remove overlaps
* Infer conditions
* Dont push pointer values through dynamic_cast
* Add test for dynamic_cast issue
* Add shifttoomanybits test
* Add test for div by zero
* Add a test for issue 9315
* Dont make impossible value inconclusive
* Fix FP with shift operator
* Improve handleKnownValuesInLoop for impossible values
* Fix cppcheck warning
* Fix impossible values for ctu
* Bailout for streams
* Check equality conditions
* Fix overflows
* Add regression test for 9332
* Remove duplicate conditions
* Skip impossible values for invalid value
* Check for null
* Rename bound to range
* Formatting
2019-09-20 15:06:37 +02:00
Paul Fultz II
9ef64eb33e
Add regression test for issue 9264: FP nullPointerRedundantCheck - pointer alias ( #2133 )
2019-09-01 09:58:53 +02:00
Paul Fultz II
9aa97cbb95
Fix issue 8296: ValueFlow: value not set in conditional scope in subfunction ( #2071 )
...
* Fix issue 8296: ValueFlow: value not set in conditional scope in subfunction
* Refactor condition checkingg
* Make test case TODO
2019-08-11 15:39:37 +02:00
Paul Fultz II
bd02ca5ccb
Fix issue 9207: Not detected 'always true' and unreachable code
2019-08-08 07:46:47 +02:00
Paul Fultz II
aaeec462e6
Re-enable valueFlowSubFunction ( #2063 )
...
* Re-enable valueFlowSubFunction
* Formatting
* Skip ternary operators in subfunctions
* Fix test with iostreams
* Fix FP with multiple parameters
2019-08-05 16:26:32 +02:00
Paul Fultz II
ab0fcc7640
Fix issue 9216: reset() method confusion ( #2025 )
...
* Fix issue 9216 with smart pointer reset
* Check for arrow
2019-07-23 22:45:58 +02:00
Daniel Marjamäki
57c6628732
Revert 'Cleaning up unsimplified templates'. This fix caused problems.
2019-05-16 21:11:04 +02:00
Daniel Marjamäki
d58d4273f9
Cleaning up unsimplified templates
2019-05-11 13:00:03 +02:00
Paul Fultz II
a688df0ea1
Fix issue 9120: crash in valueflow ( #1822 )
2019-05-05 09:51:36 +02:00
Paul Fultz II
39f4374446
Improve diagnostics with null smart pointers ( #1805 )
...
* Warn when dereferencing null smart pointers
* Improve tracking of smart pointer values
* Use library isSmartPointer
2019-04-26 11:30:09 +02:00
Daniel Marjamäki
b0c92c1ac1
CheckNullPointer: Use library instead of hardcoding
2019-03-17 07:37:38 +01:00
Daniel Marjamäki
3dc34f1515
Disable all simplified checks
2019-03-16 09:17:50 +01:00
Daniel Marjamäki
4f5a426fe5
Improved isVariableChangedByFunctionCall, better logic when parameter might be passed by reference
2019-02-28 17:02:46 +01:00
Kamil Dudka
21c22d0d4d
TestNullPointer: add regression test to cover #8813 ( #1699 )
...
... which is fixed since 1.86-72-gbc34f0239
2019-02-26 17:14:45 +01:00
Daniel Marjamäki
bd7790fd8c
Update copyright year
2019-02-09 07:24:06 +01:00
amai2012
738fef6c27
Run astyle
2019-01-12 21:51:39 +01:00
Daniel Marjamäki
8dd641b8be
Use OVERRIDE in test
2019-01-12 15:45:25 +01:00
Daniel Marjamäki
aa4f61acdf
CTU: Avoid FP in else block
2018-12-31 08:24:39 +01:00
Daniel Marjamäki
fb6a291370
CTU: Avoid FP in code protected by &&,||,?
2018-12-31 08:16:21 +01:00
Daniel Marjamäki
91a580cbd7
CTU: more warnings
2018-12-30 18:31:37 +01:00
Daniel Marjamäki
c8901e9bab
CTU: Find paths better
2018-12-30 16:23:25 +01:00
Daniel Marjamäki
d18f5d8709
CTU: Reuse CheckNullPointer::isPointerDeRef in the nullpointer isUnsafeUsage
2018-12-29 09:26:57 +01:00
Daniel Marjamäki
271763e680
CTU: Refactoring
2018-12-25 21:11:23 +01:00
Daniel Marjamäki
a1dca6acd5
Fix CTU nullpointer check
2018-12-25 12:04:01 +01:00
Daniel Marjamäki
bc34f0239d
Disable the subfunction value flow analysis. It does not work well and needs to be rewritten. There are false positives.
2018-12-18 14:36:49 +01:00
Daniel Marjamäki
0f63874c62
Take back the whole program analysis for null pointers and uninitialized variables
2018-12-18 07:56:33 +01:00
Daniel Marjamäki
ef35b86b4a
Multipass Valueflow
2018-11-03 15:53:24 +01:00
Daniel Marjamäki
45379a3aa6
Updated copyright year for modified files
...
[ci skip]
2018-06-10 22:07:21 +02:00
IOBYTE
ce50df8047
Fix override warnings. ( #1234 )
2018-05-15 16:37:40 +02:00
Paul Fultz II
0197343e0c
Fix false positive when using null arithmetic with class type ( #1214 )
2018-05-09 09:06:49 +02:00
Daniel Marjamäki
7dfbe7389b
Clarify null pointer arithmetic message
2018-05-02 12:57:24 +02:00
Daniel Marjamäki
b2343a2d4b
Fixed #8518 (Clarify warning for a NULL pointer which is received by a function call parameter.)
2018-05-01 17:30:29 +02:00
Paul Fultz II
d8b3fa5c70
Fix #8482 : Regression with valueflow ( #1159 )
...
* Fix regression with valueflow
* Simplify test case
2018-04-09 16:13:17 +02:00
PKEuS
bbfcccf078
Refactorization: Replace several push_back-sequences by initializer lists
2018-04-09 09:41:24 +02:00
Paul
d240a36a60
Extend nullPointerArithmetic to check for addition as well
2018-04-03 21:32:37 +02:00
Daniel Marjamäki
58066b1f0c
Remove whole program analysis from 'uninitialized variables' and 'null pointer dereference' checkers. I think this logic can more or less be added in ValueFlow instead and then all ValueFlow checkers should get whole program analysis.
2018-02-06 14:56:17 +01:00
Daniel Marjamäki
4998248501
Null pointers: Fixed false positives when running whole program analysis. Copied the fix from the CheckUninitVar::isUnsafeFunction.
2018-02-04 15:29:57 +01:00
Daniel Marjamäki
c4caee6b18
Updated copyright year
2018-01-14 15:37:52 +01:00
Ayaz Salikhov
28aa939d69
iwyu - include what you use
2017-05-27 04:33:47 +02:00
Daniel Marjamäki
040d2f0012
Use simplecpp lexer in test cases
2017-05-18 21:52:31 +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
7fd04cd8d0
Updated Token::expressionString(), write '->' instead of '.'
2017-04-30 14:22:18 +02:00
Daniel Marjamäki
37fd60e879
Fixed #7293 (Use of uninitialized pointer not detected (worked in 1.71))
2017-04-24 18:27:16 +02:00
PKEuS
de86d40c97
Fixed handling of NULL and nullptr in CheckNullPointer
2017-02-24 19:44:28 +01:00
PKEuS
b08f99a082
Fixed false negative: nullpointer passed as std::string argument ( #7927 )
...
Refactorization: Removed dead code from CheckNullPointer::parseFunctionCall()
2017-02-24 19:10:34 +01:00
PKEuS
2f6350a0d0
Refactorized Library
2016-12-06 14:09:28 +01:00
Stefan Weil
57b57428c2
Fix some typos in comments (found by codespell)
...
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2016-11-27 11:40:42 +01:00
Frank Zingsheim
d4f01583b6
Fixed TODO (check if function parameter is non-const reference etc..) by common function
2016-11-01 14:06:30 +01:00
Daniel Marjamäki
efa3aba32a
Remove Tokenizer::simplifyNull()
2016-10-18 21:44:02 +02:00
Daniel Marjamäki
af5dd2c29e
New check: Pointer overflow (null pointer subtracted)
2016-10-09 15:15:29 +02:00
Daniel Marjamäki
ed4a47de45
Tokenizer: Improve syntax checking of switch,if,while
2016-07-22 16:54:24 +02:00
PKEuS
923f7f843d
Better distinguishing between possible and known null pointer dereferenciations ( #7157 )
2016-01-30 20:43:40 +01:00
Daniel Marjamäki
4a3ece5847
CheckNullPointer: Fix FP for 'buf[p]' when p is NULL
2016-01-20 08:42:58 +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
PKEuS
3a5cef8a7e
Refactorization: Improved usage of Settings instances in test suite
2015-10-07 18:40:03 +02:00
Frank Zingsheim
1fd9ba0cc4
Fixed #6988 (incorrect nullPointer error for string)
2015-09-13 10:53:05 +02:00
Daniel Marjamäki
871b02ea88
removed testcase for #5238 . it's not good enough.
2015-08-15 07:38:56 +02:00
Martin Ettl
84486605ec
#6392 : Added a regression test case.
2015-08-15 01:00:36 +02:00
Martin Ettl
278808daa9
#5238 : Added a regression test case.
2015-08-15 00:49:07 +02:00
Martin Ettl
640ec3a099
#6491 : Added a regression test.
2015-08-15 00:31:26 +02:00
Alexander Mai
0b96b9d984
#6505 ValueFlow: handle 2 related if in valueFlowSubFunction. Regression test. Bug got fixed before
2015-07-31 21:15:43 +02:00
Daniel Marjamäki
6790d91fbb
Improve error messages for conditional values. make valueFlowSwitchVariable values conditional that depend on the case. Partial fix for #6884 .
2015-07-29 19:54:57 +02:00
PKEuS
176b3925b3
Removed "verify" code in testrunner. Fixing its messages reduces the accuracy of the test suite.
2015-07-25 14:18:41 +02:00
Daniel Marjamäki
eb0db322eb
Fixed #6560 (ValueFlow: handling ternary operator better in valueFlowSubFunction)
2015-05-24 17:02:00 +02:00
Daniel Marjamäki
bdc024bd7c
Fixed 6634 (false positive: dereferencing null pointer in a sizeof operation)
2015-04-20 13:46:02 +02:00
Robert Reif
4ceb24630d
Fixed #6568 : Scope for template class member function missing in symboldatabase
2015-04-09 21:01:47 +02:00
Daniel Marjamäki
fd6bd97972
Fixed #6495 (Improve check: uninitialized variable, 3rd function argument)
2015-03-14 19:23:33 +01:00
PKEuS
bc5132e0ac
Refactorization: Moved declaration of errout, ... to testsuite.h, uniformized style
2015-03-11 22:54:43 +01:00
PKEuS
451a277b18
Refactorization: Support function default values in ValueFlow, removed now obsolete CheckNullPointer::nullPointerDefaultArgument().
...
-> Use valueFlowForward() to parse values passed to functions
-> valueFlowForward(): Set value in first occurrence of a variable in a condition
2015-02-01 15:15:00 +01:00
PKEuS
21cb0cfd60
Take simplifyIfNotNull and simplifyIfNot out of simplifyTokenList1 (first step for #6072 )
2015-01-31 20:12:02 +01:00
Daniel Marjamäki
8d2f271921
clean up cfg tests in TestNullPointer
2015-01-30 06:51:03 +01:00
Daniel Marjamäki
9bbad1b622
TestNullPointer: Moved posix.cfg tests
2015-01-30 06:43:40 +01:00
Daniel Marjamäki
0949baac9b
TestNullPointer: moved out std.cfg checking
2015-01-29 06:07:48 +01:00
Daniel Marjamäki
70a38b1da6
TestNullPointer: Moved some std.cfg tests to the cfg testing
2015-01-28 16:22:45 +01:00
PKEuS
3274a00b82
Moved some more tests to testgarbage.cpp
2015-01-21 10:04:46 +01:00
Daniel Marjamäki
fe8d04e840
CheckNullPointer: Fix FP when x is NULL and address is calculated with expression '&x->y.z[0]'
2015-01-05 14:54:24 +01:00
Daniel Marjamäki
ff11ba9847
Updated copyright year to 2015
2015-01-03 12:14:58 +01:00
PKEuS
c4fd8919a2
Fixed #6014 : Added plausibility check before issuing null pointer messages on function calls defined in library
2015-01-02 13:35:39 +01:00
orbitcowboy
def3491829
posix.cfg: Added support for readdir().
2014-12-10 17:44:21 +01:00