Do not suggest pass by reference for std::initializer_list

This commit is contained in:
PKEuS 2017-01-19 11:14:55 +01:00
parent 722fac391d
commit 3022d74801
2 changed files with 4 additions and 1 deletions

View File

@ -1455,7 +1455,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), "> ::")) { } else if (var->isStlType() && Token::Match(tok, "std :: %type% <") && !Token::simpleMatch(tok->linkAt(3), "> ::") && tok->strAt(2) != "initializer_list") {
; ;
} 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.

View File

@ -1386,6 +1386,9 @@ private:
check("void f(const std::streamoff pos) {}"); check("void f(const std::streamoff pos) {}");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
check("void f(std::initializer_list<int> i) {}");
ASSERT_EQUALS("", errout.str());
// #5824 // #5824
check("void log(const std::string& file, int line, const std::string& function, const std::string str, ...) {}"); check("void log(const std::string& file, int line, const std::string& function, const std::string str, ...) {}");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());