Refactorization: Removed unused functions

This commit is contained in:
PKEuS 2021-02-17 22:44:03 +01:00 committed by Daniel Marjamäki
parent ef82897af5
commit 6a811eec1c
2 changed files with 0 additions and 65 deletions

View File

@ -393,43 +393,6 @@ void CheckAutoVariables::errorUselessAssignmentPtrArg(const Token *tok)
//---------------------------------------------------------------------------
static bool astHasAutoResult(const Token *tok)
{
if (tok->astOperand1() && !astHasAutoResult(tok->astOperand1()))
return false;
if (tok->astOperand2() && !astHasAutoResult(tok->astOperand2()))
return false;
if (tok->isOp()) {
if (tok->tokType() == Token::eIncDecOp)
return false;
if ((tok->str() == "<<" || tok->str() == ">>") && tok->astOperand1()) {
const Token* tok2 = tok->astOperand1();
while (tok2 && tok2->isUnaryOp("*"))
tok2 = tok2->astOperand1();
return tok2 && tok2->variable() && !tok2->variable()->isClass() && !tok2->variable()->isStlType(); // Class or unknown type on LHS: Assume it is a stream
}
return true;
}
if (tok->isLiteral())
return true;
if (tok->isName()) {
// TODO: check function calls, struct members, arrays, etc also
if (!tok->variable())
return false;
if (tok->variable()->isStlType())
return true;
if (tok->variable()->isClass() || tok->variable()->isPointer() || tok->variable()->isReference()) // TODO: Properly handle pointers/references to classes in symbol database
return false;
return true;
}
return false;
}
static bool isInScope(const Token * tok, const Scope * scope)
{
if (!tok)

View File

@ -1567,34 +1567,6 @@ static bool isConditionKnown(const Token* tok, bool then)
return (parent && parent->str() == "(");
}
static void valueFlowAST(Token *tok, nonneg int varid, const ValueFlow::Value &value, const Settings *settings)
{
if (!tok)
return;
if (tok->varId() == varid)
setTokenValue(tok, value, settings);
valueFlowAST(tok->astOperand1(), varid, value, settings);
if (tok->str() == "&&" && tok->astOperand1() && tok->astOperand1()->getValue(0)) {
ProgramMemory pm;
pm.setValue(varid,value);
if (conditionIsFalse(tok->astOperand1(), pm))
return;
} else if (tok->str() == "||" && tok->astOperand1()) {
const std::list<ValueFlow::Value> &values = tok->astOperand1()->values();
const bool nonzero = std::any_of(values.cbegin(), values.cend(),
[=](const ValueFlow::Value &v) {
return v.intvalue != 0;
});
if (!nonzero)
return;
ProgramMemory pm;
pm.setValue(varid,value);
if (conditionIsTrue(tok->astOperand1(), pm))
return;
}
valueFlowAST(tok->astOperand2(), varid, value, settings);
}
static const std::string& invertAssign(const std::string& assign)
{
static std::unordered_map<std::string, std::string> lookup = {