Commit Graph

71 Commits

Author SHA1 Message Date
Daniel Marjamäki 330e634937 Revert "TestTrac: Add separate file for black box / integration tests in testrunner"
This reverts commit e895fa4c3f.
2020-05-19 07:53:54 +02:00
Daniel Marjamäki e895fa4c3f TestTrac: Add separate file for black box / integration tests in testrunner 2020-05-18 20:22:00 +02:00
Daniel Marjamäki c2f8fb5603 Fixed #9405 (false positive: (style, inconclusive) Boolean expression 'dqOpen' is used in bitwise operation. Did you mean '&&') 2019-12-20 19:38:30 +01:00
Dmitry-Me 571de5844f Improve test coverage for functions returning bool values 2019-12-04 18:12:10 +03:00
Tyson Nottingham 0950a97df2 Fix false negatives in checkBitwiseOnBoolean (#2220)
* Fix false negatives in checkBitwiseOnBoolean

Use AST-based tests in favor of token-based tests for greater coverage.

* Travis: add suppressions for bitwiseOnBool
2019-10-06 09:57:31 +02:00
Tyson Nottingham ca5f2562fc Fix false negatives in checkIncrementBoolean (#2210)
Detect incrementing boolean expressions involving pointer dereferences,
array element accesses, etc.
2019-09-25 13:07:39 +02:00
Tyson Nottingham d6a70d27c7 Fix false negatives in checkAssignBoolToFloat and minor related improvements (#2198)
* Fix false negatives in checkAssignBoolToFloat

Detect assignments to expressions involving pointer dereferences, array
element accesses, etc.

* Pass assignment token to assignBoolToFloatError

Pass assignment token rather than boolean token to make error reporting
consistent between checkAssignBoolToFloat and checkAssignBoolToPointer,
as well as with other assignment checks in the code base.

* Make checkAssignBoolToPointer check consistent with checkAssignBoolToFloat
2019-09-21 08:24:54 +02:00
Daniel Marjamäki 7d63bdee6f astyle formatting
[ci skip]
2019-09-02 06:59:07 +02:00
Ken-Patrick d1c6cb9aa5 Fix issue 9304: boolean type of ternary (#2131)
* Add test cases for 9304

* Fix 9304
2019-09-01 09:51:53 +02:00
Rikard Falkeborn 0d69a86bf8 Remove debug printout (#1933) 2019-06-28 22:08:32 +02:00
Ken-Patrick 927d139488 Fix FP #9165 (#1928)
Properly check the type of the expressions, instead of using the type
of the tokens
2019-06-27 07:48:44 +02:00
Daniel Marjamäki 6d982d4320 Testing: comment/naming 2019-06-15 13:01:34 +02:00
Rikard Falkeborn b970606c93 Add regression test for #7798 (#1847)
Trac ticket #7798 was fixed in 3f1e2b4270
(More conservative fallback for function overload matching). Add a test
to avoid regressions.
2019-06-15 11:34:06 +02:00
Rikard Falkeborn dc0e8c214e Fix #9128 (FP in return non bool with class declared in function) (#1830)
Also break up the tests to smaller tests.
2019-05-14 08:56:28 +02:00
Rikard Falkeborn 4edc248dae Fix 8840: Don't warn when returning a bitmask as bool (#1818)
A common pattern is to have a function like similar to this:

	bool isFlagSet(uint32_t f) {
		return f & 0x4;
	}

Warning that the function returns a non-boolean in this case is too
noisy, it would be better suited for a Misra check, so remove the
warnings in the most obvious cases.
2019-05-02 07:00:27 +02:00
Daniel Marjamäki f40a80c349 Use 'normal' checking instead of 'simplified' 2019-03-16 07:19:48 +01:00
Daniel Marjamäki bd7790fd8c Update copyright year 2019-02-09 07:24:06 +01:00
Daniel Marjamäki 8dd641b8be Use OVERRIDE in test 2019-01-12 15:45:25 +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
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
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
Alexander Mai 5c2960713f Correct false positives compareBoolExpressionWithInt (0U) 2016-02-19 21:38:54 +01:00
PKEuS 0847d3d19a ValueType related bugfixes:
- ptrdiff_t is SIGNED
 - Detect pointers to unknown types as pointers
 - Do not identify bool* as boolean (#7381)
2016-02-05 20:29:17 +01:00
PKEuS 6215a48dc9 Support member variables in CheckBool::checkAssignBoolToFloat() 2016-02-05 20:28:42 +01:00
PKEuS e71e9bd538 CheckBool: Rely on ValueType, removed a redundant check 2016-02-05 15:48:51 +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
Simon Martin 311db970c5 Ticket #6665 (dupe of #6588): Added test case. 2015-06-05 23:44:03 +02:00
Simon Martin 519bd7007a Ticket #6588: Properly detect whether the condition in a ternary operator is constant on C input. 2015-05-31 22:40:13 +02:00
Simon Martin 764df4dd56 Ticket #6588: Added test cases since the initial issue is fixed by some past commit. 2015-05-30 22:57:54 +02:00
PKEuS 6e0302fd56 Refactorized CheckBool::checkComparisonOfBoolWithInt(), CheckBool::checkComparisonOfBoolExpressionWithInt() and CheckBool::pointerArithBool():
- Support more patterns in CheckBool::pointerArithBool()
- Use AST and SymbolDatabase
- Removed redundant skipping over template arguments
2015-03-12 20:07:48 +01:00
PKEuS bc5132e0ac Refactorization: Moved declaration of errout, ... to testsuite.h, uniformized style 2015-03-11 22:54:43 +01:00
Daniel Marjamäki ff11ba9847 Updated copyright year to 2015 2015-01-03 12:14:58 +01:00
Daniel Marjamäki 051d42ae6b astyle formatting 2014-11-20 14:20:09 +01:00
orbitcowboy f5d804f71a running astyle 2014-11-20 10:13:03 +01:00
PKEuS d42275c5f1 Fixed TODO in checkAssignBoolToFloat 2014-05-24 20:06:45 +02:00
Alexander Mai e6a394d514 CheckBool::checkAssignBoolToFloat() - don't crash on unknown variables 2014-05-24 19:15:43 +02:00
Alexander Mai 2c8087e34f #4375 New check: add style warning about 'double d=false;' Add a new check to CheckBool. Also implement Variable::isFloatingType() 2014-05-24 18:35:49 +02:00
Daniel Marjamäki 225fb96554 Fixed #5627 (False positive assignBoolToPointer) 2014-03-31 15:55:54 +02:00
Daniel Marjamäki 581886636d CheckBool::checkComparisonOfBoolExpressionWithInt: Rewrite the check using AST instead of token list 2014-03-27 16:10:43 +01:00
Daniel Marjamäki 2248cdfea0 CheckBool::checkAssignBoolToPointer: Refactor to use AST. 2014-03-27 05:39:48 +01:00
Daniel Marjamäki fd3a8a2a18 Update copyright 2014-02-15 07:45:39 +01:00
Matthias Krüger 6feb0faf4c testbool: same for checkComparisonOfBoolWithBool 2014-01-10 21:08:11 +01:00
PKEuS 4f0121ee2f Splitted simplification out of tokenize() 2013-12-30 17:45:28 +01:00
Daniel Marjamäki aa65799c19 pointerArithBool: Updated error message 2013-12-25 19:56:00 +01:00
Daniel Marjamäki a3dd65caee Fixed #5126 (new check: missing pointer dereference or pointer overflow 'if (p+1)') 2013-12-23 18:39:05 +01:00
Daniel Marjamäki 5c072993e3 CheckBool: Fixed false negative when assigning bool to pointer '; s.p = true; ' 2013-10-29 16:16:52 +01:00