Fixed false positive: Return value of std::remove() ignored when std::remove(char*) is called (#4093)
This commit is contained in:
parent
263e13e924
commit
671f1b83d9
|
@ -1340,7 +1340,7 @@ void CheckStl::uselessCalls()
|
||||||
uselessCallsSubstrError(tok, true);
|
uselessCallsSubstrError(tok, true);
|
||||||
} else if (Token::Match(tok, "[{}:;] %var% . empty ( ) ;") && style)
|
} else if (Token::Match(tok, "[{}:;] %var% . empty ( ) ;") && style)
|
||||||
uselessCallsEmptyError(tok->next());
|
uselessCallsEmptyError(tok->next());
|
||||||
else if (Token::Match(tok, "[{};] std :: remove ("))
|
else if (Token::Match(tok, "[{};] std :: remove (") && tok->tokAt(5)->nextArgument())
|
||||||
uselessCallsRemoveError(tok->next());
|
uselessCallsRemoveError(tok->next());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1941,6 +1941,7 @@ private:
|
||||||
" std::remove(a.begin(), a.end(), val);\n"
|
" std::remove(a.begin(), a.end(), val);\n"
|
||||||
" x = std::remove(a.begin(), a.end(), val);\n"
|
" x = std::remove(a.begin(), a.end(), val);\n"
|
||||||
" a.erase(std::remove(a.begin(), a.end(), val));\n"
|
" a.erase(std::remove(a.begin(), a.end(), val));\n"
|
||||||
|
" std::remove(\"foo.txt\");\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("[test.cpp:2]: (warning) Return value of std::remove() ignored. Elements remain in container.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:2]: (warning) Return value of std::remove() ignored. Elements remain in container.\n", errout.str());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue