passedByReference: avoid false positives for std::pair
This commit is contained in:
parent
44c78d1770
commit
84f0a18053
|
@ -1427,7 +1427,7 @@ void CheckOther::checkPassByReference()
|
||||||
const Token* const tok = var->typeStartToken();
|
const Token* const tok = var->typeStartToken();
|
||||||
if (var->isStlStringType()) {
|
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|shared_ptr|function")) {
|
} 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|function|pair")) {
|
||||||
;
|
;
|
||||||
} else if (var->type() && !var->type()->isEnumType()) { // Check if type is a struct or class.
|
} else if (var->type() && !var->type()->isEnumType()) { // Check if type is a struct or class.
|
||||||
// Ensure that it is a large object.
|
// Ensure that it is a large object.
|
||||||
|
|
|
@ -1384,6 +1384,14 @@ private:
|
||||||
check("void f(const std::function<F> ptr) {}");
|
check("void f(const std::function<F> ptr) {}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
{
|
||||||
|
check("void f(const std::pair<int,int> x) {}");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
check("void f(const std::pair<std::string,std::string> x) {}");
|
||||||
|
TODO_ASSERT_EQUALS("error", "", errout.str());
|
||||||
|
}
|
||||||
|
|
||||||
check("void f(const std::string::size_type x) {}");
|
check("void f(const std::string::size_type x) {}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue