Commit Graph

298 Commits

Author SHA1 Message Date
Daniel Marjamäki 484b68c550 astyle formatting 2020-11-28 05:52:35 +01:00
Daniel Marjamäki ad0eb6108b Attempt to fix crashes when variable valueType is nullptr. This can happen when decltype is used on unknown type 2020-11-27 16:45:26 +01:00
miltolstoy 5d299016f1
feat: analyze function side effects (#2901) 2020-11-26 17:34:42 +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
Oliver Stöneberg 7189b303ae
fixed some modernize-loop-convert clang-tidy warnings (#2815) 2020-09-21 19:30:47 +02:00
shaneasd 53a0760fdf
Improve ast generation for templated function parameters (#2803) 2020-09-14 18:44:50 +02:00
Daniel Marjamäki a11a0e79e4 Fixed Cppcheck internal warning 2020-07-23 18:54:40 +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
Oliver Stöneberg 4f68d85633
optimized non-matchcompiled Token::simpleMatch() a bit (#2640) 2020-05-26 20:13:56 +02:00
Oliver Stöneberg 37bc0483a4
made check.h less heavy (#2633) 2020-05-23 07:16:49 +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
Oliver Stöneberg 1af959af2c
fixed -Wextra-semi-stmt Clang warnings (#2553)
* fixed -Wextra-semi-stmt Clang warnings

* adjusted REDIRECT macro to require a semicolon

* testmathlib.cpp: rolled back accidental change
2020-04-21 17:27:51 +02:00
Daniel Marjamäki 2f5e585e59 astyle formatting
[ci skip]
2020-04-13 12:52:00 +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 0725c2290c Tokenizer: Do not simplify function pointers to normal pointers as we loose important information 2020-04-10 11:53:32 +02:00
Achouv 7719e4309d
avoid false positive unused static const struct member (#2598) 2020-04-08 18:09:20 +02:00
Rikard Falkeborn b1c6f2946a
Fix redundant FP assignment with unsigned zero (#2521)
* Refactor isNullOperand out of FwdAnalysis

* Improve isNullOperand

* Fix redundantAssignment FP with unsigned zero

* isNullValue check number

* Enhance isNullOperand to handle c++ casts

Also handle cast of NULL.
2020-02-09 11:16:08 +01:00
Daniel Marjamäki b6833b525f Clang import 2020-01-25 17:01:17 +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 1d441f64c1 CheckUnusedVar: Quick heuristic so we don't bailout for 'auto' variables 2019-11-17 15:44:57 +01:00
Daniel Marjamäki d0daf1f90d CheckUnusedVar: Assume that assignment has 'standard behavior' by default 2019-11-17 12:33:26 +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
amai2012 f02636e995 Refactoring: Convert enums to enum classes 2019-08-02 21:14:29 +02:00
Daniel Marjamäki f63011c219 Try to fix daca@home crashes 2019-07-29 19:06:41 +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 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 534659e596 Avoid 'unsigned' in Tokenizer. Use 'nonneg' instead for arguments and members. 2019-07-14 15:48:20 +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 9d5f672dbc Unused struct member: Fix FPs seen in daca@home results for template structs 2019-03-06 20:51:48 +01: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 ed514644b8 Renamed FwdAnalysisAllPaths to FwdAnalysis 2018-12-31 18:00:47 +01:00
Daniel Marjamäki 6b49a784c5 Fixed #8911 (Regression: False positive: Unassigned variable (alias)) 2018-12-30 20:20:20 +01:00
Daniel Marjamäki ddbe5c129c Clarify FwdAnalysis. It is useful for checks that need data flow analysis of ALL paths. 2018-12-25 11:56:06 +01:00
Daniel Marjamäki f118c22bb6 CheckUnusedVar: Cleanup checker 2018-12-17 17:48:45 +01:00
Daniel Marjamäki cf09fd6274 CheckUnusedVar: Code cleanup 2018-12-17 17:28:15 +01:00
Daniel Marjamäki c8d688607a Fixed #8901 (Unused value: const variable initialization) 2018-12-16 19:01:05 +01:00
Daniel Marjamäki 1f27cd56c0 FwdAnalysis; Code cleanup, isNullOperand 2018-12-13 21:01:33 +01:00
Daniel Marjamäki 0b4e08cac9 Use FwdAnalysis in UnusedVar. This is still work-in-progress. Merging to master branch so it can be tested. 2018-12-13 18:52:56 +01:00
Daniel Marjamäki 69f6100d83 Fixed #8339 (false positive: unread variable despite delete is used on it) 2018-11-14 17:04:21 +01:00
Daniel Marjamäki ac242b69d6 Refactoring: Use range for loops 2018-11-14 06:58:21 +01:00
orbitcowboy d08b39c915
Improved const correctness of local variables. There are no functional changes intended. (#1392) 2018-09-23 20:24:51 +02:00
Daniel Marjamäki a25461919c Rename private member variables 2018-06-17 19:04:06 +02:00
Daniel Marjamäki 965fcf9303 Rename private member variables 2018-06-17 18:55:41 +02:00
Daniel Marjamäki 78974e9267 Rename _type to mType 2018-06-16 20:25:54 +02:00
Daniel Marjamäki 79ffe1d4fc Rename _tokenizer, _settings, _errorLogger 2018-06-16 16:10:28 +02:00
Daniel Marjamäki ca8e19c96d SymbolDatabase: Refactor SymbolDatabase: variable list 2018-04-28 09:38:33 +02:00
Daniel Marjamäki f336c2efe7 Refactoring; Renamed Scope::classStart and Scope::classEnd 2018-04-27 22:36:30 +02:00
Daniel Marjamäki b7a52c3811 CheckUnusedVar: Use isLikelyStreamRead 2018-04-22 17:08:23 +02:00
Daniel Marjamäki c84628c28a Fixed #8494 (False positive: serialization class overloads operator) 2018-04-17 14:23:04 +02:00
Daniel Marjamäki e95ff8c7b6 Avoiding emplace 2018-04-14 19:24:35 +02:00
PKEuS d2146844dd Refactorizations:
- Replace several push_back-calls by emplace_back
- Replace some x = x.substr(0, y) calls by x.erase(y)
2018-04-11 09:44:35 +02:00
Daniel Marjamäki a0906140a6 Suppressions: New extensible Suppressions xml format that allow more attributes. To start with it also allows symbolName. 2018-04-09 06:43:48 +02:00
jrp2014 034296039c Refactor lib/checkunusedvar.cpp 2018-04-06 08:07:15 +02:00
jrp2014 b6504c70ca Improve constness 2018-04-04 21:51:31 +02:00
Daniel Marjamäki 7e4dba6a7e Updated copyright year 2018-03-31 20:59:09 +02:00
Daniel Marjamäki dbe962ad5d Compatibility fix for gcc 4.5 2018-03-29 22:00:04 +02:00
Daniel Marjamäki c4caee6b18 Updated copyright year 2018-01-14 15:37:52 +01:00
Daniel Marjamäki b3c80947ed Fixed #6508 (False positive unusedStructMember - brace initializer) 2017-11-12 22:33:17 +01:00
Ayaz Salikhov be2c65eb58 Simplify int vs bool 2017-10-08 07:54:39 +02:00
Dmitry-Me d18e8466a9 Cache and reuse values 2017-09-27 00:51:04 +03:00
Dmitry-Me 2582bbd0f6 Break loop early 2017-08-24 18:10:33 +03:00
Ayaz Salikhov b8cd7dbb5c Use nullptr instead of 0 or NULL (#936) 2017-08-09 20:00:26 +02:00
Daniel Marjamäki 9ef9d0e4a8 Fixed #8128 (False negative: variable is assigned value that is not read) 2017-08-01 14:56:53 +02:00
Daniel Marjamäki 0a03bbb320 Fixed #6315 (false positive - unreadVariable - variable is used via pointer) 2017-07-23 23:32:14 +02:00
Daniel Marjamäki ac85b78e2a Fixed #5619 (false positive: unusedVariable - array accessed by pointer variable only) 2017-07-09 11:19:00 +02:00
Daniel Marjamäki 211d8c6020 Refactoring checking for unused variables (avoid FN when not taking address) 2017-07-01 22:45:51 +02:00
Daniel Marjamäki d6f066482e Fixed #6542 (FP: Variable 'lcount' is not assigned a value - using address of integer array) 2017-07-01 11:31:51 +02:00
Daniel Marjamäki db01ea1408 Fixed #6261 (false positive: Variable used in ternary expression within function argument list) 2017-07-01 11:03:49 +02:00
Daniel Marjamäki b8ee500d45 Fixed #7092 (Invalid style error: Variable not assigned a value) 2017-06-03 15:31:29 +02:00
Ayaz Salikhov 28aa939d69 iwyu - include what you use 2017-05-27 04:33:47 +02:00
PKEuS b1f4bd7504 Refactorization: Reimplemented Settings::_enabled as a bitfeld instead of std::set (#7995) 2017-04-11 11:49:26 +02:00
PKEuS 3c8f5b85ae Refactorization: Allocate Token::_values (ValueFlow information) dynamically, reducing size of each token by around 10% 2017-03-27 18:48:34 +02:00
Daniel Marjamäki 841e0c2921 Fixed #7546 (Assignment to array element not detected if pointer addition is used) 2017-02-28 22:04:05 +01:00
umanamente 0c1ba8e8b4 (Fixed #7895) C++11 brace initialization. Added test. (#862)
Add an optional extended description…
2017-01-22 10:16:40 +01:00
Matthias Krüger b3ace258ab there is no need to have "if(tok && Token::Match(tok,..." since Token::Match checks "tok" by itselfs already. 2016-11-26 17:22:30 +01:00
Daniel Marjamäki efa3aba32a Remove Tokenizer::simplifyNull() 2016-10-18 21:44:02 +02:00
PKEuS 1227a3f596 Improved check: Complain if a variable is modified but not used again 2016-10-10 21:27:40 +02:00
Daniel Marjamäki ac1a869d60 unused struct members: don't warn about packed structs (#3088) 2016-09-05 17:27:12 +02:00
Daniel Marjamäki 60f22bd4ee Fixed #7477 (False positive 'Assigned value is never used' in multithreaded context) 2016-09-03 20:38:36 +02:00
Roberto Martelloni 28f1222dc2 CWE mapping of useAutoPointerMalloc, uselessCallsCompare, uselessCallsSwap, uselessCallsSubstr, uselessCallsEmpty, uselessCallsRemove, derefInvalidIterator, reademptycontainer, multiplySizeof, divideSizeof, stringLiteralWrite, incorrectStringCompare, literalWithCharPtrCompare, charLiteralWithCharPtrCompare, incorrectStringBooleanError, staticStringCompare, stringCompare, signConversion, truncLongCastAssignment, truncLongCastReturn, unusedFunction, unusedVariable, unusedAllocatedMemory, unreadVariable, unassignedVariable, unusedStructMember, postfixOperator, va_start_wrongParameter (#824)
Add an optional extended description…
2016-09-03 00:31:35 +02:00
Daniel Marjamäki 9f59bd6dae Try to fix travis hang 2016-08-02 19:23:45 +02:00
Daniel Marjamäki f23287544a Fixed #7196 (Improve check: deem sizeof(thing) as using the thing's members) 2016-08-02 18:50:04 +02:00
Daniel Marjamäki 41526ef3a8 Fixed #6147 (FP unreadVariable: variable assignment in function call argument list) 2016-08-02 08:50:04 +02:00
Daniel Marjamäki 920ac5a3f6 astyle formatting
[ci skip]
2016-07-16 21:21:24 +02:00
Roberto Martelloni 25525e38a7 CWE mapping of incorrectStringCompare, literalWithCharPtrCompare, charLiteralWithCharPtrCompare, incorrectStringBooleanError, staticStringCompare, stringCompare, signConversion, unusedFunction, unusedVariable 2016-07-16 10:07:06 +01:00
PKEuS 3bdcf68990 Fixed false positive in CheckUnusedVar::checkFunctionVariableUsage(): Bailout when break; is encountered
See also: https://sourceforge.net/p/cppcheck/discussion/general/thread/1c169dc5/
2016-07-07 18:27:31 +02:00
Daniel Marjamäki 54be403f64 Fixed #7026 (Cppcheck does not recognizes the use of a variabile inside lambda function) 2016-05-26 18:07:56 +02:00
PKEuS cda246da75 Refactorized CheckUnusedVar::checkStructMemberUsage(): Reimplemented check based on symboldatabase 2016-05-25 11:13:31 +02:00
PKEuS 43bf1bb685 Refactorized CheckUnusedVar::checkStructMemberUsage(): Drastically reduced number of Token::findmatch() calls to improve performance 2016-05-24 23:10:39 +02:00