Daniel Marjamäki
fe38e256cc
Fixed #7907 (FN: redundant assignment inside switchcase, overwritten by assignment outside of switch)
2018-12-17 16:10:47 +01:00
Daniel Marjamäki
858d9a18a7
Fixed #3857 (false negative: (style) Variable 'var' is assigned a value that is never used)
2018-12-17 15:16:47 +01:00
Paul Fultz II
9b973e652c
Issue 8830: New check: Function argument evaluates to constant value
...
Add a check for function arguments that can be constant:
```cpp
extern void bar(int);
void f(int x) {
bar((x & 0x01) >> 7); // function 'bar' is always called with a '0'-argument
}
```
2018-12-17 06:04:24 +01:00
Daniel Marjamäki
21eb1c5e22
FwdAnalysis: Fix false negatives for struct members
2018-12-16 18:32:34 +01:00
Daniel Marjamäki
a16f694254
Revert "Fix issue 8884: Regression: False positive: Variable 'f' is reassigned a value before the old one has been used ( #1513 )"
...
This reverts commit 6953dddfa6
.
2018-12-08 08:25:20 +01:00
Paul Fultz II
6953dddfa6
Fix issue 8884: Regression: False positive: Variable 'f' is reassigned a value before the old one has been used ( #1513 )
2018-12-08 07:33:51 +01:00
Daniel Marjamäki
ba564076db
Fixed #7907 (FN: redundant assignment inside switchcase, overwritten by assignment outside of switch)
2018-12-02 14:04:59 +01:00
Daniel Marjamäki
13c6489571
Redundant variable assignment: Fix FN for struct members
2018-11-27 18:22:22 +01:00
Daniel Marjamäki
affd03f1d6
Minor tweak for redundantVariableAssignment
2018-11-26 11:16:50 +01:00
Daniel Marjamäki
0160f80ffe
redundantVarAssignment: avoid FPs when loops are used
2018-11-25 10:32:30 +01:00
Daniel Marjamäki
22f736eae2
redundant variable assignments: avoid FPs for initializations
2018-11-25 08:49:09 +01:00
Daniel Marjamäki
2f66b31d43
redundantAssignmentInSwitch: fix false positive when there is goto
2018-11-24 21:39:01 +01:00
Daniel Marjamäki
866688c70a
Rewriting redundantAssignment checker
2018-11-24 10:03:54 +01:00
Daniel Marjamäki
a8cbbe0e16
Fixed #8816 (FP shadowLocal - variable shadows a template function?)
2018-11-19 07:00:15 +01:00
Daniel Marjamäki
58882b1f14
Fixed #8261 (False positive "Statements following return, break, continue, goto or throw will never be executed.")
2018-11-12 06:31:17 +01:00
Daniel Marjamäki
3f55707b30
Fixed #8064 (Taking the address of a moved variable is not accessing it)
2018-11-11 12:47:27 +01:00
Daniel Marjamäki
4cef2e94e7
Fixed #8368 (FP redundantAssignment - assignment has unknown side-effects)
2018-11-10 18:42:13 +01:00
orbitcowboy
1d5e797e6d
testother: Fixed typos in tests. Replaced 'voif' with 'void'.
2018-11-04 14:46:22 +01: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
29feaa5a51
Tokenizer: Avoid constant folding
2018-10-20 10:51:50 +02:00
Paul Fultz II
16c62281d0
Use followVar in checking duplicateBranch ( #1423 )
...
* Use isSameExpression for duplicate branches
* Add errorPath
* Add another test
2018-10-18 11:56:23 +02:00
Paul Fultz II
58d1de5814
Expand the duplicate variable assignment warnings when the inconclusive flag is used ( #1433 )
...
* Warn for more duplicate var expressions when inconclusive is set
* Fix issue with missing function name
2018-10-17 06:57:33 +02:00
Daniel Marjamäki
1245a036f7
Add check for shadow variables
2018-10-16 20:17:27 +02:00
rikardfalkeborn
75caf8e4de
Fix #8230 : FP unknown evaluation order on comma expression in while clause ( #1415 )
...
The while part of a do-while loop looks almost like a function call, so
extend the check for function calls to ignore while-statements.
Note that there was only an FP when checking c-code, since the check is
disabled for c++-code. Therefore, make sure the test cases are run on a
c-file.
2018-10-09 14:44:01 +02:00
Daniel Marjamäki
aa58f41e6d
Fixed #7152 (False positive for redundantAssignment after calling a lambda function)
2018-10-08 21:07:21 +02:00
Paul Fultz II
e170a45230
Enable followVar for opposite expressions ( #1404 )
...
Enable followVar for opposite expressions
2018-10-04 21:17:47 +02:00
Paul Fultz II
4598995564
Enable followVar for duplicate ternary expressions ( #1406 )
2018-10-01 14:31:06 +02:00
Paul Fultz II
f65cf220ba
Fix false positives in unknownEvaluationOrder when using followVar ( #1391 )
...
Fix false positives in unknownEvaluationOrder when using followVar
2018-09-28 08:38:24 +02:00
Paul Fultz II
5bebeec224
Fix issue 8775: Dont follow aliased variables ( #1390 )
2018-09-24 06:37:47 +02:00
Daniel Marjamäki
afe09f4d7a
Temporarily comment out the followVariable() handling
2018-09-23 16:03:18 +02:00
Paul Fultz II
90a29d986b
Fix issue 8730: Dont follow variables with unknown symbols ( #1374 )
2018-09-12 17:30:18 +02:00
Paul Fultz II
f4f3f81e8f
Fix issue 8741: Require pure when following variables in isSameExpression ( #1373 )
2018-09-09 07:08:32 +02:00
Paul Fultz II
5a2362b2a0
Fix issue 8738: Dont warn about multiconditions when value is known ( #1369 )
2018-09-07 15:02:34 +02:00
Paul Fultz II
2da958efb5
Fix issue 8722: Avoid duplicate messages due for followVar ( #1367 )
2018-09-06 06:55:36 +02:00
Paul Fultz II
b46e25c18e
Fix issue 8730: False positive: Opposite expression on both sides of && ( #1366 )
2018-09-05 18:07:01 +02:00
Paul Fultz II
08f301a0de
Reenable followVar ( #1363 )
...
Reenable followVar
2018-09-05 05:53:33 +02:00
Paul Fultz II
93be440f92
Fix issue 8709: crash with switch statement with followVar ( #1362 )
...
* Fix crash with switch statement
* Update comment
2018-09-03 19:54:14 +02:00
Paul Fultz II
0e5fabf4dc
Dont follow volatile variables ( #1365 )
2018-09-03 19:51:48 +02:00
Paul Fultz II
8353f94b93
Fix crashes in followVarExpression ( #1358 )
...
* Fix crashes in followVarExpression
* Add a regression test for issue 8717
* Skip reference declarations
2018-09-02 08:28:53 +02:00
Daniel Marjamäki
a331206b44
Temporarily disable followVariableExpressions(), there are problems that should be fixed.
2018-09-01 08:32:06 +02:00
Daniel Marjamäki
7591616f43
Fixed #8710 (Update message duplicateExpression when operand is integer literal)
2018-08-30 18:28:34 +02:00
Paul Fultz II
a5f4c5d0eb
Improve message for same expressions ( #1349 )
...
* Improve message for same expressions
* Update message
2018-08-25 14:25:31 +02:00
Paul Fultz II
c5154286da
Fix issue 8687: false positive with same expression ( #1336 )
2018-08-13 12:55:41 +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
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
0e491b41a8
Clarify warning message for 'Same expression on both sides of operator'
2018-08-05 10:48:02 +02:00
Daniel Marjamäki
f9a5a114bb
astyle formatting
...
[ci skip]
2018-07-25 07:44:06 +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
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