Fix 11308: FP accessMoved with virtual function (#4478)
* Fix 11308: FP accessMoved with virtual function * Format
This commit is contained in:
parent
d34de745c0
commit
de7d02293f
|
@ -4838,10 +4838,7 @@ static void valueFlowAfterMove(TokenList* tokenlist, SymbolDatabase* symboldatab
|
||||||
continue;
|
continue;
|
||||||
if (parent && parent->astOperand1() && parent->astOperand1()->varId() == varId)
|
if (parent && parent->astOperand1() && parent->astOperand1()->varId() == varId)
|
||||||
continue;
|
continue;
|
||||||
const Variable *var = varTok->variable();
|
const Token* const endOfVarScope = getEndOfExprScope(varTok);
|
||||||
if (!var)
|
|
||||||
continue;
|
|
||||||
const Token * const endOfVarScope = var->scope()->bodyEnd;
|
|
||||||
|
|
||||||
const Token * openParentesisOfMove = findOpenParentesisOfMove(varTok);
|
const Token * openParentesisOfMove = findOpenParentesisOfMove(varTok);
|
||||||
const Token * endOfFunctionCall = findEndOfFunctionCallForParameter(openParentesisOfMove);
|
const Token * endOfFunctionCall = findEndOfFunctionCallForParameter(openParentesisOfMove);
|
||||||
|
|
|
@ -259,6 +259,7 @@ private:
|
||||||
TEST_CASE(moveAndLambda);
|
TEST_CASE(moveAndLambda);
|
||||||
TEST_CASE(moveInLoop);
|
TEST_CASE(moveInLoop);
|
||||||
TEST_CASE(moveCallback);
|
TEST_CASE(moveCallback);
|
||||||
|
TEST_CASE(moveClassVariable);
|
||||||
TEST_CASE(forwardAndUsed);
|
TEST_CASE(forwardAndUsed);
|
||||||
|
|
||||||
TEST_CASE(funcArgNamesDifferent);
|
TEST_CASE(funcArgNamesDifferent);
|
||||||
|
@ -9976,6 +9977,21 @@ private:
|
||||||
ASSERT_EQUALS("[test.cpp:4]: (warning) Access of moved variable 'callback'.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:4]: (warning) Access of moved variable 'callback'.\n", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void moveClassVariable()
|
||||||
|
{
|
||||||
|
check("struct B {\n"
|
||||||
|
" virtual void f();\n"
|
||||||
|
"};\n"
|
||||||
|
"struct D : B {\n"
|
||||||
|
" void f() override {\n"
|
||||||
|
" auto p = std::unique_ptr<D>(new D(std::move(m)));\n"
|
||||||
|
" }\n"
|
||||||
|
" D(std::unique_ptr<int> c) : m(std::move(c)) {}\n"
|
||||||
|
" std::unique_ptr<int> m;\n"
|
||||||
|
"};\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
}
|
||||||
|
|
||||||
void forwardAndUsed() {
|
void forwardAndUsed() {
|
||||||
Settings keepTemplates;
|
Settings keepTemplates;
|
||||||
keepTemplates.checkUnusedTemplates = true;
|
keepTemplates.checkUnusedTemplates = true;
|
||||||
|
|
Loading…
Reference in New Issue