Commit Graph

426 Commits

Author SHA1 Message Date
chrchr-github 15f8c71ec3
Fix #9946 FP: unassignedVariable when operator() is called subsequently (#4303) 2022-07-24 17:52:14 +02:00
chrchr-github 1aceded300
Fix #10977 FP noExplicitConstructor with variadic template (#4301) 2022-07-24 10:18:19 +02:00
chrchr-github 457a0cff87
Fix #11016 FP unusedStructMember when used through iterator (regression) (#4289)
* Format

* Fix #11016 FP unusedStructMember when used through iterator (regression)

* Format

* Fix test

* Format

* Nullptr check
2022-07-19 20:42:54 +02:00
chrchr-github 6dc606fd6a
Add tests for #8446, #10750, #10894 (#4287) 2022-07-18 18:03:08 +02:00
chrchr-github b08aabefee
Fix #9877 FP unreadVariable (incomplete code; missing macro definition) (#4278) 2022-07-17 19:40:39 +02:00
chrchr-github 4894cdab8f
Fix #11108 FP unreadVariable with unique_ptr and unknown c'tor (#4284)
* Fix #11108 FP unreadVariable with unique_ptr and unknown c'tor

* Fix test
2022-07-16 23:46:55 +02:00
chrchr-github a658baf962
Fix #11143 FP: unreadVariable (remove simplifyMathExpressions()) (#4227)
* Fix #11143 FP: unreadVariable (remove simplifyMathExpressions())

* Remove unused function, tests
2022-06-21 15:42:23 +02:00
chrchr-github de9b65c737
Add tests for #9194, #10415, #4759, #9876, #10006 (#4213)
* Add test for #10152

* Add test for #9773

* Fix test

* Add test for #7529

* Add test for #6371

* Add test for #6475

* Format

* Format

* Fix test

* Remove duplicate test

* Add valueflow test

* Rebuild

