Commit Graph

35 Commits

Author SHA1 Message Date
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
IOBYTE ce50df8047 Fix override warnings. (#1234) 2018-05-15 16:37:40 +02:00
Daniel Marjamäki c4caee6b18 Updated copyright year 2018-01-14 15:37:52 +01:00
Ayaz Salikhov 28aa939d69 iwyu - include what you use 2017-05-27 04:33:47 +02:00
Daniel Marjamäki 040d2f0012 Use simplecpp lexer in test cases 2017-05-18 21:52:31 +02:00
Daniel Marjamäki 101dc28afa Refactoring: Moved checkMemset.. from CheckOther to CheckFunctions 2017-04-23 07:53:41 +02:00
Daniel Marjamäki f8e9071de1 CheckFunction: In the <valid> check handle possible/conditional/inconclusive values better 2017-04-20 22:14:54 +02:00
Daniel Marjamäki 41a64f6d1f Fix crash 2017-04-11 20:16:33 +02:00
Daniel Marjamäki 7d8af7bdca Fixed #7979 (crash (nr 2): CheckFunctions::checkIgnoredReturnValue()) 2017-04-07 13:18:53 +02:00
Daniel Marjamäki 5ea9519586 UseRetVal: Fix FN for methods 2017-03-05 22:23:16 +01:00
Daniel Marjamäki 774a8979a3 Fixed #7095 (False positive: (warning) Return value of function to_string() is not used.) 2017-02-12 16:50:45 +01:00
Daniel Marjamäki 7c800d6ed7 Fixed #7447 (FP: ignoredReturnValue on C++11 uniform initialization) 2017-02-12 16:33:28 +01:00
PKEuS dde6f5eaea Do not warn about alloca() in C89 mode (#7558) 2016-06-20 09:30:41 +02:00
Matthias Krüger b42feb7b88 fix testrunner (sample was not updated in f5e8a72dc2). 2016-04-08 12:09:16 +02:00
Lauri Nurmi 996c9244d8 Update copyright year to 2007-2016. 2016-01-01 15:34:45 +02:00
Daniel Marjamäki 293bd2eead Fixed #6990 (false negative: Invalid abs() argument nr 1. A non-boolean value is required.) 2015-12-26 01:38:41 +01:00
PKEuS 8f641aaa76 Added gets_s() to std.cfg (C11), added <use-retval/> to min/max(). 2015-12-18 18:09:07 +01:00
PKEuS f516de8633 Moved a few checks from CheckOther to CheckFunctions 2015-11-22 13:49:10 +01:00
PKEuS 57d1196386 Replaced CheckNonReentrantFunctions and CheckObsoleteFunctions by generic CheckFunctions which is based on Library (#6529) 2015-11-22 09:18:07 +01:00