This commit is contained in:
parent
f4d18a8d1e
commit
26ba29c303
|
@ -3052,7 +3052,7 @@ const Token* getIteratorExpression(const Token* tok)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isIteratorPair(std::vector<const Token*> args)
|
bool isIteratorPair(const std::vector<const Token*>& args)
|
||||||
{
|
{
|
||||||
if (args.size() != 2)
|
if (args.size() != 2)
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -393,7 +393,7 @@ const Token* getIteratorExpression(const Token* tok);
|
||||||
/**
|
/**
|
||||||
* Are the arguments a pair of iterators/pointers?
|
* Are the arguments a pair of iterators/pointers?
|
||||||
*/
|
*/
|
||||||
bool isIteratorPair(std::vector<const Token*> args);
|
bool isIteratorPair(const std::vector<const Token*>& args);
|
||||||
|
|
||||||
CPPCHECKLIB const Token *findLambdaStartToken(const Token *last);
|
CPPCHECKLIB const Token *findLambdaStartToken(const Token *last);
|
||||||
|
|
||||||
|
|
|
@ -1281,27 +1281,11 @@ static bool canBeConst(const Variable *var, const Settings* settings)
|
||||||
if (parent->str() == ">>" && parent->astOperand2() == tok2)
|
if (parent->str() == ">>" && parent->astOperand2() == tok2)
|
||||||
return false;
|
return false;
|
||||||
} else if (parent->str() == "," || parent->str() == "(") { // function argument
|
} else if (parent->str() == "," || parent->str() == "(") { // function argument
|
||||||
const Token* tok3 = tok2->previous();
|
int argNr = -1;
|
||||||
int argNr = 0;
|
const Token* functionTok = getTokenArgumentFunction(tok2, argNr);
|
||||||
while (tok3 && tok3->str() != "(") {
|
|
||||||
if (tok3->link() && Token::Match(tok3, ")|]|}|>"))
|
|
||||||
tok3 = tok3->link();
|
|
||||||
else if (tok3->link())
|
|
||||||
break;
|
|
||||||
else if (tok3->str() == ";")
|
|
||||||
break;
|
|
||||||
else if (tok3->str() == ",")
|
|
||||||
argNr++;
|
|
||||||
tok3 = tok3->previous();
|
|
||||||
}
|
|
||||||
if (!tok3 || tok3->str() != "(")
|
|
||||||
return false;
|
|
||||||
const Token* functionTok = tok3->astOperand1();
|
|
||||||
if (!functionTok)
|
if (!functionTok)
|
||||||
return false;
|
return false;
|
||||||
const Function* tokFunction = functionTok->function();
|
const Function* tokFunction = functionTok->function();
|
||||||
if (!tokFunction && functionTok->str() == "." && (functionTok = functionTok->astOperand2()))
|
|
||||||
tokFunction = functionTok->function();
|
|
||||||
if (tokFunction) {
|
if (tokFunction) {
|
||||||
const Variable* argVar = tokFunction->getArgumentVar(argNr);
|
const Variable* argVar = tokFunction->getArgumentVar(argNr);
|
||||||
if (!argVar || (!argVar->isConst() && argVar->isReference()))
|
if (!argVar || (!argVar->isConst() && argVar->isReference()))
|
||||||
|
|
|
@ -4280,7 +4280,7 @@ static bool hasBorrowingVariables(const std::list<Variable>& vars, const std::ve
|
||||||
static void valueFlowLifetimeUserConstructor(Token* tok,
|
static void valueFlowLifetimeUserConstructor(Token* tok,
|
||||||
const Function* constructor,
|
const Function* constructor,
|
||||||
const std::string& name,
|
const std::string& name,
|
||||||
std::vector<const Token*> args,
|
const std::vector<const Token*>& args,
|
||||||
TokenList& tokenlist,
|
TokenList& tokenlist,
|
||||||
ErrorLogger* errorLogger,
|
ErrorLogger* errorLogger,
|
||||||
const Settings* settings)
|
const Settings* settings)
|
||||||
|
|
|
@ -2159,6 +2159,14 @@ private:
|
||||||
"T::T(std::string s) noexcept(true) : m(std::move(s)) {}\n");
|
"T::T(std::string s) noexcept(true) : m(std::move(s)) {}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
check("namespace N {\n" // #12086
|
||||||
|
" void g(int);\n"
|
||||||
|
"}\n"
|
||||||
|
"void f(std::vector<int> v) {\n"
|
||||||
|
" N::g(v[0]);\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("[test.cpp:4]: (performance) Function parameter 'v' should be passed by const reference.\n", errout.str());
|
||||||
|
|
||||||
Settings settings1 = settingsBuilder().platform(Platform::Type::Win64).build();
|
Settings settings1 = settingsBuilder().platform(Platform::Type::Win64).build();
|
||||||
check("using ui64 = unsigned __int64;\n"
|
check("using ui64 = unsigned __int64;\n"
|
||||||
"ui64 Test(ui64 one, ui64 two) { return one + two; }\n",
|
"ui64 Test(ui64 one, ui64 two) { return one + two; }\n",
|
||||||
|
|
Loading…
Reference in New Issue