ValueFlow; Refactoring
This commit is contained in:
parent
30bc67c691
commit
96ff57e275
|
@ -3439,7 +3439,7 @@ static void valueFlowForwardLifetime(Token * tok, TokenList *tokenlist, ErrorLog
|
||||||
|
|
||||||
const Token* endOfVarScope = nullptr;
|
const Token* endOfVarScope = nullptr;
|
||||||
if (var && var->isLocal())
|
if (var && var->isLocal())
|
||||||
endOfVarScope = var->typeStartToken()->scope()->bodyEnd;
|
endOfVarScope = var->scope()->bodyEnd;
|
||||||
else
|
else
|
||||||
endOfVarScope = tok->scope()->bodyEnd;
|
endOfVarScope = tok->scope()->bodyEnd;
|
||||||
|
|
||||||
|
@ -3489,9 +3489,7 @@ static void valueFlowForwardLifetime(Token * tok, TokenList *tokenlist, ErrorLog
|
||||||
// Variable
|
// Variable
|
||||||
} else if (tok->variable()) {
|
} else if (tok->variable()) {
|
||||||
const Variable *var = tok->variable();
|
const Variable *var = tok->variable();
|
||||||
if (!var->typeStartToken() || !var->typeStartToken()->scope())
|
const Token *endOfVarScope = var->scope()->bodyEnd;
|
||||||
return;
|
|
||||||
const Token *endOfVarScope = var->typeStartToken()->scope()->bodyEnd;
|
|
||||||
|
|
||||||
std::list<ValueFlow::Value> values = tok->values();
|
std::list<ValueFlow::Value> values = tok->values();
|
||||||
const Token *nextExpression = nextAfterAstRightmostLeaf(parent);
|
const Token *nextExpression = nextAfterAstRightmostLeaf(parent);
|
||||||
|
@ -4082,7 +4080,7 @@ static void valueFlowAfterMove(TokenList *tokenlist, SymbolDatabase* symboldatab
|
||||||
if (!var || (!var->isLocal() && !var->isArgument()))
|
if (!var || (!var->isLocal() && !var->isArgument()))
|
||||||
continue;
|
continue;
|
||||||
const int varId = varTok->varId();
|
const int varId = varTok->varId();
|
||||||
const Token * const endOfVarScope = var->typeStartToken()->scope()->bodyEnd;
|
const Token * const endOfVarScope = var->scope()->bodyEnd;
|
||||||
setTokenValue(varTok, value, settings);
|
setTokenValue(varTok, value, settings);
|
||||||
valueFlowForwardVariable(
|
valueFlowForwardVariable(
|
||||||
varTok->next(), endOfVarScope, var, varId, values, false, false, tokenlist, errorLogger, settings);
|
varTok->next(), endOfVarScope, var, varId, values, false, false, tokenlist, errorLogger, settings);
|
||||||
|
@ -4106,7 +4104,7 @@ static void valueFlowAfterMove(TokenList *tokenlist, SymbolDatabase* symboldatab
|
||||||
const Variable *var = varTok->variable();
|
const Variable *var = varTok->variable();
|
||||||
if (!var)
|
if (!var)
|
||||||
continue;
|
continue;
|
||||||
const Token * const endOfVarScope = var->typeStartToken()->scope()->bodyEnd;
|
const Token * const endOfVarScope = var->scope()->bodyEnd;
|
||||||
|
|
||||||
ValueFlow::Value value;
|
ValueFlow::Value value;
|
||||||
value.valueType = ValueFlow::Value::ValueType::MOVED;
|
value.valueType = ValueFlow::Value::ValueType::MOVED;
|
||||||
|
@ -4144,7 +4142,7 @@ static void valueFlowForwardAssign(Token * const tok,
|
||||||
ErrorLogger * const errorLogger,
|
ErrorLogger * const errorLogger,
|
||||||
const Settings * const settings)
|
const Settings * const settings)
|
||||||
{
|
{
|
||||||
const Token * const endOfVarScope = var->nameToken()->scope()->bodyEnd;
|
const Token * const endOfVarScope = var->scope()->bodyEnd;
|
||||||
if (std::any_of(values.begin(), values.end(), std::mem_fn(&ValueFlow::Value::isLifetimeValue))) {
|
if (std::any_of(values.begin(), values.end(), std::mem_fn(&ValueFlow::Value::isLifetimeValue))) {
|
||||||
valueFlowForwardLifetime(tok, tokenlist, errorLogger, settings);
|
valueFlowForwardLifetime(tok, tokenlist, errorLogger, settings);
|
||||||
values.remove_if(std::mem_fn(&ValueFlow::Value::isLifetimeValue));
|
values.remove_if(std::mem_fn(&ValueFlow::Value::isLifetimeValue));
|
||||||
|
@ -4932,7 +4930,7 @@ static void valueFlowForLoopSimplifyAfter(Token *fortok, nonneg int varid, const
|
||||||
const Variable *var = vartok->variable();
|
const Variable *var = vartok->variable();
|
||||||
const Token *endToken = nullptr;
|
const Token *endToken = nullptr;
|
||||||
if (var->isLocal())
|
if (var->isLocal())
|
||||||
endToken = var->typeStartToken()->scope()->bodyEnd;
|
endToken = var->scope()->bodyEnd;
|
||||||
else
|
else
|
||||||
endToken = fortok->scope()->bodyEnd;
|
endToken = fortok->scope()->bodyEnd;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue