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
fa076598ade8a751ad85d5375bc976439e32c117, 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
..
2017-06-05 13:23:00 +02:00
2018-01-14 15:37:52 +01:00
2018-01-14 15:37:52 +01:00
2018-01-14 15:37:52 +01:00
2019-01-12 15:45:25 +01:00
2019-01-12 15:45:25 +01:00
2019-01-12 15:45:25 +01:00
2019-01-12 15:45:25 +01:00
2019-01-12 15:45:25 +01:00
2019-01-12 15:45:25 +01:00
2019-01-12 15:45:25 +01:00
2019-01-12 15:45:25 +01:00
2019-01-12 15:45:25 +01:00
2019-01-12 15:45:25 +01:00
2019-01-12 15:45:25 +01:00
2019-01-12 15:45:25 +01:00
2019-01-12 15:45:25 +01:00
2019-01-12 15:45:25 +01:00
2019-01-12 15:45:25 +01:00
2019-01-12 15:45:25 +01:00
2019-01-12 15:45:25 +01:00
2019-01-12 15:45:25 +01:00
2019-01-12 21:51:39 +01:00
2019-01-12 15:45:25 +01:00
2019-01-12 15:45:25 +01:00
2019-01-12 15:45:25 +01:00
2019-01-12 15:45:25 +01:00
2019-01-12 15:45:25 +01:00
2019-01-12 15:45:25 +01:00
2018-10-13 18:20:31 +02:00
2019-01-12 15:45:25 +01:00
2019-01-12 15:45:25 +01:00
2019-01-12 15:45:25 +01:00
2019-01-12 15:45:25 +01:00
2019-01-12 15:45:25 +01:00
2019-01-12 15:45:25 +01:00
2019-01-12 19:10:59 +01:00
2019-01-12 15:45:25 +01:00
2019-01-12 15:45:25 +01:00
2019-01-12 15:45:25 +01:00
2019-01-12 15:45:25 +01:00
2019-01-12 15:45:25 +01:00
2019-01-12 15:45:25 +01:00
2019-01-12 15:45:25 +01:00
2019-01-12 15:45:25 +01:00
2019-01-12 15:45:25 +01:00
2019-01-12 15:45:25 +01:00
2019-01-12 15:45:25 +01:00
2019-01-12 15:45:25 +01:00
2019-01-12 21:51:39 +01:00
2019-01-12 19:11:18 +01:00