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
..
2018-10-13 18:20:31 +02:00
2018-10-13 18:20:31 +02:00
2018-06-16 16:31:07 +02:00
2018-07-14 10:02:32 +02:00
2018-10-21 20:28:46 +02:00
2018-05-15 16:37:40 +02:00
2018-10-18 20:08:32 +02:00
2018-10-18 20:08:32 +02:00
2018-07-13 16:57:17 +02:00
2018-07-15 23:05:48 +02:00
2018-06-17 17:04:34 +02:00
2018-10-13 18:20:31 +02:00
2018-01-14 15:37:52 +01:00
2018-10-13 18:20:31 +02:00
2018-10-13 18:20:31 +02:00
2018-03-31 20:59:09 +02:00
2018-10-20 15:28:34 +02:00
2018-06-17 09:06:16 +02:00
2018-10-13 18:20:31 +02:00
2018-01-14 15:37:52 +01:00
2018-06-20 10:39:21 +02:00
2018-10-28 17:37:19 +01:00
2018-06-17 17:20:16 +02:00
2018-06-17 17:20:16 +02:00
2018-06-16 16:28:03 +02:00
2018-10-13 18:20:31 +02:00
2018-10-13 18:55:19 +02:00