Fixed #8618 (False positive: shared_ptr is passed by reference by intention)

This commit is contained in:
Daniel Marjamäki 2018-06-07 22:39:21 +02:00
parent cb2880e7c1
commit de09c117bf
2 changed files with 4 additions and 1 deletions

View File

@ -1427,7 +1427,7 @@ void CheckOther::checkPassByReference()
const Token* const tok = var->typeStartToken();
if (var->isStlStringType()) {
;
} else if (var->isStlType() && Token::Match(tok, "std :: %type% <") && !Token::simpleMatch(tok->linkAt(3), "> ::") && !Token::Match(tok->tokAt(2), "initializer_list|weak_ptr|auto_ptr|unique_ptr")) {
} else if (var->isStlType() && Token::Match(tok, "std :: %type% <") && !Token::simpleMatch(tok->linkAt(3), "> ::") && !Token::Match(tok->tokAt(2), "initializer_list|weak_ptr|auto_ptr|unique_ptr|shared_ptr")) {
;
} else if (var->type() && !var->type()->isEnumType()) { // Check if type is a struct or class.
// Ensure that it is a large object.

View File

@ -1378,6 +1378,9 @@ private:
check("void f(std::unique_ptr<std::string> ptr) {}");
ASSERT_EQUALS("", errout.str());
check("void f(const std::shared_ptr<std::string> ptr) {}");
ASSERT_EQUALS("", errout.str());
check("void f(const std::string::size_type x) {}");
ASSERT_EQUALS("", errout.str());