cppcheck/lib
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
..
CMakeLists.txt Fixed #7660 (cmake build does not handle simplecpp) 2016-08-06 18:21:54 +02:00
analyzerinfo.cpp Fix Cppcheck shadow variable warning 2018-11-03 19:41:25 +01:00
analyzerinfo.h Updated copyright year 2018-10-13 18:20:31 +02:00
astutils.cpp Fixed #8949 (False Positive: Variable 'f' is assigned a value that is never used.) 2019-01-22 21:16:27 +01:00
astutils.h ValueFlow: better FwdAnalysis for complex expressions 2019-01-01 18:23:47 +01:00
check.cpp Updated copyright year 2018-10-13 18:20:31 +02:00
check.h 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
check64bit.cpp Rename _tokenizer, _settings, _errorLogger 2018-06-16 16:10:28 +02:00
check64bit.h Introduce macro OVERRIDE for gcc-4.6 compatibility. 2019-01-12 07:37:42 +01:00
checkassert.cpp Patch assert warning lib/checkassert.cpp (#1543) 2018-12-28 15:25:22 +01:00
checkassert.h Introduce macro OVERRIDE for gcc-4.6 compatibility. 2019-01-12 07:37:42 +01:00
checkautovariables.cpp Lifetime: Support analysis with functions that do not return a reference (#1632) 2019-01-29 09:47:52 +01:00
checkautovariables.h Extend lifetime checking for references 2019-01-23 07:29:16 +01:00
checkbool.cpp Use functions instead of comparing with enum (#1471) 2018-11-09 06:30:41 +01:00
checkbool.h Introduce macro OVERRIDE for gcc-4.6 compatibility. 2019-01-12 07:37:42 +01:00
checkboost.cpp Rename _tokenizer, _settings, _errorLogger 2018-06-16 16:10:28 +02:00
checkboost.h Introduce macro OVERRIDE for gcc-4.6 compatibility. 2019-01-12 07:37:42 +01:00
checkbufferoverrun.cpp CTU: Refactoring 2018-12-25 21:11:23 +01:00
checkbufferoverrun.h Introduce macro OVERRIDE for gcc-4.6 compatibility. 2019-01-12 07:37:42 +01:00
checkclass.cpp Replace "virtual method" with "virtual function" in messages. 2019-01-15 06:22:14 +01:00
checkclass.h Replace "virtual method" with "virtual function" in messages. 2019-01-15 06:22:14 +01:00
checkcondition.cpp Add a check for duplicate if statements 2019-01-09 20:41:01 +01:00
checkcondition.h Introduce macro OVERRIDE for gcc-4.6 compatibility. 2019-01-12 07:37:42 +01:00
checkexceptionsafety.cpp Refactoring; Use range for loops 2018-07-14 09:49:03 +02:00
checkexceptionsafety.h Introduce macro OVERRIDE for gcc-4.6 compatibility. 2019-01-12 07:37:42 +01:00
checkfunctions.cpp Fix false positive: Invalid string argument with array (#1439) 2018-10-19 07:48:47 +02:00
checkfunctions.h Introduce macro OVERRIDE for gcc-4.6 compatibility. 2019-01-12 07:37:42 +01:00
checkinternal.cpp rephraze internal warning 2019-01-13 12:12:07 +01:00
checkinternal.h Introduce macro OVERRIDE for gcc-4.6 compatibility. 2019-01-12 07:37:42 +01:00
checkio.cpp checkio: Add missing id "invalidScanfFormatWidth_smaller" to errorlist output (#1533) 2018-12-20 21:14:02 +01:00
checkio.h Introduce macro OVERRIDE for gcc-4.6 compatibility. 2019-01-12 07:37:42 +01:00
checkleakautovar.cpp Fixed #8392 (false positive: "Memory leak" with malloc in if) 2019-01-27 10:27:44 +01:00
checkleakautovar.h Introduce macro OVERRIDE for gcc-4.6 compatibility. 2019-01-12 07:37:42 +01:00
checkmemoryleak.cpp Fixed #8116 ([False positive] Invalid memory leak detection when using reference.) 2019-01-09 20:38:32 +01:00
checkmemoryleak.h Introduce macro OVERRIDE for gcc-4.6 compatibility. 2019-01-12 07:37:42 +01:00
checknullpointer.cpp CheckNullPointer: Try to report all CTU issues not just the first found issue 2018-12-31 07:52:14 +01:00
checknullpointer.h Fix Cppcheck missingOverride warnings 2019-01-13 13:22:36 +01:00
checkother.cpp Use valueflow in unsigned less than zero checker (#1630) 2019-01-31 09:30:29 +01:00
checkother.h Use valueflow in unsigned less than zero checker (#1630) 2019-01-31 09:30:29 +01:00
checkpostfixoperator.cpp Refactoring: Use ranged for loop 2018-07-13 16:50:12 +02:00
checkpostfixoperator.h Introduce macro OVERRIDE for gcc-4.6 compatibility. 2019-01-12 07:37:42 +01:00
checksizeof.cpp Use for arithOperationsOnVoidPointer messages 2018-09-26 17:58:22 +02:00
checksizeof.h Introduce macro OVERRIDE for gcc-4.6 compatibility. 2019-01-12 07:37:42 +01:00
checkstl.cpp CTU: Reuse CheckNullPointer::isPointerDeRef in the nullpointer isUnsafeUsage 2018-12-29 09:26:57 +01:00
checkstl.h Introduce macro OVERRIDE for gcc-4.6 compatibility. 2019-01-12 07:37:42 +01:00
checkstring.cpp Use functions instead of comparing with enum (#1471) 2018-11-09 06:30:41 +01:00
checkstring.h Introduce macro OVERRIDE for gcc-4.6 compatibility. 2019-01-12 07:37:42 +01:00
checktype.cpp Clarify warning 2018-12-23 12:42:18 +01:00
checktype.h Introduce macro OVERRIDE for gcc-4.6 compatibility. 2019-01-12 07:37:42 +01:00
checkuninitvar.cpp Fix inline suppression. 2019-01-13 12:10:26 +01:00
checkuninitvar.h Fix Cppcheck missingOverride warnings 2019-01-13 13:22:36 +01:00
checkunusedfunctions.cpp CTU: Refactoring 2018-12-25 21:11:23 +01:00
checkunusedfunctions.h Introduce macro OVERRIDE for gcc-4.6 compatibility. 2019-01-12 07:37:42 +01:00
checkunusedvar.cpp Fixed #8948 (False Positive: Variable 'n' is assigned a value that is never used.) 2019-01-26 21:44:07 +01:00
checkunusedvar.h Introduce macro OVERRIDE for gcc-4.6 compatibility. 2019-01-12 07:37:42 +01:00
checkvaarg.cpp Fix 8124: False positive va_end missing with lambda (#1577) 2019-01-10 18:32:17 +01:00
checkvaarg.h Introduce macro OVERRIDE for gcc-4.6 compatibility. 2019-01-12 07:37:42 +01:00
config.h Travis: Enable missingOverride checker 2019-01-13 12:21:01 +01:00
cppcheck.cpp Fixed #7203 (Better syntax error, handle array declaration with @) 2019-01-01 09:45:41 +01:00
cppcheck.h Introduce macro OVERRIDE for gcc-4.6 compatibility. 2019-01-12 07:37:42 +01:00
cppcheck.natvis Fixed Visual Studio Natvis file after recent refactoring (#1299) 2018-07-09 08:27:26 +02:00
cppcheck.vcxproj Add ctu sources to VS projects 2018-12-27 22:11:40 +01:00
cppcheck.vcxproj.filters Add ctu sources to VS projects 2018-12-27 22:11:40 +01:00
ctu.cpp Fix inline suppression. 2019-01-13 12:10:26 +01:00
ctu.h Introduce macro OVERRIDE for gcc-4.6 compatibility. 2019-01-12 07:37:42 +01:00
errorlogger.cpp Fix return value from ErrorLogger::reportUnmatchedSuppressions 2019-01-22 06:45:22 +01:00
errorlogger.h Correct exit code when there are no unmatched suppressions 2019-01-21 20:33:22 +01:00
importproject.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
importproject.h Json: Use simple json library picojson to read compile databases 2019-01-05 17:45:07 +01:00
lib.pri CTU: Refactoring 2018-12-25 21:11:23 +01:00
library.cpp library.cpp: Let tinyxml2 print a helpful error message when XML is bad (#1609) 2019-01-18 17:10:41 +01:00
library.h Rename Library::isargvalid() 2018-07-15 23:05:48 +02:00
matchcompiler.h
mathlib.cpp Correct detection of Microsoft extensions in MathLib::isValidIntegerSuffix. Remove public overloaded implementation which was not used outside mathlib.cpp. (#1531) 2018-12-20 12:20:31 +01:00
mathlib.h Correct detection of Microsoft extensions in MathLib::isValidIntegerSuffix. Remove public overloaded implementation which was not used outside mathlib.cpp. (#1531) 2018-12-20 12:20:31 +01:00
path.cpp Fixed #8563 (CPPCheck not able to locate file through compilation database) 2019-01-05 23:11:43 +01:00
path.h Fixed #8563 (CPPCheck not able to locate file through compilation database) 2019-01-05 23:11:43 +01:00
pathmatch.cpp Updated copyright year 2018-10-13 18:20:31 +02:00
pathmatch.h Updated copyright year 2018-10-13 18:20:31 +02:00
pcrerules.pri
platform.cpp Updated copyright year 2018-03-31 20:59:09 +02:00
platform.h Fix Cppcheck error message 2018-10-20 15:28:34 +02:00
preprocessor.cpp Remove inline suppression and fix false positive. 2019-01-13 07:59:41 +01:00
preprocessor.h Renamed private member file0 2018-06-17 09:06:16 +02:00
settings.cpp template simplifier: add cli --debug-template option to print the parsed template information (#1598) 2019-01-14 08:29:32 +01:00
settings.h template simplifier: add cli --debug-template option to print the parsed template information (#1598) 2019-01-14 08:29:32 +01:00
standards.h Updated copyright year 2018-01-14 15:37:52 +01:00
suppressions.cpp Suppressions: Handle comment in file that starts with # 2019-01-12 15:21:47 +01:00
suppressions.h suppressions: Avoid duplicate comparison. 2018-10-04 17:13:11 +02:00
symboldatabase.cpp Extend lifetime checking for references 2019-01-23 07:29:16 +01:00
symboldatabase.h Extend lifetime checking for references 2019-01-23 07:29:16 +01:00
templatesimplifier.cpp template simplifier: add forward declaration map to debug output (#1629) 2019-01-27 07:46:27 +01:00
templatesimplifier.h template simplifier: add forward declaration map to debug output (#1629) 2019-01-27 07:46:27 +01:00
timer.cpp Rename private member variables 2018-06-17 17:20:16 +02:00
timer.h Fix Cppcheck missingOverride warnings 2019-01-13 13:22:36 +01:00
token.cpp Fix Token::findExpressionStartEndTokens() regression 2019-01-20 13:23:19 +01:00
token.h Replace std::set::emplace with std::set::insert to make Cppcheck compilable in Slackware 14.0 2019-01-05 18:18:15 +01:00
tokenize.cpp Fixed #7417 ("syntax error" in valid code containing explicitly specialised variable template) (#1604) 2019-01-18 21:12:39 +01:00
tokenize.h Improve syntax errors for unmatched (){}[] 2019-01-05 11:56:21 +01:00
tokenlist.cpp Optimization: Removed unnecessary calls to simplifyPath(). The Caller should do this, and our callers (mainly the test suite) more or less do so, as they all supply just dummy paths ("test.cpp") 2018-12-18 20:33:45 +01:00
tokenlist.h relative paths: show {code} properly when there are relative paths 2018-11-18 16:08:08 +01:00
utils.h Revert "Refactoring endsWith utility function" 2018-07-25 16:14:43 +02:00
valueflow.cpp Lifetime: Support analysis with functions that do not return a reference (#1632) 2019-01-29 09:47:52 +01:00
valueflow.h astyle formatting 2019-01-29 09:48:18 +01:00
version.h Set version to 1.86.99/1.87 dev 2018-12-08 11:53:37 +01:00
version.rc