cppcheck/test
rikardfalkeborn 7779a9186e Use valueflow in unsigned less than zero checker (#1630)
The unsigned less than zero checker looked for patterns like "<= 0".
Switching to use valueflow improves the checker in a few aspects.

First, it removes false positives where instead of 0, the code is using
0L, 0U, etc. Instead of having to hard code the different variants of 0,
valueflow handles this automatically. This fixes FPs on the form

	uint32_t value = 0xFUL;
	void f() {
  		if (value < 0u)
		{
			value = 0u;
		}
	}

where 0u was previously not recognized by the checker. This fixes #8836.

Morover, it makes it possible to handle templates properly. In commit
fa076598ad, all warnings inside templates
were made inconclusive, since the checker had no idea if "0" came from
a template parameter or not.

This makes it possible to not warn for the following case which was
reported as a FP in #3233

	template<int n> void foo(unsigned int x) {
	if (x <= n);
	}
	foo<0>();

but give a warning for the following case

	template<int n> void foo(unsigned int x) {
	if (x <= 0);
	}

Previously, both these cases gave inconclusive warnings.

Finally, it makes it possible to give warnings for the following code:

	void f(unsigned x) {
		int y = 0;
		if (x <= y) {}
	}

Also, previously, the checker for unsigned variables larger than 0, the
checker used the string of the astoperand. This meant that for code like
the following:

	void f(unsigned x, unsigned y) {
		if (x -y >= 0) {}
	}

cppcheck would output

	[unsigned-expression-positive.c] (style) Unsigned variable '-' can't be negative so it is unnecessary to test it.

using expressionString() instead gives a better error message

        [unsigned-expression-positive.c] (style) Unsigned expression 'x-z' can't be negative so it is unnecessary to test it.
2019-01-31 09:30:29 +01:00
..
cfg gtk.cfg: Add configurations for g_free() and g_malloc() / g_malloc0() 2019-01-28 13:47:46 +01:00
synthetic Improve Python code 2017-06-05 13:23:00 +02:00
CMakeLists.txt Add a check target to cmake (#1465) 2018-11-05 18:13:04 +01:00
options.cpp Updated copyright year 2018-01-14 15:37:52 +01:00
options.h Updated copyright year 2018-01-14 15:37:52 +01:00
redirect.h Updated copyright year 2018-01-14 15:37:52 +01:00
test.cxx test: tabs to spaces, remove trailing spaces and extra empty lines at the end of files 2012-09-17 13:51:40 +02:00
test64bit.cpp Use OVERRIDE in test 2019-01-12 15:45:25 +01:00
testassert.cpp Use OVERRIDE in test 2019-01-12 15:45:25 +01:00
testastutils.cpp Use OVERRIDE in test 2019-01-12 15:45:25 +01:00
testautovariables.cpp Lifetime: Support analysis with functions that do not return a reference (#1632) 2019-01-29 09:47:52 +01:00
testbool.cpp Use OVERRIDE in test 2019-01-12 15:45:25 +01:00
testboost.cpp Use OVERRIDE in test 2019-01-12 15:45:25 +01:00
testbufferoverrun.cpp ValueFlow: Set arrays to true when converting to a boolean 2019-01-21 20:05:35 +01:00
testcharvar.cpp Use OVERRIDE in test 2019-01-12 15:45:25 +01:00
testclass.cpp Replace "virtual method" with "virtual function" in messages. 2019-01-15 06:22:14 +01:00
testcmdlineparser.cpp Use OVERRIDE in test 2019-01-12 15:45:25 +01:00
testcondition.cpp Add regression test for #8780 (#1619) 2019-01-25 07:48:18 +01:00
testconstructors.cpp Use OVERRIDE in test 2019-01-12 15:45:25 +01:00
testcppcheck.cpp Use OVERRIDE in test 2019-01-12 15:45:25 +01:00
testerrorlogger.cpp Use OVERRIDE in test 2019-01-12 15:45:25 +01:00
testexceptionsafety.cpp Use OVERRIDE in test 2019-01-12 15:45:25 +01:00
testfilelister.cpp Use OVERRIDE in test 2019-01-12 15:45:25 +01:00
testfiles.pri testrunner: Add testplatform to verify platform loading (#1176) 2018-04-18 16:12:35 +02:00
testfunctions.cpp Use OVERRIDE in test 2019-01-12 15:45:25 +01:00
testgarbage.cpp Use OVERRIDE in test 2019-01-12 15:45:25 +01:00
testimportproject.cpp Fixed #8925 (compile_commands.json: False positives in .mm (Objective-C++) files, that file type should maybe just be ignored) 2019-01-21 06:36:31 +01:00
testincompletestatement.cpp Use OVERRIDE in test 2019-01-12 15:45:25 +01:00
testinternal.cpp Use OVERRIDE in test 2019-01-12 15:45:25 +01:00
testio.cpp Use OVERRIDE in test 2019-01-12 15:45:25 +01:00
testleakautovar.cpp Fixed #8392 (false positive: "Memory leak" with malloc in if) 2019-01-27 10:27:44 +01:00
testlibrary.cpp Use OVERRIDE in test 2019-01-12 15:45:25 +01:00
testmathlib.cpp Use OVERRIDE in test 2019-01-12 15:45:25 +01:00
testmemleak.cpp Remove TestMemleakGlib and TestMemleakWindows 2019-01-12 19:09:55 +01:00
testnullpointer.cpp Run astyle 2019-01-12 21:51:39 +01:00
testoptions.cpp Use OVERRIDE in test 2019-01-12 15:45:25 +01:00
testother.cpp Use valueflow in unsigned less than zero checker (#1630) 2019-01-31 09:30:29 +01:00
testpath.cpp Use OVERRIDE in test 2019-01-12 15:45:25 +01:00
testpathmatch.cpp Use OVERRIDE in test 2019-01-12 15:45:25 +01:00
testplatform.cpp Use OVERRIDE in test 2019-01-12 15:45:25 +01:00
testpostfixoperator.cpp Use OVERRIDE in test 2019-01-12 15:45:25 +01:00
testpreprocessor.cpp Use OVERRIDE in test 2019-01-12 15:45:25 +01:00
testrunner.cpp Updated copyright year 2018-10-13 18:20:31 +02:00
testrunner.vcxproj Export interfaces from cppcheck-core.dll used from testrunner. In turn remove ctu sources from testrunner which are obsolete now. 2018-12-28 23:09:44 +01:00
testrunner.vcxproj.filters Export interfaces from cppcheck-core.dll used from testrunner. In turn remove ctu sources from testrunner which are obsolete now. 2018-12-28 23:09:44 +01:00
testsamples.cpp Use OVERRIDE in test 2019-01-12 15:45:25 +01:00
testsimplifytemplate.cpp template simplifier: fix missing instantiation (#1627) 2019-01-26 07:08:54 +01:00
testsimplifytokens.cpp Use OVERRIDE in test 2019-01-12 15:45:25 +01:00
testsimplifytypedef.cpp Use OVERRIDE in test 2019-01-12 15:45:25 +01:00
testsizeof.cpp Use OVERRIDE in test 2019-01-12 15:45:25 +01:00
teststl.cpp Use OVERRIDE in test 2019-01-12 15:45:25 +01:00
teststring.cpp Use OVERRIDE in test 2019-01-12 15:45:25 +01:00
testsuite.cpp Fix Cppcheck warning 2019-01-12 19:10:59 +01:00
testsuite.h Introduce macro OVERRIDE for gcc-4.6 compatibility. 2019-01-12 07:37:42 +01:00
testsuppressions.cpp Use OVERRIDE in test 2019-01-12 15:45:25 +01:00
testsymboldatabase.cpp Use OVERRIDE in test 2019-01-12 15:45:25 +01:00
testthreadexecutor.cpp Use OVERRIDE in test 2019-01-12 15:45:25 +01:00
testtimer.cpp Use OVERRIDE in test 2019-01-12 15:45:25 +01:00
testtoken.cpp Use OVERRIDE in test 2019-01-12 15:45:25 +01:00
testtokenize.cpp Use OVERRIDE in test 2019-01-12 15:45:25 +01:00
testtokenlist.cpp Use OVERRIDE in test 2019-01-12 15:45:25 +01:00
testtype.cpp Use OVERRIDE in test 2019-01-12 15:45:25 +01:00
testuninitvar.cpp Use OVERRIDE in test 2019-01-12 15:45:25 +01:00
testunusedfunctions.cpp Use OVERRIDE in test 2019-01-12 15:45:25 +01:00
testunusedprivfunc.cpp Use OVERRIDE in test 2019-01-12 15:45:25 +01:00
testunusedvar.cpp Fixed #8948 (False Positive: Variable 'n' is assigned a value that is never used.) 2019-01-26 21:44:07 +01:00
testutils.h Introduce macro OVERRIDE for gcc-4.6 compatibility. 2019-01-12 07:37:42 +01:00
testvaarg.cpp Use OVERRIDE in test 2019-01-12 15:45:25 +01:00
testvalueflow.cpp Run astyle 2019-01-12 21:51:39 +01:00
testvarid.cpp Fix Cppcheck warning 2019-01-12 19:11:18 +01:00