From 2cc31acabb10aeb21592ba6ce90110ee79e24376 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Fri, 18 Jul 2014 15:51:59 +0200 Subject: [PATCH] Fixed #5922 (FP: passedByValue for std::string::value_type) --- lib/checkother.cpp | 2 +- test/testother.cpp | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/checkother.cpp b/lib/checkother.cpp index f3d5bbaa8..c88d2d127 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -1978,7 +1978,7 @@ void CheckOther::checkConstantFunctionParameter() // namespace and add them to the pattern. There are // streams for example (however it seems strange with // const stream parameter). - if (Token::Match(tok, "std :: string|wstring")) { + if (Token::Match(tok, "std :: string|wstring !!::")) { passedByValueError(tok, var->name()); } else if (Token::Match(tok, "std :: %type% <") && !Token::simpleMatch(tok->linkAt(3), "> ::")) { passedByValueError(tok, var->name()); diff --git a/test/testother.cpp b/test/testother.cpp index e5a21c0c8..05936db23 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -1577,6 +1577,9 @@ private: testPassedByValue("void f(const std::string 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) {}"); ASSERT_EQUALS("[test.cpp:2]: (performance) Function parameter 'foo' should be passed by reference.\n", errout.str());