Cleanup: Removed unfinnished checking of std::find
This commit is contained in:
parent
8a8547e6b7
commit
6acb304ef2
|
@ -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)
|
||||
|
|
|
@ -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";
|
||||
}
|
||||
|
|
|
@ -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<int> &ints)\n"
|
||||
"{\n"
|
||||
" std::vector<int>::iterator it = std::find(ints.begin(), ints.end(), 33);\n"
|
||||
" *it = 11;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void size1()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue