diff --git a/lib/checkstl.cpp b/lib/checkstl.cpp index 96f25a533..d25dc614c 100644 --- a/lib/checkstl.cpp +++ b/lib/checkstl.cpp @@ -501,38 +501,6 @@ void CheckStl::stlBoundriesError(const Token *tok, const std::string &container_ -void CheckStl::find() -{ - for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next()) - { - if (tok->str() != ";") - continue; - if (!Token::Match(tok->next(), "%var% = std :: find (")) - continue; - const unsigned int iteratorid = tok->next()->varId(); - if (iteratorid == 0) - continue; - tok = tok->tokAt(6)->link(); - if (!tok) - break; - for (const Token *tok2 = tok; tok2; tok2 = tok2->next()) - { - if (tok2->str() == "{" || tok2->str() == "}" || tok2->str() == "(" || tok2->str() == ")") - break; - if (tok2->varId() == iteratorid && Token::simpleMatch(tok2->previous(), "*")) - findError(tok2); - } - } -} - - -void CheckStl::findError(const Token *tok) -{ - reportError(tok, Severity::error, "stlfind", "dangerous usage of find result"); -} - - - void CheckStl::if_find() { if (!_settings->_checkCodingStyle) diff --git a/lib/checkstl.h b/lib/checkstl.h index ec049fcf8..aac50f3f6 100644 --- a/lib/checkstl.h +++ b/lib/checkstl.h @@ -53,7 +53,6 @@ public: checkStl.erase(); checkStl.pushback(); checkStl.stlBoundries(); - checkStl.find(); checkStl.if_find(); if (settings->_checkCodingStyle) @@ -100,9 +99,6 @@ public: */ void stlBoundries(); - /** usage of std::find - proper handling of return iterator*/ - void find(); - /** if (a.find(x)) - possibly incorrect condition */ void if_find(); @@ -128,7 +124,6 @@ private: void invalidIteratorError(const Token *tok, const std::string &func, const std::string &iterator_name); void invalidPointerError(const Token *tok, const std::string &pointer_name); void stlBoundriesError(const Token *tok, const std::string &container_name); - void findError(const Token *tok); void if_findError(const Token *tok, bool str); void sizeError(const Token *tok); @@ -142,7 +137,6 @@ private: invalidIteratorError(0, "push_back|push_front|insert", "iterator"); invalidPointerError(0, "pointer"); stlBoundriesError(0, "container"); - findError(0); if_findError(0, false); if_findError(0, true); sizeError(0); @@ -161,7 +155,6 @@ private: "* mismatching containers in calls\n" "* dereferencing an erased iterator\n" "* for vectors: using iterator/pointer after push_back has been used\n" - "* dangerous usage of find\n" "* optimisation: use empty() instead of size() to guarantee fast code\n" "* suspicious condition when using find\n"; } diff --git a/test/teststl.cpp b/test/teststl.cpp index aea6a9d61..40484306e 100644 --- a/test/teststl.cpp +++ b/test/teststl.cpp @@ -75,9 +75,6 @@ private: // if (str.find("ab")) TEST_CASE(if_find); - // find - TEST_CASE(find1); - TEST_CASE(size1); } @@ -686,15 +683,6 @@ private: - void find1() - { - check("void f(std::vector &ints)\n" - "{\n" - " std::vector::iterator it = std::find(ints.begin(), ints.end(), 33);\n" - " *it = 11;\n" - "}\n"); - ASSERT_EQUALS("", errout.str()); - } void size1() {