cppcheck/test
Paul Fultz II 091f4bcf8d Add check for unnecessary search before insertion
This will warn for cases where searching in an associative container happens before insertion, like this:

```cpp
void f1(std::set<unsigned>& s, unsigned x) {
    if (s.find(x) == s.end()) {
        s.insert(x);
    }
}

void f2(std::map<unsigned, unsigned>& m, unsigned x) {
    if (m.find(x) == m.end()) {
        m.emplace(x, 1);
    } else {
        m[x] = 1;
    }
}
```

In the case of the map it could be written as `m[x] = 1` as it will create the key if it doesnt exist, so the extra search is not necessary.

I have this marked as `performance` as it is mostly concerning performance, but there could be a copy-paste error possibly, although I dont think thats common.
2019-05-02 11:04:23 +02:00
..
cfg posix.cfg: Improved configuration for close(). Issue a warning in case close is called with a file pointer having a negative value. 2019-04-21 12:28:17 +02:00
cli Revert "Fixed #7999 (Inline suppressions do not work under weird circumstances)" 2019-05-02 06:50:08 +02:00
synthetic Improve Python code 2017-06-05 13:23:00 +02:00
testsuites Typos found by running "codespell" (#1804) 2019-04-23 13:26:48 +02:00
CMakeLists.txt Add a check target to cmake (#1465) 2018-11-05 18:13:04 +01:00
options.cpp Allow multiple test case arguments to testrunner (#1755) 2019-03-26 20:28:40 +01:00
options.h Allow multiple test case arguments to testrunner (#1755) 2019-03-26 20:28:40 +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 Update copyright year 2019-02-09 07:24:06 +01:00
testassert.cpp Moved CheckAssert::assertWithSideEffects to normal checking 2019-03-09 16:50:50 +01:00
testastutils.cpp Adjust more test results for invalid code 2019-04-19 20:53:07 +02:00
testautovariables.cpp Fix bug in lifetime constructors (#1816) 2019-05-01 07:52:52 +02:00
testbool.cpp Fix 8840: Don't warn when returning a bitmask as bool (#1818) 2019-05-02 07:00:27 +02:00
testboost.cpp CheckBoost: Use 'normal' checking 2019-03-09 20:00:31 +01:00
testbufferoverrun.cpp Fixed #9112 (false positive: (error) Array index out of bounds; buffer 'x' is accessed at offset n.) 2019-05-01 13:00:14 +02:00
testcharvar.cpp Remove test case, ValueFlow will truncate and sign-extend values 2019-05-01 19:33:47 +02:00
testclass.cpp Library: Added <smart-pointer> element 2019-04-24 13:06:58 +02:00
testcmdlineparser.cpp Fix compiler errors. After removing the -std=posix. 2019-04-12 10:41:53 +02:00
testcondition.cpp Use multiline in testing 2019-04-28 07:48:38 +02:00
testconstructors.cpp Update copyright year 2019-02-09 07:24:06 +01:00
testcppcheck.cpp Update copyright year 2019-02-09 07:24:06 +01:00
testerrorlogger.cpp Update copyright year 2019-02-09 07:24:06 +01:00
testexceptionsafety.cpp Use 'normal' checking instead of 'simplified' 2019-03-16 07:19:48 +01:00
testfilelister.cpp Update copyright year 2019-02-09 07:24:06 +01:00
testfiles.pri Fixed #8960 ("(debug) Unknown type 'x'." with alias in template class alias) (#1643) 2019-02-05 08:52:23 +01:00
testfunctions.cpp Fix false positive with ignoredReturnValue with std::move (#1809) 2019-04-26 12:22:31 +02:00
testgarbage.cpp Adjust some test results for invalid code. Comment out still crashing example for #8913 2019-04-19 17:42:21 +02:00
testimportproject.cpp astyle formatting 2019-04-16 19:07:44 +02:00
testincompletestatement.cpp Fix FP with unused variable (#1814) 2019-04-29 11:50:19 +02:00
testinternal.cpp CheckInternal: Extend redundant null pointer check before Token::Match() (#1789) 2019-04-06 07:44:44 +02:00
testio.cpp Fix #8992: Add originalTypeToken to auto (#1701) 2019-02-27 06:44:31 +01:00
testleakautovar.cpp CheckLeakAutoVar: Use Library::isSmartPointer() 2019-04-24 15:35:47 +02:00
testlibrary.cpp Library: Enhance minsize configuration and allow simple values. (#1736) 2019-03-17 14:22:26 +01:00
testmathlib.cpp Update copyright year 2019-02-09 07:24:06 +01:00
testmemleak.cpp Fixed #8848 (False positive memory leak if locally defined type returns a new pointer) 2019-04-22 17:37:41 +02:00
testnullpointer.cpp Improve diagnostics with null smart pointers (#1805) 2019-04-26 11:30:09 +02:00
testoptions.cpp Allow multiple test case arguments to testrunner (#1755) 2019-03-26 20:28:40 +01:00
testother.cpp Fixed #9043 (false positive & regression: Variable '*s' is reassigned a value before the old one has been used.) 2019-04-16 19:07:26 +02:00
testpath.cpp Update copyright year 2019-02-09 07:24:06 +01:00
testpathmatch.cpp Update copyright year 2019-02-09 07:24:06 +01:00
testplatform.cpp Update copyright year 2019-02-09 07:24:06 +01:00
testpostfixoperator.cpp Fixed #9042 (Another `using BOOL` type breach) (#1765) 2019-03-27 21:42:50 +01:00
testpreprocessor.cpp Update copyright year 2019-02-09 07:24:06 +01:00
testrunner.cpp Add help to testrunner (#1704) 2019-03-02 08:06:23 +01:00
testrunner.vcxproj Fixed #8960 ("(debug) Unknown type 'x'." with alias in template class alias) (#1643) 2019-02-05 08:52:23 +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 Update copyright year 2019-02-09 07:24:06 +01:00
testsimplifytemplate.cpp partial fix for #8663 (Stack overflow with template disambiguator) (#1801) 2019-04-21 06:46:16 +02:00
testsimplifytokens.cpp simplifyMathExpression: Fix tests 2019-04-09 08:22:41 +02:00
testsimplifytypedef.cpp Fix issue 9006: False positive: Return value of function std::move() is not used. 2019-04-15 06:37:27 +02:00
testsimplifyusing.cpp Fixed #9042 (Another `using BOOL` type breach) (#1765) 2019-03-27 21:42:50 +01:00
testsizeof.cpp sizeof: write inconclusive warning if calculation in sizeof is done indirectly by macro 2019-02-26 21:06:44 +01:00
teststl.cpp Add check for unnecessary search before insertion 2019-05-02 11:04:23 +02:00
teststring.cpp Checkstring fixes (#1783) 2019-04-06 06:54:38 +02:00
testsuite.cpp Fixed Cppcheck shadowVar warnings 2019-04-30 21:01:18 +02:00
testsuite.h Add help to testrunner (#1704) 2019-03-02 08:06:23 +01:00
testsuppressions.cpp Update copyright year 2019-02-09 07:24:06 +01:00
testsymboldatabase.cpp Set wchar_t type (#1807) 2019-05-01 16:34:28 +02:00
testthreadexecutor.cpp Update copyright year 2019-02-09 07:24:06 +01:00
testtimer.cpp Update copyright year 2019-02-09 07:24:06 +01:00
testtoken.cpp TestToken: Add more tests (#1806) 2019-04-25 07:08:13 +02:00
testtokenize.cpp Optimize astStringVerbose() for large arrays (#1815) 2019-04-30 13:35:48 +02:00
testtokenlist.cpp Update copyright year 2019-02-09 07:24:06 +01:00
testtype.cpp Refactoring: Use range based for loops (#1817) 2019-05-02 06:53:07 +02:00
testuninitvar.cpp Uninitialized variables: Fixed false positive 2019-03-09 11:30:45 +01:00
testunusedfunctions.cpp Fixed #8580 (False positive: unused function (lambda)) 2019-04-27 17:17:51 +02:00
testunusedprivfunc.cpp Update copyright year 2019-02-09 07:24:06 +01:00
testunusedvar.cpp Update copyright year 2019-02-09 07:24:06 +01:00
testutils.h Update copyright year 2019-02-09 07:24:06 +01:00
testvaarg.cpp Disable all simplified checks 2019-03-16 09:17:50 +01:00
testvalueflow.cpp Fixed #6317 (wrong simplification: int i = 1.5; return i; get simplified to: return 1.5;) 2019-05-01 17:05:16 +02:00
testvarid.cpp Fixed #8889 (varid on function when using trailing return type.) (#1800) 2019-04-18 20:22:39 +02:00