ValueFlow: Fix FP when lambda is called
This commit is contained in:
parent
7c47283e6d
commit
f5a94ed300
|
@ -1880,10 +1880,10 @@ static bool valueFlowForward(Token * const startToken,
|
|||
|
||||
// skip lambda functions
|
||||
// TODO: handle lambda functions
|
||||
if (Token::simpleMatch(tok2, "= [")) {
|
||||
Token *lambdaEndToken = const_cast<Token *>(findLambdaEndToken(tok2->next()));
|
||||
if (tok2->str() == "[" && findLambdaEndToken(tok2)) {
|
||||
Token *lambdaEndToken = const_cast<Token *>(findLambdaEndToken(tok2));
|
||||
// Dont skip lambdas for lifetime values
|
||||
if (lambdaEndToken && !std::all_of(values.begin(), values.end(), std::mem_fn(&ValueFlow::Value::isLifetimeValue))) {
|
||||
if (!std::all_of(values.begin(), values.end(), std::mem_fn(&ValueFlow::Value::isLifetimeValue))) {
|
||||
tok2 = lambdaEndToken;
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -1431,6 +1431,16 @@ private:
|
|||
"}\n";
|
||||
ASSERT_EQUALS(false, testValueOfX(code, 4U, 0));
|
||||
|
||||
code = "void f() {\n"
|
||||
" int x = 0;\n"
|
||||
" dostuff([&]() {\n"
|
||||
" if (x > 0) {}\n"
|
||||
" x++;\n"
|
||||
" });\n"
|
||||
" dosomething(q);\n"
|
||||
"}\n";
|
||||
ASSERT_EQUALS(false, testValueOfX(code, 4U, 0));
|
||||
|
||||
// ?:
|
||||
code = "void f() {\n"
|
||||
" int x = 8;\n"
|
||||
|
|
Loading…
Reference in New Issue