Commit Graph

68 Commits

Author SHA1 Message Date
Daniel Marjamäki 3e6540c4b3 Fixed #10523 (FP: missingReturn with nested switch statements) 2021-10-31 14:48:29 +01:00
Daniel Marjamäki 47f5e5d145 Fixed #10461 (FP missingReturn with empty initializer list) 2021-09-06 21:20:19 +02:00
Daniel Marjamäki dccebb98ea Removed missingReturn inconclusive warnings, that was too noisy 2021-09-01 19:50:17 +02:00
Daniel Marjamäki c2305b1da7 Fixed #10396 (FP missingReturn on void operator=()) 2021-08-10 09:55:16 +02:00
Paul Fultz II 7f358b2bed
Format with uncrustify (#3388) 2021-08-07 20:51:18 +02:00
Daniel Marjamäki 9362c1fc6c missing return; write inconclusive error if function ends with unknown function-like macro 2021-07-18 16:00:42 +02:00
Daniel Marjamäki 02682ab17d missing return; Fixed FP when function ends with assert(0) 2021-07-18 14:54:25 +02:00
orbitcowboy 3f1e937ea1 Running astyle [ci skip] 2021-07-17 08:19:04 +02:00
Pavel Šimovec c71e2da5a8
Remove a false positive - main function has no return value (#3335) 2021-07-16 18:50:16 +02:00
Daniel Marjamäki 24c17916af missingReturn; ensure Function::returnsVoid returns true when there is unknown macro 'void STDCALL foo() {}' 2021-07-12 20:29:20 +02:00
Daniel Marjamäki e4ecfd7be8 missingReturn; Fixed false positive when if condition is always true 2021-07-12 17:53:32 +02:00
Daniel Marjamäki a336c07663 missing return; False positive when goto jumps back 2021-07-12 15:31:21 +02:00
Daniel Marjamäki a8fb0309fd missingReturn; Improved handling of noreturn function 2021-07-10 08:59:01 +02:00
Daniel Marjamäki 53955b48d2 missingReturn; Fixed false negative for goto-label 2021-07-10 08:49:48 +02:00
Daniel Marjamäki 8f1cb2304f missingReturn; Add missing ASSERT_EQUALS in test 2021-07-10 08:45:04 +02:00
Daniel Marjamäki c6f7a78ebb missingReturn; Fixed false positives 2021-07-10 08:37:10 +02:00
Daniel Marjamäki 7cb66d56f3 missingReturn; fixed false positive with trailing return type 2021-07-08 13:50:26 +02:00
Daniel Marjamäki ef0af26d9f missingReturn; Fixed FP when function is declared in macro 2021-07-08 13:14:11 +02:00
Maksim Derbasov 6b8d0be431
New check: [perf] Copy elision optimization can't be applied for `return std::move(local)` (#3281) 2021-07-06 08:07:46 +02:00
Daniel Marjamäki 6cb8f87798 missing return; fixed false positive for 'return {};' 2021-07-04 19:59:22 +02:00
Daniel Marjamäki 036c71d967 Fixed #5462 (non-void function does not return a value) 2021-07-04 11:27:57 +02:00
Daniel Marjamäki 118ad67645 testrunner: return value in non-void functions 2021-06-12 16:43:48 +02:00
keinflue 6541f52e61
Fix false positive invalidFunctionArg for zero arguments to calloc. (#3238) 2021-05-01 12:39:01 +02:00
Daniel Marjamäki 518fb01553 Fixed #8412 (ignoredReturnValue not issued when return value is changed but not really used (by logical not for example)) 2021-04-04 18:26:07 +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
Georgy Komarov 80dee36e68
library: Add new warning: ignoredReturnErrorCode (#2877)
* library: Add optional "type" attribute to "use-retval"

Added an optional "type" attribute to "use-retval" nodes in the
configuration. When the return type of a function configured with
`<use-retval type="error-code"\>` node does not used, the new style
error "ignoredReturnErrorCode" will be generated.

* Fix and improve patch after the initial review

* Fixed severity level and [[nodiscard]] attribute

* Fix incorrect condition

* Remove redundant condition
2020-11-05 13:35:52 +01:00
orbitcowboy 05c36a79b5 Fix testrunner fail, introduced by latest commit 2020-06-12 09:18:16 +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
Daniel Marjamäki 1173186876 Fixed daca@home crash by stopping for unknown macro 'MACRO(a();b();)' 2020-03-12 13:28:09 +01:00
Dmitry-Me 5a48ac0c6e Improve test coverage for invalid use of bool parameters 2019-11-22 18:11:38 +03:00
Oliver Stöneberg eac040a00b Various clang-tidy fixes (#2192)
* use range loops

* removed redundant string initializations

* use nullptr

* use proper boolean false

* removed unnecessary continue from end of loop

* removed unnecessary c_str() usage

* use emplace_back()

* removed redundant void arguments
2019-09-25 15:25:19 +02:00
Paul Fultz II e856920488 Fix false positive with ignoredReturnValue with std::move (#1809) 2019-04-26 12:22:31 +02:00
Paul Fultz II a90caa7e5a Fix issue 9006: False positive: Return value of function std::move() is not used.
This is trying to fix the issue by fixing the ast and symbol database. First, the ast nodes will be created for the init list and the symbol database will not mark it as a scope. I am not sure if this is the correct approach as I dont really understand how the AST part works.

It did change the AST for `try {} catch (...) {}` but that is because it incorrectly treats `try {}` as an initializer list.
2019-04-15 06:37:27 +02:00
Daniel Marjamäki 773d19b2d6 Fix compiler errors. After removing the -std=posix. 2019-04-12 10:41:53 +02:00
Daniel Marjamäki 3dc34f1515 Disable all simplified checks 2019-03-16 09:17:50 +01:00
Daniel Marjamäki bd7790fd8c Update copyright year 2019-02-09 07:24:06 +01:00
Daniel Marjamäki 8dd641b8be Use OVERRIDE in test 2019-01-12 15:45:25 +01:00
rikardfalkeborn 402d0c565f Fix false positive: Invalid string argument with array (#1439) 2018-10-19 07:48:47 +02:00
rikardfalkeborn f1074ea1ab Fix false positive: Invalid string argument with pointer to pointer (#1427)
If the address is taken inside an array, the address is not of a single
character, so do not warn about this.
2018-10-16 06:54:25 +02:00
rikardfalkeborn 613dc19b68 #4241: Check for address of single character passed as string (#1381)
* #4241: Check for address of single character passed as string

Add a check that address of a single character is not passed as argument
to argument marked as strings (using strz). The check does not warn if
the address of a character with known value '\0'.

Since ValueFlow currently does not handle global constants (see #7597),
do not warn if the variable is global to avoid FPs when the address of
a global variable assigned to '\0' is passed to a function expecting a
string.

Remove comment in docs saying strz is unused.

* Change asdf to Hello world

* Add test of address to first element in string

* Add error reporting function to getErrorMessages

* Fix strings in test
2018-10-14 18:49:34 +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
rikardfalkeborn 30a8d953e3 Move sqrt{,f,l} argument checks to cfg file (#1313) 2018-07-20 20:56:39 +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 45379a3aa6 Updated copyright year for modified files
[ci skip]
2018-06-10 22:07:21 +02:00
IOBYTE 3982c81394 Add support for C++ attribute nodiscard for functions. (#1269) 2018-05-29 21:43:56 +02:00