Fixed #5922 (FP: passedByValue for std::string::value_type)
This commit is contained in:
parent
6c44c20183
commit
2cc31acabb
|
@ -1978,7 +1978,7 @@ void CheckOther::checkConstantFunctionParameter()
|
||||||
// namespace and add them to the pattern. There are
|
// namespace and add them to the pattern. There are
|
||||||
// streams for example (however it seems strange with
|
// streams for example (however it seems strange with
|
||||||
// const stream parameter).
|
// const stream parameter).
|
||||||
if (Token::Match(tok, "std :: string|wstring")) {
|
if (Token::Match(tok, "std :: string|wstring !!::")) {
|
||||||
passedByValueError(tok, var->name());
|
passedByValueError(tok, var->name());
|
||||||
} else if (Token::Match(tok, "std :: %type% <") && !Token::simpleMatch(tok->linkAt(3), "> ::")) {
|
} else if (Token::Match(tok, "std :: %type% <") && !Token::simpleMatch(tok->linkAt(3), "> ::")) {
|
||||||
passedByValueError(tok, var->name());
|
passedByValueError(tok, var->name());
|
||||||
|
|
|
@ -1577,6 +1577,9 @@ private:
|
||||||
testPassedByValue("void f(const std::string str) {}");
|
testPassedByValue("void f(const std::string str) {}");
|
||||||
ASSERT_EQUALS("[test.cpp:1]: (performance) Function parameter 'str' should be passed by reference.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:1]: (performance) Function parameter 'str' should be passed by reference.\n", errout.str());
|
||||||
|
|
||||||
|
testPassedByValue("void f(const std::string::size_type x) {}");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
testPassedByValue("class Foo;\nvoid f(const Foo foo) {}");
|
testPassedByValue("class Foo;\nvoid f(const Foo foo) {}");
|
||||||
ASSERT_EQUALS("[test.cpp:2]: (performance) Function parameter 'foo' should be passed by reference.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:2]: (performance) Function parameter 'foo' should be passed by reference.\n", errout.str());
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue