Fix #9815 FP redundantInitialization with lambda / #10864 debug: valueFlowConditionExpressions bailout (#3970)
* Fix #9815 FP redundantInitialization with lambda * Fix #10864 debug: valueFlowConditionExpressions bailout * Format
This commit is contained in:
parent
f5313dc519
commit
4c375e7224
|
@ -3177,6 +3177,12 @@ struct FwdAnalysis::Result FwdAnalysis::checkRecursive(const Token *expr, const
|
||||||
return Result(Result::Type::READ);
|
return Result(Result::Type::READ);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
const auto startEnd = parent->astParent()->astOperand2()->findExpressionStartEndTokens();
|
||||||
|
for (const Token* tok2 = startEnd.first; tok2 != startEnd.second; tok2 = tok2->next()) {
|
||||||
|
if (tok2->tokType() == Token::eLambda)
|
||||||
|
return Result(Result::Type::BAILOUT);
|
||||||
|
// TODO: analyze usage in lambda
|
||||||
|
}
|
||||||
// ({ .. })
|
// ({ .. })
|
||||||
if (hasGccCompoundStatement(parent->astParent()->astOperand2()))
|
if (hasGccCompoundStatement(parent->astParent()->astOperand2()))
|
||||||
return Result(Result::Type::BAILOUT);
|
return Result(Result::Type::BAILOUT);
|
||||||
|
|
|
@ -1432,7 +1432,7 @@ void SymbolDatabase::createSymbolDatabaseIncompleteVars()
|
||||||
if (Token::simpleMatch(tok->next(), ")") && Token::simpleMatch(tok->next()->link()->previous(), "catch ("))
|
if (Token::simpleMatch(tok->next(), ")") && Token::simpleMatch(tok->next()->link()->previous(), "catch ("))
|
||||||
continue;
|
continue;
|
||||||
// Very likely a typelist
|
// Very likely a typelist
|
||||||
if (Token::Match(tok->tokAt(-2), "%type% ,"))
|
if (Token::Match(tok->tokAt(-2), "%type% ,") || Token::Match(tok->next(), ", %type%"))
|
||||||
continue;
|
continue;
|
||||||
// Inside template brackets
|
// Inside template brackets
|
||||||
if (Token::Match(tok->next(), "<|>") && tok->next()->link())
|
if (Token::Match(tok->next(), "<|>") && tok->next()->link())
|
||||||
|
|
|
@ -8104,6 +8104,13 @@ private:
|
||||||
" i = nullptr;\n"
|
" i = nullptr;\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
check("int f(const std::vector<int>& v) {\n" // #9815
|
||||||
|
" int i = g();\n"
|
||||||
|
" i = std::distance(v.begin(), std::find_if(v.begin(), v.end(), [=](int j) { return i == j; }));\n"
|
||||||
|
" return i;\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void redundantMemWrite() {
|
void redundantMemWrite() {
|
||||||
|
|
|
@ -357,6 +357,7 @@ private:
|
||||||
TEST_CASE(symboldatabase96); // #10126
|
TEST_CASE(symboldatabase96); // #10126
|
||||||
TEST_CASE(symboldatabase97); // #10598 - final class
|
TEST_CASE(symboldatabase97); // #10598 - final class
|
||||||
TEST_CASE(symboldatabase98); // #10451
|
TEST_CASE(symboldatabase98); // #10451
|
||||||
|
TEST_CASE(symboldatabase99); // #10864
|
||||||
TEST_CASE(symboldatabase100); // #10174
|
TEST_CASE(symboldatabase100); // #10174
|
||||||
|
|
||||||
TEST_CASE(createSymbolDatabaseFindAllScopes1);
|
TEST_CASE(createSymbolDatabaseFindAllScopes1);
|
||||||
|
@ -4880,6 +4881,11 @@ private:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void symboldatabase99() { // #10864
|
||||||
|
check("void f() { std::map<std::string, int> m; }");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
}
|
||||||
|
|
||||||
void symboldatabase100() {
|
void symboldatabase100() {
|
||||||
{
|
{
|
||||||
GET_SYMBOL_DB("namespace N {\n" // #10174
|
GET_SYMBOL_DB("namespace N {\n" // #10174
|
||||||
|
|
Loading…
Reference in New Issue