Commit Graph

9825 Commits

Author SHA1 Message Date
Daniel Marjamäki f37434cd1d valueFlowContainerReverse: Fix FPs when there is assignment 2018-08-10 12:26:53 +02:00
Daniel Marjamäki 907f81d059 ValueFlow: Improved analysis of container size 2018-08-10 11:53:56 +02:00
Daniel Marjamäki 81f54f7094 Fixed #8681 (ValueFlow: Container size) 2018-08-10 11:29:16 +02:00
Daniel Marjamäki 8032f64c15 Refactoring; Use range for loops 2018-08-10 10:04:10 +02:00
Daniel Marjamäki b707f6e476 Refactoring; use range for loops 2018-08-10 06:47:18 +02:00
Daniel Marjamäki 223a116f24 The checksum in analyzer info files will now depend on the suppressions 2018-08-09 09:27:26 +02:00
Daniel Marjamäki f2e7071922 Fix FP, conversion of char literal '\0' to boolean is not true 2018-08-08 19:04:10 +02:00
Daniel Marjamäki 1f1c44a04f Fixed #8677 (False positive: unused method) 2018-08-08 11:31:35 +02:00
Paul Fultz II 80290a15e0 Fix FP with duplicate assign (#1330) 2018-08-08 08:31:31 +02:00
Daniel Marjamäki c3a44ce56b astyle formatting
[ci skip]
2018-08-07 18:06:51 +02:00
Daniel Marjamäki 78df7f98dd Fixed #8674 (False positive: Method that returns const should not be const) 2018-08-07 18:06:14 +02:00
Paul Fultz II f603b529df Fix issue 8413: Condition is always false 'i=expr; if (i != expr) {}' (#1295)
* Follow variables when comparing same expression

* Remove assert include

* Dont follow function arguments

* Improve the checking to check more cases

* Add more tests

* Check if the variable is used inside a loop

* Follow both variables

* Only skip loops when variable is modified in scope

* Fix FP when followed variable is modified

* Dont follow arrays

* Skip pointer indirection

* Make recursive

* Improve checking more variables

* Fix test with sizeof

* Skip following operators

* Fix test when using sizeof

* Dont check every step

* Use early returns

* Update test to use a loop instead of conditional

* Add static

* Check variables are global

* Check local variables in another scope

* Fix issue with const pointers

* Distinguish between pointer indirection and multiply

* Use simple match

* Prevent crash with uniform initialization

* Use unary op and ast to detect pointer indirection

* Expand error message when expression do not match exactly

* Add errorpath to issameexpression

* Revert "Clarify warning message for 'Same expression on both sides of operator'"

This reverts commit 0e491b41a8.

* Check if the tokens are the same

* Report the operator and not the expressions
2018-08-07 09:32:16 +02:00
Daniel Marjamäki 1b933f4dd1 astyle formatting
[ci skip]
2018-08-05 22:40:21 +02:00
Paul Fultz II b839ad60dd Fix issue 6856: add checks in isOppositeCond when using == and < or > (#1298)
* Fix issue 6856: add checks in isOppositeCond when using == and < or >

* Move tests to testcondition

* Fix some more tests

* Fix test messages

* Remove the float check
2018-08-05 22:39:40 +02:00
Daniel Marjamäki ddbe4b89b5 Renamed --debug to --debug-simplified 2018-08-05 11:19:20 +02:00
Daniel Marjamäki bcdd58de0b astyle formatting
[ci skip]
2018-08-05 10:48:28 +02:00
Daniel Marjamäki 0e491b41a8 Clarify warning message for 'Same expression on both sides of operator' 2018-08-05 10:48:02 +02:00
Paul Fultz II ed197f235a Fix issue 4693: Diagnostic when using the same iterators to an algorithm (#1326)
* Fix issue 4693: Diagnostic when using the same iterators to an algorithm

* Update classinfo
2018-08-05 09:10:54 +02:00
rikardfalkeborn 710d7ce015 Add checks of log2 and log1p range (#1324)
* Add tests for log10{,f,l} valid arguments

* Add log2{,f,l} to checkfunctions

* Add log1p{,f,l} to checkfunctions

* checkfunctions: Simplify check for log function limit out of range

The conditions for negative and non-negative int and float were
identical so the call to isNegative can be removed and the if-statements
be simplified.
2018-08-03 12:14:39 +02:00
Daniel Marjamäki 0a66f5c4f9 astyle formatting
[ci skip]
2018-07-26 22:24:00 +02:00
Daniel Marjamäki e2a4b1706c Refactoring CheckStl::mismatchingContainers; Use AST 2018-07-26 22:23:37 +02:00
Daniel Marjamäki 86721f5b91 small refactorings 2018-07-26 22:08:05 +02:00
Daniel Marjamäki d471c27502 astyle formatting
[ci skip]
2018-07-26 22:03:49 +02:00
Paul Fultz II 0d35a96594 Improve checking of mismatch iterators (#1293) 2018-07-26 22:00:48 +02:00
Daniel Marjamäki 54e2726bf3 Fixed #8636 (Misleading verbose message if virtual method called from destructor) 2018-07-26 09:16:17 +02:00
Daniel Marjamäki c666f74755 astyle formatting
[ci skip]
2018-07-25 23:02:16 +02:00
Paul Fultz II f093692551 ValueFlow: Set values in else branch even when the first branch modifies the value (#1309)
* Set values in else branch even when the first branch modifies the value

* Move tests

* Add check for goto

* Remvoe todo

* Also check scope is noreturn

* Use isEscapeScope when variables are changed
2018-07-25 22:59:54 +02:00
firewave 01ceb9bae7 fixed issue 8661: Misleading error message when compilation database is not recognized 2018-07-25 16:26:25 +02:00
Daniel Marjamäki 58c91c4645 Revert "Refactoring endsWith utility function"
This reverts commit d300d1f61b.
2018-07-25 16:14:43 +02:00
Daniel Marjamäki f9a5a114bb astyle formatting
[ci skip]
2018-07-25 07:44:06 +02:00
Daniel Marjamäki d300d1f61b Refactoring endsWith utility function 2018-07-25 07:43:50 +02:00
Paul Fultz II 9895ea5ff2 Fix issue 470: Condition is always true or false on logical operators (#1294)
* Fix issue 470: Condition is always true or false on logical operators

* Dont warn on literals

* Compute logical operators using valueflow

* Fix FP when using literals

* Always warn on subconditions that are always true

* Use percent matches first

* Add test for logical operators

* Check if parent is null
2018-07-23 08:51:59 +02:00
lordylike 12e58c8521 fix ticket 8570: passedByValue with member initializer list and std::move (#1316)
* fix ticket 8570

allow member initializer list variables that are moved to be non-const

* review feedback

* replace tabs with spaces in test code
2018-07-22 15:01:18 +02:00
Daniel Marjamäki 77b653bf94 Clarify warnings when char literals are converted to bool in conditions 2018-07-21 18:40:06 +02:00
Daniel Marjamäki 417670d947 Clarify code with continue 2018-07-20 21:44:23 +02:00
rikardfalkeborn 30a8d953e3 Move sqrt{,f,l} argument checks to cfg file (#1313) 2018-07-20 20:56:39 +02:00
Daniel Marjamäki 7c4820e047 Rename Library::isargvalid() 2018-07-15 23:05:48 +02:00
rikardfalkeborn 491ee577c6 Support floats in valid config (#1297)
* Add tests for invalid ranges

* Refactor loadLibErrors

This reduces the amount of code slightly and will simplify adding
more tests.

* Handle empty valid field

Before this change, the sequence <valid></valid> in a config file would
result in a segmentation fault. Now an empty field results in the error
message:

cppcheck: Failed to load library configuration file 'mycfg.cfg'. Bad attribute value '""'

* Add support for valid for floating point arguments

Previously, it was not possible to add valid ranges to floating point
arguments since it only handled integers. This made ranges not work well
for floating point arguments since arguments were cast to integers
before the ranges were handled.

Fix this by using doubles instead of integers if the argument is a float.
Add some tests for this and make sure errors are printed with enough
precision (somewhat arbitrarily chosen).

Note that it is still only possible to add integer ranges (i.e. -1:1).

* Add support for floats in configuration valid range

Now that it is possible to handle decimal arguments, there is no reason
to not allow non-integer ranges. Take care to not allow broken
configurations.

* Move check to within if-clause

* Move asin{,f,l} and acos{,f,l} input checks to config file
2018-07-15 22:47:56 +02:00
Daniel Marjamäki 39857220ce Refactoring: Use range for loops 2018-07-15 15:08:35 +02:00
Daniel Marjamäki cc5f00c252 Refactoring; use range for loops 2018-07-15 15:03:08 +02:00
Daniel Marjamäki 518dd8bfa3 Refactoring: Use range for loops 2018-07-15 14:51:33 +02:00
Daniel Marjamäki 1c4fb47582 astyle formatting
[ci skip]
2018-07-15 14:45:33 +02:00
Daniel Marjamäki faea8e1c02 Refactoring: Use range for loops 2018-07-15 14:45:15 +02:00
Paul Fultz II 5d1fdf7958 Fix issue 7904: Handle double nots in isSameExpression (#1305)
* Fix issue 7904: Handle double nots in isSameExpression

* Skip checking double nots in assignments

* Use ast to check for double not
2018-07-15 11:30:02 +02:00
Daniel Marjamäki 60485df762 Refactoring; Use range for loops 2018-07-14 22:49:31 +02:00
Daniel Marjamäki 991300ac54 Clarify code with Token::isUnaryOp() 2018-07-14 22:36:08 +02:00
Daniel Marjamäki 1e824330c0 Refactoring: Use range for loops 2018-07-14 22:26:22 +02:00
Daniel Marjamäki 0f3cc56c59 Refactoring: Use range for loops 2018-07-14 13:19:41 +02:00
Daniel Marjamäki d603a811bb Clarify code with Token::hasKnownValue() 2018-07-14 13:09:53 +02:00
Daniel Marjamäki d00e522856 Clarify the code with Token::isUnaryOp and Token::isBinaryOp 2018-07-14 13:01:24 +02:00