From de09c117bffb6614acf0f5a4aec9da7a35e6e598 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Thu, 7 Jun 2018 22:39:21 +0200 Subject: [PATCH] Fixed #8618 (False positive: shared_ptr is passed by reference by intention) --- 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 0409490e1..0ffa71838 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -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. diff --git a/test/testother.cpp b/test/testother.cpp index aa8884ae4..8cbecb852 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -1378,6 +1378,9 @@ private: check("void f(std::unique_ptr ptr) {}"); ASSERT_EQUALS("", errout.str()); + check("void f(const std::shared_ptr ptr) {}"); + ASSERT_EQUALS("", errout.str()); + check("void f(const std::string::size_type x) {}"); ASSERT_EQUALS("", errout.str());