useInitializationList: Skip warning when rhs is a multi line lambda. For readability it might be better to have assignments in constructor in this case.
This commit is contained in:
parent
1ef13f8b06
commit
14a312e310
|
@ -946,6 +946,10 @@ void CheckClass::initializationListUsage()
|
||||||
if (var->isPointer() || var->isReference() || var->isEnumType() || var->valueType()->type > ValueType::Type::ITERATOR)
|
if (var->isPointer() || var->isReference() || var->isEnumType() || var->valueType()->type > ValueType::Type::ITERATOR)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
// bailout: multi line lambda in rhs => do not warn
|
||||||
|
if (findLambdaEndToken(tok->tokAt(2)) && tok->tokAt(2)->findExpressionStartEndTokens().second->linenr() > tok->tokAt(2)->linenr())
|
||||||
|
continue;
|
||||||
|
|
||||||
// Access local var member in rhs => do not warn
|
// Access local var member in rhs => do not warn
|
||||||
bool localmember = false;
|
bool localmember = false;
|
||||||
visitAstNodes(tok->next()->astOperand2(),
|
visitAstNodes(tok->next()->astOperand2(),
|
||||||
|
|
|
@ -6635,6 +6635,17 @@ private:
|
||||||
" }\n"
|
" }\n"
|
||||||
"};");
|
"};");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
// bailout: multi line lambda in rhs => do not warn
|
||||||
|
checkInitializationListUsage("class Fred {\n"
|
||||||
|
" std::function f;\n"
|
||||||
|
" Fred() {\n"
|
||||||
|
" f = [](){\n"
|
||||||
|
" return 1;\n"
|
||||||
|
" };\n"
|
||||||
|
" }\n"
|
||||||
|
"};");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue