8629 Commits

Author SHA1 Message Date
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
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
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
Paul Fultz II
d62ed420d8 Add a check target to cmake (#1465) 2018-11-05 18:13:04 +01:00
Daniel Marjamäki
ca19894a04 ValueFlow: In evaluate handle correlated values 2018-11-05 18:07:35 +01:00
IOBYTE
2275f05f65 Fixed #8833 (false negative: No 'return' statement in non-void function causes undefined behavior.) (#1463) 2018-11-05 06:55:30 +01:00
Daniel Marjamäki
8a54420274 ValueFlow: Try to handle multiple argument values in <returnValue> evaluation 2018-11-04 20:52:12 +01:00
orbitcowboy
1d5e797e6d testother: Fixed typos in tests. Replaced 'voif' with 'void'. 2018-11-04 14:46:22 +01:00
Daniel Marjamäki
6878de2c5e ValueFlow: getExpressionRange, valueFlowRightShift 2018-11-03 23:25:46 +01:00
Daniel Marjamäki
f8b0584f6a replace 'constexpr' with 'const' 2018-11-03 19:22:51 +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
ef35b86b4a Multipass Valueflow 2018-11-03 15:53:24 +01:00
Daniel Marjamäki
6138294e3d Fixed #8818 (AST broken: restrict) 2018-11-03 11:05:38 +01:00
Daniel Marjamäki
9741239b2f Fixed #8824 (False positive: uninitialized variable (regression)) 2018-11-03 10:31:55 +01:00
Daniel Marjamäki
a4afcb5995 Revert "Fixed #8818 (AST broken: restrict)"
This reverts commit e7d61f399a995ad6e8540e3a94d6b2e06cc1fc09.
2018-11-02 21:07:37 +01:00
Daniel Marjamäki
0cc4555337 Revert "Tokenizer: Do not remove 'constexpr'"
This reverts commit 2f400b40ba00f7e4e7a8299e31ec178157cdbd79.
2018-11-02 21:07:24 +01:00
Daniel Marjamäki
2f400b40ba Tokenizer: Do not remove 'constexpr' 2018-11-02 20:32:12 +01:00
Daniel Marjamäki
e7d61f399a Fixed #8818 (AST broken: restrict) 2018-11-02 20:28:49 +01:00
Daniel Marjamäki
5de683ec49 Container size: Fix false positive 2018-11-02 20:10:40 +01:00
Daniel Marjamäki
e53be26f48 Try to fix Travis 2018-11-02 19:04:21 +01:00
Daniel Marjamäki
16cc20a232 ValueFlow: Better handling of container size values 2018-11-02 18:28:32 +01:00
Daniel Marjamäki
3798feecad TemplateSimplifier : Remove 'class|struct' in template arguments 2018-11-02 14:49:40 +01:00
rikardfalkeborn
869e4ba6ab Add check for return value of boolean function (#1451)
* Add check for return value of boolean function

The rule for converting an integer to a boolean is that 0 is mapped to
false and everything else is mapped to true. There is nothing wrong with
the following code (according to the standards):

    bool f()
    {
        return -1;
    }

and neither gcc nor clang will warn about it. However, it's a bit
confusing. This commit adds a check that warns when a value other than 0
or 1 is returned from a boolean function (similar to the existing check
that functions with boolean arguments are only passed 0 or 1). Since the
code is perfectly legal, set the severity to "Style".

* Use early continue and remove some braces

* Add testcase with multiple returns

* Avoid null pointer dereference in case of return without operand

* Skip lambdas

Add TODO-test cases that shows FPs when the return type of lambdas are
specified explicitly (this is a problem with findLambdaEndToken).

* Enable testcases
2018-11-01 11:08:16 +01:00
rikardfalkeborn
88008fedb1 findLambdaEndToken handle explicit type (#1458)
* findLambdaEndToken: Add tests

* Add handling of explicit return in findLambdaEndToken()

* Use AST in findLambdaEndToken()

* Fix ast when lambda is mutable
2018-10-31 12:36:08 +01:00
Paul Fultz II
fafd0742d4 Fix FPs with return conditions (#1455)
* Fix 8815: FP with identical inner conditions

* Fix issue 8801: FP when not returning a bool

* Fix FP

* Add missing semicolon

* Move returnVar
2018-10-31 09:47:48 +01:00
amai
3032ac4619 Fix compile error in test code 2018-10-28 21:36:28 +01:00
Daniel Marjamäki
c03d32b429 ValueFlow: Improve containerSize handling of string like classes 2018-10-28 19:14:00 +01:00
Daniel Marjamäki
8beb42cc90 astyle formatting
[ci skip]
2018-10-28 17:37:19 +01:00
Paul Fultz II
2b6cc33dc6 Fix issue 8757: Throw syntax error on invalid code (#1378)
* Fix issue 8757: Throw syntax error on invalid code

* Fix FP with lambda returns

* Remove double percent

* Check more keywords

* Skip preprocessor directives

* Check for valid PP directive

* Fix preprocessor check

* Dont check for preprocessor directives
2018-10-28 17:17:53 +01:00
Paul Fultz II
f5811c6818 Fix issue 8732: Syntax error when using enable_if (#1453)
* Fix issue 8732: Syntax error when using enable_if

* Fix FPs

* Use simpleMatch
2018-10-28 17:16:31 +01:00
Daniel Marjamäki
06ede9c239 ValueFlow: handle x+=y for containers 2018-10-27 18:38:04 +02:00
orbitcowboy
b998dcb5aa gnu.cfg: Added support for '__builtin_memset'. 2018-10-27 18:25:05 +02:00
IOBYTE
adbbadec7f Fixed #8798 (template simplifier: wrong simpifications for namespaces) (#1452) 2018-10-26 14:20:13 +02:00
Daniel Marjamäki
ab08801dc4 Remove header tests from testconstructors, because they were invalid (using preprocessor directive)
The checker does not care if it's a header or source file. So I guess these tests were added to test
some parsing problem. Nowadays, #line is removed by simplecpp::preprocess, but there is no proper
testing for it in simplecpp.. I will add some testing for #line asap.
2018-10-26 07:03:15 +02:00
Kamil Dudka
d206047b84 Fixed #8794 - Memory leak false positive triggered by !(x != NULL) (#1450) 2018-10-26 06:21:45 +02:00
Daniel Marjamäki
b8e8b12783 Fixed #8797 (exprDependsOnThis handle method call in non-inline method) 2018-10-24 20:17:00 +02:00
Daniel Marjamäki
2348dcde6c #8801: Quick fix for false positives 2018-10-24 19:57:50 +02:00
IOBYTE
0763fdbfad Copy template default argument values from forward declaration to declaration. (#1447)
It is possible to define default template parameter values in forward
declarations and not define any in the actual declaration.  Cppcheck
ignores forward declarations and only uses the default values in the
actual declaration so default values in forward declarations are copied
to the actual declaration when necessary.
2018-10-24 14:38:59 +02:00
Daniel Marjamäki
15160f1691 Fixed #8788 (AST Broken error from assigning lambda to variable) 2018-10-22 17:25:01 +02:00
Daniel Marjamäki
dc38681a56 Remove FIXME in AST validation. Ticket #8749 2018-10-22 11:37:24 +02:00
Daniel Marjamäki
c483bcb12b Fixed testrunner 2018-10-22 00:28:09 +02:00
Daniel Marjamäki
f9b132e831 Tokenizer::simplifyTypedef: Fix bug with arrays 2018-10-21 21:15:34 +02:00
Paul Fultz II
edde0eedaa Fix FP issue 8801: Condition 'a+b' is always true (#1444) 2018-10-21 08:04:00 +02:00
Paul Fultz II
2989c44f59 Enable checking duplicate expressions across associative operators (#1445)
* Enable checking duplicate expressions across associative operators

* Remove bitshift operators and check for streamRead
2018-10-21 07:09:20 +02:00
Daniel Marjamäki
14afc3fd3a Fixed #8796 (Tokenizer::simplifyCompoundAssignment: Wrong simplification of return) 2018-10-20 21:33:43 +02:00