No unused variable messages about std::unique_ptr|shared_ptr|auto_ptr (#4355)

This commit is contained in:
PKEuS 2014-08-31 19:18:02 +02:00
parent 78932094c8
commit 8f4662de92
2 changed files with 6 additions and 2 deletions

View File

@ -691,8 +691,7 @@ void CheckUnusedVar::checkFunctionVariableUsage_iterateScopes(const Scope* const
i->typeEndToken()->isStandardType() ||
isRecordTypeWithoutSideEffects(i->type()) ||
(i->isStlType() &&
i->typeStartToken()->strAt(2) != "lock_guard" &&
i->typeStartToken()->strAt(2) != "unique_lock"))
!Token::Match(i->typeStartToken()->tokAt(2), "lock_guard|unique_lock|shared_ptr|unique_ptr|auto_ptr")))
type = Variables::standard;
if (type == Variables::none || isPartOfClassStructUnion(i->typeStartToken()))
continue;

View File

@ -3685,6 +3685,11 @@ private:
"}");
ASSERT_EQUALS("", errout.str());
functionVariableUsage("void f() {\n"
" pLocker = std::shared_ptr<jfxLocker>(new jfxLocker(m_lock, true));\n" // Could have side-effects (#4355)
"}");
ASSERT_EQUALS("", errout.str());
functionVariableUsage("void f() {\n"
" std::mutex m;\n"
" std::unique_lock<std::mutex> lock(m);\n" // #4624