Fixed false positive "Parameter 'x' is passed as a value" for types like std::vector<T>::size_type (#3986)

This commit is contained in:
PKEuS 2012-07-23 01:41:20 -07:00
parent a733c9b603
commit ae6201d289
2 changed files with 4 additions and 1 deletions

View File

@ -1741,7 +1741,7 @@ void CheckOther::checkConstantFunctionParameter()
// const stream parameter).
if (Token::Match(tok, "std :: string|wstring")) {
passedByValueError(tok, var->name());
} else if (Token::Match(tok, "std :: %type% <")) {
} else if (Token::Match(tok, "std :: %type% <") && !Token::Match(tok->linkAt(3), "> ::")) {
passedByValueError(tok, var->name());
} else if (var->type() || symbolDatabase->isClassOrStruct(tok->str())) { // Check if type is a struct or class.
passedByValueError(tok, var->name());

View File

@ -969,6 +969,9 @@ private:
testPassedByValue("void f(const std::vector<std::string> v) {}");
ASSERT_EQUALS("[test.cpp:1]: (performance) Function parameter 'v' should be passed by reference.\n", errout.str());
testPassedByValue("void f(const std::vector<std::string>::size_type s) {}");
ASSERT_EQUALS("", errout.str());
testPassedByValue("void f(const std::vector<int> &v) {}");
ASSERT_EQUALS("", errout.str());