* Add tests for #9194, #10415, #4759, #9876, #10006
2022-06-14 13:05:07 +02:00
chrchr-github 6d22d6a8ae
Fix FP unusedVar with side effects in destructor (#4212) 2022-06-14 09:55:22 +02:00
chrchr-github 69834d537b
Fix #9997 False negative: variable is not used (#4104) 2022-06-07 21:20:33 +02:00
chrchr-github f962436826
Fix #11082 FN badBitmaskCheck for binary or with 0 (#4170)
* Fix #11082 FN badBitmaskCheck for binary or with 0

* Add test for #10703
2022-06-04 17:25:10 +02:00
chrchr-github d5d6da0dd4
Fix #11094 FP unreadVariable with unique_ptr and unknown type (#4140) 2022-05-27 17:17:50 +02:00
chrchr-github 2ceaf308de
Fix #11084: ValueType for pointer typedef, don't warn for typedef'd pointers, improve error message (#4123)
* Fix ValueType for pointer typedef

* Add test

* Don't warn for typedef'd pointers, improve error message

* Fix tests

* Add TODO

* Fix test

* Set isSimplifiedTypedef() for more tokens, add test

* Add test
2022-05-24 10:09:48 +02:00
chrchr-github 112b1573c5
Fix #11078 FN constructing string from nullptr / #11079 FN unread variables (#4112)
* Fix #11078 FN constructing string from nullptr / #11079 FN unread variables

* Format
2022-05-18 13:52:44 +02:00
orbitcowboy 9f7c34272d Added a regression test for ticket #10000 - No UnreadVariable for simple class 2022-05-03 06:58:03 +02:00
chrchr-github 0636018df3
Fix #10368 FP: unassignedVariable with structured binding (#3990) 2022-04-09 14:50:30 +02:00
chrchr-github 7b97230dd2
Fix #10505 FP unreadVariable for lock_guard variable (#3938) 2022-03-28 21:45:49 +02:00
chrchr-github 190506db40
Fix #10737 Regression: unusedStructMember (#3894)
* Fix #10737 Regression: unusedStructMember

* Add test for #9161

* simpleMatch
2022-03-13 06:27:17 +01:00
chrchr-github c3506b5186
Fix #10691 regressions with static variables and multiple assignments (#3895)
* Fix regressions with static variables and multiple assignments

* Fix test

* Fix test cases
2022-03-13 06:26:21 +01:00
chrchr-github 4c85ac0d7b
Fix #10852 FP unused struct member (inner struct in C code) (#3890)
* Fix #10852 FP unused struct member (inner struct in C code)

* Redundant findType() call, add test
2022-03-12 06:16:29 +01:00
chrchr-github 2616046461
Partial fix for #10848 FP: unusedStructMember (#3880) 2022-03-09 20:25:58 +01:00
chrchr-github 557263acde
Partial fix for #10848 FP: unusedStructMember (II) (#3881)
* Preliminary

* Fix member search, add tests
2022-03-09 18:22:30 +01:00
orbitcowboy 1d2beb0431 Added a regression test for ticket 6928 - Improve check: unused variables, goto 2022-03-07 10:12:57 +01:00
chrchr-github 0b0a8cad39
Fix #10846 FP unreadVariable within a macro (regression) (#3874)
* Fix #10846 FP unreadVariable within a macro (regression)

* Format

* Format
2022-03-05 08:14:57 +01:00
chrchr-github 9c50136571
Fix #10824 FN unreadVariable for pointer assignment when destructor exists (regression) (#3864)
* Fix #10824 FN unreadVariable for pointer assignment when destructor exists (regression)

* unused variable

* Issue warning for missing cfg

* Format
2022-03-02 11:11:44 +01:00
chrchr-github 441b437cea
Fix #10826 FN: unusedStructMember (#3858) 2022-02-26 18:53:00 +01:00
chrchr-github 172aafdeb8
Fix #7908 FN: redundant assignment in loop (#3650) 2022-02-22 09:51:44 +01:00
chrchr-github 0a99e3b6fc
Partial fix for #9407 FN redundant assignment/unreadVariable (#3651) 2022-02-12 15:32:08 +01:00
Oliver Stöneberg f32583e097
removed OVERRIDE and FINAL defines and use the keywords directly (#3767) 2022-02-10 23:02:24 +01:00
Daniel Marjamäki 3989408738 Update copyright year 2022-02-05 11:45:17 +01:00
chrchr-github 8cf5c8fbf2
Fix #10684 FP unusedStructMember with static object (#3681) 2022-02-02 19:28:16 +01:00
chrchr-github 127b3bb1c4
Fix #9471 FP unreadVariable caused by invalid template injection (#3783) 2022-02-01 17:15:27 +01:00
Oliver Stöneberg 171da2e6f9
avoid dependency on transitive includes - based on include-what-you-use (#3757) 2022-01-27 19:03:20 +01:00
chrchr-github c132235a76
Add test for #10398 (#3752)
* Fix #10200 False positive: uninitStructMember

* Fix #9828 False positive: unreadVariable alias

* Use Token::Match

* Add test for #10398
2022-01-25 22:05:54 +01:00
chrchr-github d05e43ce15
Fix #9828 False positive: unreadVariable alias (#3744) 2022-01-24 21:52:45 +01:00
chrchr-github 089ca67d78
Use TODO_ASSERT (#3704) 2022-01-18 22:03:52 +01:00
chrchr-github 95dc05b21d
Fix #7732 false negative: (style) Unused variable: std::pair (#3695) 2022-01-13 08:05:05 +01:00
chrchr-github 7aa0ec3e95
Fix regression: unreadVariable for trivial initialization (#3698) 2022-01-12 22:06:03 +01:00
chrchr-github 1670805a8d
Fix #10490 FP unreadVariable with std::shared_lock (#3672) 2022-01-10 07:43:02 +01:00
chrchr-github df3da38483
Fix #10682 Unused QString / #10686 unused std::array / #10005 unused variable with c++11 braced initializer not detected (#3684) 2022-01-10 07:36:49 +01:00
chrchr-github 5a95ece15e
#10591: add TODO (#3647) 2021-12-21 10:24:38 +01:00
chrchr-github bb327be8e8
Fix #10591 FP unusedStructMember with value-initialized struct and typedef (#3643) 2021-12-18 22:55:52 +01:00
chrchr-github ca311ebcdf
ASSERT() on calls to Tokenizer::tokenize() in test code (#3501) 2021-11-29 07:34:39 +01:00
Daniel Marjamäki 3f7093004a Fixed #10485 (FP unusedStructMember for array size) 2021-10-30 19:34:46 +02:00
chrchr f363d8948b Fix test case 2021-10-30 19:04:50 +02:00
Daniel Marjamäki 1f01845efb Fixed #10531 (FP unreadVariable with reference and *=) 2021-10-25 19:34:19 +02:00
Daniel Marjamäki 2ee920dc4e Fixed #10495 (False positive: unreadVariable when assigning to reference returned by method) 2021-09-24 07:30:17 +02:00
Daniel Marjamäki a55b0c332a Fixed #10095 (False positive: unreadVariable) 2021-08-27 17:37:42 +02:00
Paul Fultz II 7f358b2bed
Format with uncrustify (#3388) 2021-08-07 20:51:18 +02:00
Daniel Marjamäki 216918756b Fixed #10276 (FP: (style) Variable '((uint8_t*)(uint16_t)0x1000)[0]' is assigned a value that is never used.) 2021-05-18 20:35:00 +02:00
Daniel Marjamäki 3c885df74d testunusedvar: Remove test cases that have undefined behavior 2021-05-15 14:55:35 +02:00
Daniel Marjamäki 404b82fc21 unused var; fix todo test cases, redundant assignment of array in loop 2021-05-14 19:07:30 +02:00
Daniel Marjamäki 56410c3d00 testunusedvar: fix mismatching allocation/deallocation in test 2021-05-14 14:01:39 +02:00
Daniel Marjamäki 56bc5536aa testunusedvar: move UB testcase to testuninitvar 2021-05-14 11:24:39 +02:00
Daniel Marjamäki ffac1d1b00 testunusedvar.cpp: remove test cases that has undefined behavior 2021-05-14 11:06:44 +02:00
Daniel Marjamäki fd31f0846e unused var; remove test case that has undefined behavior 2021-05-13 21:53:06 +02:00
Daniel Marjamäki 1def0d797b extracttests: disable TestUnusedVar::localvar2 tests they do not make sense externally 2021-05-13 21:31:44 +02:00
Daniel Marjamäki d549770b5b updated extracttests.py. fix syntax errors in test cases. 2021-05-13 20:21:02 +02:00
Daniel Marjamäki 2e2d766e2b Fixed #6766 (Improve check; struct member is assigned value that is never used) 2021-05-09 20:09:10 +02:00
dummyunit b18e6f1e10
Fix varId assignment for uses of variables declared in the if condition (#3231)
Variables declared in the if condition (or in C++17 init-statement) are
visible not only in the if body but also in the else body. But logic in
Tokenizer::setVarIdPass1() handled such variables as if they were
declared in the if body.

As the result they were removed from variablesMap by the time the else
block was parsed and their uses in the else block were either given an
incorrect varId from variables in some outer scope or not given a varId
at all.

This then resulted in false positive unreadVariable errors for variables
declared in the if condition (or init-statement) and used only in the
else block.

Simplification from "else if ..." to "else { if ... }" was moved before
setVarId() to simplify detection for ends of blocks in if-else chains.
2021-04-26 07:38:03 +02:00
Daniel Marjamäki 42437277dc Update Copyright year 2021-03-21 20:58:32 +01:00
PKEuS 141d2ac215 Refactorization: Improved internal implementation of severity and certainty levels
Backported from LCppC.
2021-02-24 22:00:06 +01:00
PKEuS 4b01d5bdc6 Re-enabled a bunch of disabled unit tests, some as TODO tests
Merged from LCppC.
2021-02-20 13:02:14 +01:00
PKEuS cf1937294a Refactorization: Removed unnecessary \n and spaces in strings
Merged from LCppC.
2021-02-20 12:58:42 +01:00
PKEuS 423d7dbc3c Fixed false negatives literalWithCharPtrCompare when address-of operator (C only) or arrays are used, adapted TODO unit tests
Enabled working unit test in testunusedvar.cpp

Merged from LCppC.
2021-02-20 12:42:48 +01:00
miltolstoy ee8d5b972a
checkunusedvar: handle array element change using pointer arithmetic (#3000) 2021-01-01 08:06:20 +01:00
miltolstoy 6366a577f9
feat(unused_var): analyze global variables inside function body (#2944) 2020-12-19 08:55:19 +01:00
Daniel Marjamäki 484b68c550 astyle formatting 2020-11-28 05:52:35 +01:00
miltolstoy 5d299016f1
feat: analyze function side effects (#2901) 2020-11-26 17:34:42 +01:00
Daniel Marjamäki 34c8334882 Fixed #9737 (False positive: unreadVariable) 2020-10-25 20:32:45 +01:00
Daniel Marjamäki 05514950af astyle formatting
[ci skip]
2020-10-25 07:12:30 +01:00
miltolstoy d55874ec37
checkunusedvar: handle initialization list (#2836) 2020-10-25 07:11:45 +01:00
Daniel Marjamäki 6de91d6386 Fixed #9707 (False positive: unreadVariable, union) 2020-10-02 20:22:22 +02:00
Daniel Marjamäki ba84303501 Fixed #9680 (false positive: style: Variable 'x' is assigned a value that is never used with smart pointers) 2020-09-27 19:15:15 +02:00
Daniel Marjamäki 7bb82c5df7 Fixed #9901 (False positive: variable is assigned value that is not used 'if (--N == 0)') 2020-09-26 22:13:05 +02:00
Daniel Marjamäki 682a6d1c02 Fixed #9017 (Simple classes without side effects not reported as unused) 2020-07-23 11:10:08 +02:00
Daniel Marjamäki 0583763cc6 Fixed #3088 (False positive: Dont report "struct or union member is never used" for structs with __attribute__((packed)) or #pragma pack(push)) 2020-06-30 11:00:40 +02:00
Daniel Marjamäki 08ddd84780 Update copyright year 2020-05-10 11:16:32 +02:00
Daniel Marjamäki 3e0218299b Revert "Update copyright year"
This reverts commit 6eec6c4bd5.
2020-05-10 11:13:05 +02:00
Daniel Marjamäki 6eec6c4bd5 Update copyright year 2020-05-10 11:11:34 +02:00
shaneasd 82c09f243b
Maybeunusedsupport (#2570)
* Add rudimentary support for [[maybe_unused]]

* Add more test cases. use the symboldatabase rather than reparsing. Fix travis error.

* test review actions

* change var to usage._var
2020-04-12 20:35:54 +02:00
Daniel Marjamäki 37a4e375ba astyle formatting
[ci skip]
2020-04-08 22:39:17 +02:00
Achouv 7719e4309d
avoid false positive unused static const struct member (#2598) 2020-04-08 18:09:20 +02:00
Daniel Marjamäki 67b495fc50 Fixed #9280 (False positive: unreadVariable on assignment to fixed address volatile struct member) 2020-02-15 17:31:47 +01:00
Daniel Marjamäki 8c0ad6a1b9 Fixed #9555 (False positive (unreadVariable): struct is assigned a value that is never used) 2020-02-15 16:43:06 +01:00
Daniel Marjamäki bd83630f2e Fixed #8990 (False positive: struct member not used (union)) 2019-12-20 18:31:55 +01:00
Daniel Marjamäki f5e3dc9a38 Improved fix for #8978 (False positive: Variable assigned value that is never used when assigning via iterator) 2019-11-17 12:08:21 +01:00
Daniel Marjamäki 5654630099 Fixed #8978 (False positive: Variable assigned value that is never used when assigning via iterator) 2019-11-16 19:49:54 +01:00
Daniel Marjamäki 06ea1a2b53 Fixed #9312 (FP : variable is assigned a value that is never used (static)) 2019-11-04 17:59:16 +01:00
Daniel Marjamäki 510748134f Fixed #9234 (FP unreadVariable - assignment via iterator) 2019-08-04 10:21:16 +02:00
Daniel Marjamäki a1214348c0 Fixed #8974 (false negative regression about never used variable) 2019-07-29 08:49:19 +02:00
Daniel Marjamäki a178d05cc5 Changed TODO test case, I do not see why it should warn. 2019-07-29 07:51:00 +02:00
Daniel Marjamäki d2284ddbcd Fix false positives in self check: Variable t is assigned a value that is never used. Classes with destructors was not handled properly. 2019-07-14 16:20:45 +02:00
Daniel Marjamäki 1cadd9398a Fixed #8933 (false negative: (style) Variable is assigned a value that is never used (std::string)) 2019-07-14 09:44:30 +02:00
Daniel Marjamäki f84dcc4738 astyle formatting
[ci skip]
2019-07-03 08:29:47 +02:00
Ken-Patrick d6f6e68fa2 Fix false positive 9167 (#1904)
Skip returns from local class/struct definition in FwdAnalysis.
2019-07-03 08:17:06 +02:00
Paul Fultz II 108cdaa485 Fix FP with unreadVariable (#1859) 2019-05-31 08:06:36 +02:00
Daniel Marjamäki bd7790fd8c Update copyright year 2019-02-09 07:24:06 +01:00
Daniel Marjamäki 2bba9ac78a Fixed #8948 (False Positive: Variable 'n' is assigned a value that is never used.) 2019-01-26 21:44:07 +01:00
Daniel Marjamäki 8c07be136a Fixed #8949 (False Positive: Variable 'f' is assigned a value that is never used.) 2019-01-22 21:16:27 +01:00