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
Daniel Marjamäki
03faa25d12
Conditions: Better handling of function calls
2018-07-08 15:58:04 +02:00
Daniel Marjamäki
24dd4c9c26
Restore code in checkVariableScope. Fixes false negative
2018-07-01 22:31:45 +02:00
Daniel Marjamäki
655a8b21b6
Fix false positive 'passedByValue' when address of argument is used
2018-06-23 23:25:06 +02:00
Daniel Marjamäki
d0614b9b36
varScope: Fix false negatives for references
2018-06-22 22:51:03 +02:00
Daniel Marjamäki
593f7eee38
Fixed #8624 (Crash below CheckOther::checkDuplicateExpression)
2018-06-14 22:39:26 +02:00
Paul Fultz II
daacf27c2e
Fix false positive from issue 8612 ( #1285 )
2018-06-10 00:05:23 +02:00
Paul Fultz II
8d53bcfd63
Fix FP when using non-const members and also check return type of function ( #1283 )
2018-06-09 08:05:19 +02:00
Daniel Marjamäki
84f0a18053
passedByReference: avoid false positives for std::pair
2018-06-08 10:19:02 +02:00
Daniel Marjamäki
44c78d1770
passedByReference: avoid false positives for std::function
2018-06-08 08:40:14 +02:00
Daniel Marjamäki
de09c117bf
Fixed #8618 (False positive: shared_ptr is passed by reference by intention)
2018-06-07 22:39:21 +02:00
IOBYTE
ce50df8047
Fix override warnings. ( #1234 )
2018-05-15 16:37:40 +02:00
Paul Fultz II
7ef714b0c6
Fix FP with duplicate assignments by checking if the expression is unique ( #1223 )
...
* Fix FP with duplicate assignments by checking if the expression is unique
* Use array of pointers
* Reorder scope condition
2018-05-13 20:20:55 +02:00
Paul Fultz II
f5dbfce8ff
Fix false positive with oppositeExpression when using binary op ( #1211 )
...
* Fix false positive with oppositeExpression when using binary op
* Simplify conditional
2018-05-08 20:43:57 +02:00
Paul Fultz II
cac68c6b81
Fix FP when using - as a binary operator ( #1201 )
2018-05-04 07:58:30 +02:00
Paul Fultz II
f191a3e753
Improve checking of opposite expressions ( #1199 )
...
* Improve checking of opposite expressions
* Fix some formatting
2018-05-02 06:32:33 +02:00
Daniel Marjamäki
e1db4c0e2c
astyle formatting
...
[ci skip]
2018-04-21 13:28:31 +02:00
Paul Fultz II
d939c6015a
Report opposite expressions ( #1182 )
...
* Report opposite expressions
* Skip assignment operator
2018-04-21 11:28:21 +02:00
Daniel Marjamäki
d5fb529d4f
Fixed #8492 (Improve message: parameter should be passed by reference)
2018-04-20 17:33:42 +02:00
PKEuS
bbfcccf078
Refactorization: Replace several push_back-sequences by initializer lists
2018-04-09 09:41:24 +02:00
Paul Fultz II
95fc84a26b
Find duplicate expressions assigned to the same variable ( #1129 )
...
* Check for duplicate assignments
* Improve checking of expression
* Add more tests
* Use simple match
* Improve robustness of check
* check for null
* Reduce side effects by checking for side effects
* Improve verbose message
* Reword the error message
2018-04-08 14:43:19 +02:00
amai
b133d50ebe
#6426 Regression now has platform dependent results
2018-04-04 16:07:07 +02:00
amai
7581231d9d
#6426 FP duplicateExpressionTernary - (expr) ? ~0u : ~0ul. Add regression test
2018-04-04 14:31:48 +02:00
Daniel Marjamäki
7efc4dd26e
astyle formatting
...
[ci skip]
2018-04-04 10:04:40 +02:00
Paul Fultz II
bce5fe5cef
Improve duplicate expressions in the ternary op by checking for equal values as well ( #1134 )
...
* Improve duplicate expressions in the ternary op by checking for equal values as well
* Use value instead of expression
2018-04-03 21:43:55 +02:00
Daniel Marjamäki
c4caee6b18
Updated copyright year
2018-01-14 15:37:52 +01:00
Daniel Marjamäki
bbeff99cc3
Fixed #6930 (Token: need function that says if the token comes from instantiated template argument)
2018-01-11 09:41:22 +01:00
Matthias Krüger
eb58df236e
CheckOther::accessMovedError() / accessMoved, accessForwarded warnings: put variable name into single quotes.
2018-01-07 10:57:19 +01:00
Andreas Pokorny
b802b98136
Do not warn when unique pointers are passed by value
...
A unique pointer should only be passed by value or by const reference.
Passing by value means transferring ownership it makes no sense to have a pass by value Warning for unique_ptr
Signed-off-by: Andreas Pokorny <andreas.pokorny@siemens.com>
2017-07-25 11:17:56 +02:00
Daniel Marjamäki
0967700f4b
Refactoring tests
2017-06-06 08:59:18 +02:00
Stas Cymbalov
ff38cc5c13
Set struct size cutoff in passedByValue check to 2*sizeof_pointer
...
Struct arguments are either pushed to the stack or passed in the
registers. Since both methods operate on machine words it is logical to
tie the maximum size of a struct argument that doesn't trigger
passedByValue diagnostic to the size of the machine word.
Also guessed size of STL classes is set to 3*sizeof_pointer, this better
represents reality and ensures that structs containing them will still
trigger passedByValue.
2017-06-06 08:48:11 +02:00
Ayaz Salikhov
28aa939d69
iwyu - include what you use
2017-05-27 04:33:47 +02:00
uburuntu
3817384223
FIX: test: parameter 'settings' is always rewritten
2017-05-27 04:17:18 +02:00
Daniel Marjamäki
040d2f0012
Use simplecpp lexer in test cases
2017-05-18 21:52:31 +02:00
Daniel Marjamäki
7fd04cd8d0
Updated Token::expressionString(), write '->' instead of '.'
2017-04-30 14:22:18 +02:00
Daniel Marjamäki
101dc28afa
Refactoring: Moved checkMemset.. from CheckOther to CheckFunctions
2017-04-23 07:53:41 +02:00
Daniel Marjamäki
50da7d4919
Tokenizer: Write syntax error if there is C++ code in C file.
2017-04-06 08:50:35 +02:00
Robert Reif
3dba1b1739
Tests for git pull request #882 .
2017-03-25 15:46:25 -04:00
PKEuS
816106560a
More conservative check for non-commutative operator+ in isSameExpression() ( #7938 )
2017-03-15 19:17:40 +01:00
PKEuS
00904ba32a
Fixed false negatives in CheckOther::checkPassByReference() when assignment operator is used.
2017-03-07 21:49:28 +01:00
Daniel Marjamäki
59c1c76a97
Fixed #7466 (Reference variable does not count side-effects (FP variableScope))
2017-03-03 19:07:00 +01:00
Matthias Krüger
f80e888b7e
run astyle
...
[ci-skip]
2017-01-31 16:22:31 +01:00
umanamente
a012e5b5fb
( Fixed #7846 ) Syntax error when using C++11 braced-initializer in function last argument
...
Add an optional extended description…
2017-01-23 12:50:36 +01:00
PKEuS
3022d74801
Do not suggest pass by reference for std::initializer_list
2017-01-19 11:14:55 +01:00
Robert Reif
139071d88b
Fixed #7875 (New check: function declaration and definition argument names don't match)
2017-01-05 08:52:11 +01:00
Daniel Marjamäki
770abcf453
Fixed #5398 (False positive: Scope of variable can be reduced does not account for other variables not reduceable)
2016-12-26 14:14:40 +01:00
Daniel Marjamäki
df6ae9f3b4
Fixed #7847 (Can't detect shift negative values when some op is executed)
2016-12-22 09:40:19 +01:00
Daniel Marjamäki
606bb78297
ValueFlow: Better handling of casts
2016-12-20 19:32:21 +01:00
Frank Zingsheim
9a871d33f7
Improve Fix #6180 ("reset" and "clear" clears the move status)
2016-12-17 16:39:30 +01:00
Frank Zingsheim
f4ab45f13b
Improve Fix #6180 (Do not warn about move if it is part of a reassignment of the variable)
2016-12-17 16:39:30 +01:00
Daniel Marjamäki
8cba02dc66
Readd test case I removed in b098d5fbd6
2016-12-11 21:24:12 +01:00