enabled and fixed `modernize-use-override` clang-tidy warnings (#4168)
This commit is contained in:
parent
eae164371c
commit
ce945ec7fc
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
Checks: '*,-abseil-*,-altera-*,-android-*,-cert-*,-cppcoreguidelines-*,-fuchsia-*,-google-*,-hicpp-*,-linuxkernel-*,-llvm-*,-llvmlibc-*,-mpi-*,-objc-*,-openmp-*,-zircon-*,-readability-braces-around-statements,-readability-magic-numbers,-bugprone-macro-parentheses,-readability-isolate-declaration,-readability-function-size,-modernize-use-trailing-return-type,-readability-implicit-bool-conversion,-readability-uppercase-literal-suffix,-modernize-use-auto,-readability-else-after-return,-modernize-use-default-member-init,-readability-named-parameter,-readability-redundant-member-init,-performance-faster-string-find,-modernize-avoid-c-arrays,-modernize-use-equals-default,-readability-container-size-empty,-readability-simplify-boolean-expr,-modernize-use-override,-modernize-pass-by-value,-bugprone-branch-clone,-bugprone-narrowing-conversions,-modernize-raw-string-literal,-readability-convert-member-functions-to-static,-modernize-loop-convert,-misc-unused-using-decls,-readability-const-return-type,-performance-unnecessary-value-param,-modernize-return-braced-init-list,-performance-inefficient-string-concatenation,-misc-throw-by-value-catch-by-reference,-readability-avoid-const-params-in-decls,-readability-non-const-parameter,-misc-non-private-member-variables-in-classes,-bugprone-suspicious-string-compare,-clang-analyzer-*,-bugprone-signed-char-misuse,-readability-make-member-function-const,-misc-no-recursion,-readability-use-anyofallof,-performance-no-automatic-move,-bugprone-suspicious-include,-modernize-replace-random-shuffle,-readability-function-cognitive-complexity,-readability-redundant-access-specifiers,-modernize-use-equals-delete,-performance-noexcept-move-constructor,-concurrency-mt-unsafe,-bugprone-easily-swappable-parameters,-readability-suspicious-call-argument,-readability-identifier-length,-readability-container-data-pointer'
|
Checks: '*,-abseil-*,-altera-*,-android-*,-cert-*,-cppcoreguidelines-*,-fuchsia-*,-google-*,-hicpp-*,-linuxkernel-*,-llvm-*,-llvmlibc-*,-mpi-*,-objc-*,-openmp-*,-zircon-*,-readability-braces-around-statements,-readability-magic-numbers,-bugprone-macro-parentheses,-readability-isolate-declaration,-readability-function-size,-modernize-use-trailing-return-type,-readability-implicit-bool-conversion,-readability-uppercase-literal-suffix,-modernize-use-auto,-readability-else-after-return,-modernize-use-default-member-init,-readability-named-parameter,-readability-redundant-member-init,-performance-faster-string-find,-modernize-avoid-c-arrays,-modernize-use-equals-default,-readability-container-size-empty,-readability-simplify-boolean-expr,-modernize-pass-by-value,-bugprone-branch-clone,-bugprone-narrowing-conversions,-modernize-raw-string-literal,-readability-convert-member-functions-to-static,-modernize-loop-convert,-misc-unused-using-decls,-readability-const-return-type,-performance-unnecessary-value-param,-modernize-return-braced-init-list,-performance-inefficient-string-concatenation,-misc-throw-by-value-catch-by-reference,-readability-avoid-const-params-in-decls,-readability-non-const-parameter,-misc-non-private-member-variables-in-classes,-bugprone-suspicious-string-compare,-clang-analyzer-*,-bugprone-signed-char-misuse,-readability-make-member-function-const,-misc-no-recursion,-readability-use-anyofallof,-performance-no-automatic-move,-bugprone-suspicious-include,-modernize-replace-random-shuffle,-readability-function-cognitive-complexity,-readability-redundant-access-specifiers,-modernize-use-equals-delete,-performance-noexcept-move-constructor,-concurrency-mt-unsafe,-bugprone-easily-swappable-parameters,-readability-suspicious-call-argument,-readability-identifier-length,-readability-container-data-pointer'
|
||||||
WarningsAsErrors: '*'
|
WarningsAsErrors: '*'
|
||||||
CheckOptions:
|
CheckOptions:
|
||||||
- key: misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic
|
- key: misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic
|
||||||
|
|
|
@ -2634,7 +2634,7 @@ struct ValueFlowAnalyzer : Analyzer {
|
||||||
return Action::None;
|
return Action::None;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual Action analyze(const Token* tok, Direction d) const override {
|
Action analyze(const Token* tok, Direction d) const override {
|
||||||
if (invalid())
|
if (invalid())
|
||||||
return Action::Invalid;
|
return Action::Invalid;
|
||||||
// Follow references
|
// Follow references
|
||||||
|
@ -2684,7 +2684,7 @@ struct ValueFlowAnalyzer : Analyzer {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual std::vector<MathLib::bigint> evaluate(Evaluate e, const Token* tok, const Token* ctx = nullptr) const override
|
std::vector<MathLib::bigint> evaluate(Evaluate e, const Token* tok, const Token* ctx = nullptr) const override
|
||||||
{
|
{
|
||||||
if (e == Evaluate::Integral) {
|
if (e == Evaluate::Integral) {
|
||||||
return evaluateInt(tok, [&] {
|
return evaluateInt(tok, [&] {
|
||||||
|
@ -2706,7 +2706,7 @@ struct ValueFlowAnalyzer : Analyzer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void assume(const Token* tok, bool state, unsigned int flags) override {
|
void assume(const Token* tok, bool state, unsigned int flags) override {
|
||||||
// Update program state
|
// Update program state
|
||||||
pms.removeModifiedVars(tok);
|
pms.removeModifiedVars(tok);
|
||||||
pms.addState(tok, getProgramState());
|
pms.addState(tok, getProgramState());
|
||||||
|
@ -2748,7 +2748,7 @@ struct ValueFlowAnalyzer : Analyzer {
|
||||||
assert(false && "Internal update unimplemented.");
|
assert(false && "Internal update unimplemented.");
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void update(Token* tok, Action a, Direction d) override {
|
void update(Token* tok, Action a, Direction d) override {
|
||||||
ValueFlow::Value* value = getValue(tok);
|
ValueFlow::Value* value = getValue(tok);
|
||||||
if (!value)
|
if (!value)
|
||||||
return;
|
return;
|
||||||
|
@ -2774,7 +2774,7 @@ struct ValueFlowAnalyzer : Analyzer {
|
||||||
setTokenValue(tok, *value, getSettings());
|
setTokenValue(tok, *value, getSettings());
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ValuePtr<Analyzer> reanalyze(Token*, const std::string&) const override {
|
ValuePtr<Analyzer> reanalyze(Token*, const std::string&) const override {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -2796,18 +2796,18 @@ struct SingleValueFlowAnalyzer : ValueFlowAnalyzer {
|
||||||
return aliases;
|
return aliases;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual const ValueFlow::Value* getValue(const Token*) const override {
|
const ValueFlow::Value* getValue(const Token*) const override {
|
||||||
return &value;
|
return &value;
|
||||||
}
|
}
|
||||||
virtual ValueFlow::Value* getValue(const Token*) override {
|
ValueFlow::Value* getValue(const Token*) override {
|
||||||
return &value;
|
return &value;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void makeConditional() override {
|
void makeConditional() override {
|
||||||
value.conditional = true;
|
value.conditional = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool useSymbolicValues() const override
|
bool useSymbolicValues() const override
|
||||||
{
|
{
|
||||||
if (value.isUninitValue())
|
if (value.isUninitValue())
|
||||||
return false;
|
return false;
|
||||||
|
@ -2816,11 +2816,11 @@ struct SingleValueFlowAnalyzer : ValueFlowAnalyzer {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void addErrorPath(const Token* tok, const std::string& s) override {
|
void addErrorPath(const Token* tok, const std::string& s) override {
|
||||||
value.errorPath.emplace_back(tok, s);
|
value.errorPath.emplace_back(tok, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool isAlias(const Token* tok, bool& inconclusive) const override {
|
bool isAlias(const Token* tok, bool& inconclusive) const override {
|
||||||
if (value.isLifetimeValue())
|
if (value.isLifetimeValue())
|
||||||
return false;
|
return false;
|
||||||
for (const auto& m: {
|
for (const auto& m: {
|
||||||
|
@ -2838,7 +2838,7 @@ struct SingleValueFlowAnalyzer : ValueFlowAnalyzer {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool isGlobal() const override {
|
bool isGlobal() const override {
|
||||||
for (const auto&p:getVars()) {
|
for (const auto&p:getVars()) {
|
||||||
const Variable* var = p.second;
|
const Variable* var = p.second;
|
||||||
if (!var->isLocal() && !var->isArgument() && !var->isConst())
|
if (!var->isLocal() && !var->isArgument() && !var->isConst())
|
||||||
|
@ -2847,20 +2847,20 @@ struct SingleValueFlowAnalyzer : ValueFlowAnalyzer {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool lowerToPossible() override {
|
bool lowerToPossible() override {
|
||||||
if (value.isImpossible())
|
if (value.isImpossible())
|
||||||
return false;
|
return false;
|
||||||
value.changeKnownToPossible();
|
value.changeKnownToPossible();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
virtual bool lowerToInconclusive() override {
|
bool lowerToInconclusive() override {
|
||||||
if (value.isImpossible())
|
if (value.isImpossible())
|
||||||
return false;
|
return false;
|
||||||
value.setInconclusive();
|
value.setInconclusive();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool isConditional() const override {
|
bool isConditional() const override {
|
||||||
if (value.conditional)
|
if (value.conditional)
|
||||||
return true;
|
return true;
|
||||||
if (value.condition)
|
if (value.condition)
|
||||||
|
@ -2868,7 +2868,7 @@ struct SingleValueFlowAnalyzer : ValueFlowAnalyzer {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool stopOnCondition(const Token* condTok) const override
|
bool stopOnCondition(const Token* condTok) const override
|
||||||
{
|
{
|
||||||
if (value.isNonValue())
|
if (value.isNonValue())
|
||||||
return false;
|
return false;
|
||||||
|
@ -2882,7 +2882,7 @@ struct SingleValueFlowAnalyzer : ValueFlowAnalyzer {
|
||||||
return cs.isUnknownDependent();
|
return cs.isUnknownDependent();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool updateScope(const Token* endBlock, bool) const override {
|
bool updateScope(const Token* endBlock, bool) const override {
|
||||||
const Scope* scope = endBlock->scope();
|
const Scope* scope = endBlock->scope();
|
||||||
if (!scope)
|
if (!scope)
|
||||||
return false;
|
return false;
|
||||||
|
@ -2905,7 +2905,7 @@ struct SingleValueFlowAnalyzer : ValueFlowAnalyzer {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ValuePtr<Analyzer> reanalyze(Token* tok, const std::string& msg) const override {
|
ValuePtr<Analyzer> reanalyze(Token* tok, const std::string& msg) const override {
|
||||||
ValueFlow::Value newValue = value;
|
ValueFlow::Value newValue = value;
|
||||||
newValue.errorPath.emplace_back(tok, msg);
|
newValue.errorPath.emplace_back(tok, msg);
|
||||||
return makeAnalyzer(tok, newValue, tokenlist);
|
return makeAnalyzer(tok, newValue, tokenlist);
|
||||||
|
@ -2977,29 +2977,29 @@ struct ExpressionAnalyzer : SingleValueFlowAnalyzer {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool invalid() const override {
|
bool invalid() const override {
|
||||||
return unknown;
|
return unknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ProgramState getProgramState() const override {
|
ProgramState getProgramState() const override {
|
||||||
ProgramState ps;
|
ProgramState ps;
|
||||||
ps[expr] = value;
|
ps[expr] = value;
|
||||||
return ps;
|
return ps;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool match(const Token* tok) const override {
|
bool match(const Token* tok) const override {
|
||||||
return tok->exprId() == expr->exprId();
|
return tok->exprId() == expr->exprId();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool dependsOnThis() const override {
|
bool dependsOnThis() const override {
|
||||||
return dependOnThis;
|
return dependOnThis;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool isGlobal() const override {
|
bool isGlobal() const override {
|
||||||
return !local;
|
return !local;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool isVariable() const override {
|
bool isVariable() const override {
|
||||||
return expr->varId() > 0;
|
return expr->varId() > 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -3013,7 +3013,7 @@ struct OppositeExpressionAnalyzer : ExpressionAnalyzer {
|
||||||
: ExpressionAnalyzer(e, val, t), isNot(pIsNot)
|
: ExpressionAnalyzer(e, val, t), isNot(pIsNot)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
virtual bool match(const Token* tok) const override {
|
bool match(const Token* tok) const override {
|
||||||
return isOppositeCond(isNot, isCPP(), expr, tok, getSettings()->library, true, true);
|
return isOppositeCond(isNot, isCPP(), expr, tok, getSettings()->library, true, true);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -3030,28 +3030,28 @@ struct SubExpressionAnalyzer : ExpressionAnalyzer {
|
||||||
|
|
||||||
virtual bool submatch(const Token* tok, bool exact = true) const = 0;
|
virtual bool submatch(const Token* tok, bool exact = true) const = 0;
|
||||||
|
|
||||||
virtual bool isAlias(const Token* tok, bool& inconclusive) const override
|
bool isAlias(const Token* tok, bool& inconclusive) const override
|
||||||
{
|
{
|
||||||
if (tok->exprId() == expr->exprId() && tok->astParent() && submatch(tok->astParent(), false))
|
if (tok->exprId() == expr->exprId() && tok->astParent() && submatch(tok->astParent(), false))
|
||||||
return false;
|
return false;
|
||||||
return ExpressionAnalyzer::isAlias(tok, inconclusive);
|
return ExpressionAnalyzer::isAlias(tok, inconclusive);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool match(const Token* tok) const override
|
bool match(const Token* tok) const override
|
||||||
{
|
{
|
||||||
return tok->astOperand1() && tok->astOperand1()->exprId() == expr->exprId() && submatch(tok);
|
return tok->astOperand1() && tok->astOperand1()->exprId() == expr->exprId() && submatch(tok);
|
||||||
}
|
}
|
||||||
virtual bool internalMatch(const Token* tok) const override
|
bool internalMatch(const Token* tok) const override
|
||||||
{
|
{
|
||||||
return tok->exprId() == expr->exprId() && !(astIsLHS(tok) && submatch(tok->astParent(), false));
|
return tok->exprId() == expr->exprId() && !(astIsLHS(tok) && submatch(tok->astParent(), false));
|
||||||
}
|
}
|
||||||
virtual void internalUpdate(Token* tok, const ValueFlow::Value& v, Direction) override
|
void internalUpdate(Token* tok, const ValueFlow::Value& v, Direction) override
|
||||||
{
|
{
|
||||||
partialReads->push_back(std::make_pair(tok, v));
|
partialReads->push_back(std::make_pair(tok, v));
|
||||||
}
|
}
|
||||||
|
|
||||||
// No reanalysis for subexression
|
// No reanalysis for subexression
|
||||||
virtual ValuePtr<Analyzer> reanalyze(Token*, const std::string&) const override {
|
ValuePtr<Analyzer> reanalyze(Token*, const std::string&) const override {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -3064,7 +3064,7 @@ struct MemberExpressionAnalyzer : SubExpressionAnalyzer {
|
||||||
: SubExpressionAnalyzer(e, val, t), varname(std::move(varname))
|
: SubExpressionAnalyzer(e, val, t), varname(std::move(varname))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
virtual bool submatch(const Token* tok, bool exact) const override
|
bool submatch(const Token* tok, bool exact) const override
|
||||||
{
|
{
|
||||||
if (!Token::Match(tok, ". %var%"))
|
if (!Token::Match(tok, ". %var%"))
|
||||||
return false;
|
return false;
|
||||||
|
@ -5038,11 +5038,11 @@ struct SymbolicInferModel : InferModel {
|
||||||
explicit SymbolicInferModel(const Token* tok) : expr(tok) {
|
explicit SymbolicInferModel(const Token* tok) : expr(tok) {
|
||||||
assert(expr->exprId() != 0);
|
assert(expr->exprId() != 0);
|
||||||
}
|
}
|
||||||
virtual bool match(const ValueFlow::Value& value) const override
|
bool match(const ValueFlow::Value& value) const override
|
||||||
{
|
{
|
||||||
return value.isSymbolicValue() && value.tokvalue && value.tokvalue->exprId() == expr->exprId();
|
return value.isSymbolicValue() && value.tokvalue && value.tokvalue->exprId() == expr->exprId();
|
||||||
}
|
}
|
||||||
virtual ValueFlow::Value yield(MathLib::bigint value) const override
|
ValueFlow::Value yield(MathLib::bigint value) const override
|
||||||
{
|
{
|
||||||
ValueFlow::Value result(value);
|
ValueFlow::Value result(value);
|
||||||
result.valueType = ValueFlow::Value::ValueType::SYMBOLIC;
|
result.valueType = ValueFlow::Value::ValueType::SYMBOLIC;
|
||||||
|
@ -6067,7 +6067,7 @@ static void valueFlowCondition(const ValuePtr<ConditionHandler>& handler,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct SimpleConditionHandler : ConditionHandler {
|
struct SimpleConditionHandler : ConditionHandler {
|
||||||
virtual std::vector<Condition> parse(const Token* tok, const Settings*) const override {
|
std::vector<Condition> parse(const Token* tok, const Settings*) const override {
|
||||||
|
|
||||||
std::vector<Condition> conds;
|
std::vector<Condition> conds;
|
||||||
parseCompareEachInt(tok, [&](const Token* vartok, ValueFlow::Value true_value, ValueFlow::Value false_value) {
|
parseCompareEachInt(tok, [&](const Token* vartok, ValueFlow::Value true_value, ValueFlow::Value false_value) {
|
||||||
|
@ -6111,10 +6111,10 @@ struct SimpleConditionHandler : ConditionHandler {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct IntegralInferModel : InferModel {
|
struct IntegralInferModel : InferModel {
|
||||||
virtual bool match(const ValueFlow::Value& value) const override {
|
bool match(const ValueFlow::Value& value) const override {
|
||||||
return value.isIntValue();
|
return value.isIntValue();
|
||||||
}
|
}
|
||||||
virtual ValueFlow::Value yield(MathLib::bigint value) const override
|
ValueFlow::Value yield(MathLib::bigint value) const override
|
||||||
{
|
{
|
||||||
ValueFlow::Value result(value);
|
ValueFlow::Value result(value);
|
||||||
result.valueType = ValueFlow::Value::ValueType::INT;
|
result.valueType = ValueFlow::Value::ValueType::INT;
|
||||||
|
@ -6153,10 +6153,10 @@ ValueFlow::Value inferCondition(std::string op, MathLib::bigint val, const Token
|
||||||
|
|
||||||
struct IteratorInferModel : InferModel {
|
struct IteratorInferModel : InferModel {
|
||||||
virtual ValueFlow::Value::ValueType getType() const = 0;
|
virtual ValueFlow::Value::ValueType getType() const = 0;
|
||||||
virtual bool match(const ValueFlow::Value& value) const override {
|
bool match(const ValueFlow::Value& value) const override {
|
||||||
return value.valueType == getType();
|
return value.valueType == getType();
|
||||||
}
|
}
|
||||||
virtual ValueFlow::Value yield(MathLib::bigint value) const override
|
ValueFlow::Value yield(MathLib::bigint value) const override
|
||||||
{
|
{
|
||||||
ValueFlow::Value result(value);
|
ValueFlow::Value result(value);
|
||||||
result.valueType = getType();
|
result.valueType = getType();
|
||||||
|
@ -6166,13 +6166,13 @@ struct IteratorInferModel : InferModel {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct EndIteratorInferModel : IteratorInferModel {
|
struct EndIteratorInferModel : IteratorInferModel {
|
||||||
virtual ValueFlow::Value::ValueType getType() const override {
|
ValueFlow::Value::ValueType getType() const override {
|
||||||
return ValueFlow::Value::ValueType::ITERATOR_END;
|
return ValueFlow::Value::ValueType::ITERATOR_END;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct StartIteratorInferModel : IteratorInferModel {
|
struct StartIteratorInferModel : IteratorInferModel {
|
||||||
virtual ValueFlow::Value::ValueType getType() const override {
|
ValueFlow::Value::ValueType getType() const override {
|
||||||
return ValueFlow::Value::ValueType::ITERATOR_END;
|
return ValueFlow::Value::ValueType::ITERATOR_END;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -6233,7 +6233,7 @@ struct SymbolicConditionHandler : SimpleConditionHandler {
|
||||||
return tok->astOperand1();
|
return tok->astOperand1();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual std::vector<Condition> parse(const Token* tok, const Settings* settings) const override
|
std::vector<Condition> parse(const Token* tok, const Settings* settings) const override
|
||||||
{
|
{
|
||||||
if (!Token::Match(tok, "%comp%"))
|
if (!Token::Match(tok, "%comp%"))
|
||||||
return {};
|
return {};
|
||||||
|
@ -6557,7 +6557,7 @@ struct MultiValueFlowAnalyzer : ValueFlowAnalyzer {
|
||||||
return vars;
|
return vars;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual const ValueFlow::Value* getValue(const Token* tok) const override {
|
const ValueFlow::Value* getValue(const Token* tok) const override {
|
||||||
if (tok->varId() == 0)
|
if (tok->varId() == 0)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
auto it = values.find(tok->varId());
|
auto it = values.find(tok->varId());
|
||||||
|
@ -6565,7 +6565,7 @@ struct MultiValueFlowAnalyzer : ValueFlowAnalyzer {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
return &it->second;
|
return &it->second;
|
||||||
}
|
}
|
||||||
virtual ValueFlow::Value* getValue(const Token* tok) override {
|
ValueFlow::Value* getValue(const Token* tok) override {
|
||||||
if (tok->varId() == 0)
|
if (tok->varId() == 0)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
auto it = values.find(tok->varId());
|
auto it = values.find(tok->varId());
|
||||||
|
@ -6574,19 +6574,19 @@ struct MultiValueFlowAnalyzer : ValueFlowAnalyzer {
|
||||||
return &it->second;
|
return &it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void makeConditional() override {
|
void makeConditional() override {
|
||||||
for (auto&& p:values) {
|
for (auto&& p:values) {
|
||||||
p.second.conditional = true;
|
p.second.conditional = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void addErrorPath(const Token* tok, const std::string& s) override {
|
void addErrorPath(const Token* tok, const std::string& s) override {
|
||||||
for (auto&& p:values) {
|
for (auto&& p:values) {
|
||||||
p.second.errorPath.emplace_back(tok, "Assuming condition is " + s);
|
p.second.errorPath.emplace_back(tok, "Assuming condition is " + s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool isAlias(const Token* tok, bool& inconclusive) const override {
|
bool isAlias(const Token* tok, bool& inconclusive) const override {
|
||||||
const auto range = SelectValueFromVarIdMapRange(&values);
|
const auto range = SelectValueFromVarIdMapRange(&values);
|
||||||
|
|
||||||
for (const auto& p:getVars()) {
|
for (const auto& p:getVars()) {
|
||||||
|
@ -6600,11 +6600,11 @@ struct MultiValueFlowAnalyzer : ValueFlowAnalyzer {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool isGlobal() const override {
|
bool isGlobal() const override {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool lowerToPossible() override {
|
bool lowerToPossible() override {
|
||||||
for (auto&& p:values) {
|
for (auto&& p:values) {
|
||||||
if (p.second.isImpossible())
|
if (p.second.isImpossible())
|
||||||
return false;
|
return false;
|
||||||
|
@ -6612,7 +6612,7 @@ struct MultiValueFlowAnalyzer : ValueFlowAnalyzer {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
virtual bool lowerToInconclusive() override {
|
bool lowerToInconclusive() override {
|
||||||
for (auto&& p:values) {
|
for (auto&& p:values) {
|
||||||
if (p.second.isImpossible())
|
if (p.second.isImpossible())
|
||||||
return false;
|
return false;
|
||||||
|
@ -6621,7 +6621,7 @@ struct MultiValueFlowAnalyzer : ValueFlowAnalyzer {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool isConditional() const override {
|
bool isConditional() const override {
|
||||||
for (auto&& p:values) {
|
for (auto&& p:values) {
|
||||||
if (p.second.conditional)
|
if (p.second.conditional)
|
||||||
return true;
|
return true;
|
||||||
|
@ -6631,11 +6631,11 @@ struct MultiValueFlowAnalyzer : ValueFlowAnalyzer {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool stopOnCondition(const Token*) const override {
|
bool stopOnCondition(const Token*) const override {
|
||||||
return isConditional();
|
return isConditional();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool updateScope(const Token* endBlock, bool) const override {
|
bool updateScope(const Token* endBlock, bool) const override {
|
||||||
const Scope* scope = endBlock->scope();
|
const Scope* scope = endBlock->scope();
|
||||||
if (!scope)
|
if (!scope)
|
||||||
return false;
|
return false;
|
||||||
|
@ -6669,11 +6669,11 @@ struct MultiValueFlowAnalyzer : ValueFlowAnalyzer {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool match(const Token* tok) const override {
|
bool match(const Token* tok) const override {
|
||||||
return values.count(tok->varId()) > 0;
|
return values.count(tok->varId()) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ProgramState getProgramState() const override {
|
ProgramState getProgramState() const override {
|
||||||
ProgramState ps;
|
ProgramState ps;
|
||||||
for (const auto& p : values) {
|
for (const auto& p : values) {
|
||||||
const Variable* var = vars.at(p.first);
|
const Variable* var = vars.at(p.first);
|
||||||
|
@ -7286,11 +7286,11 @@ struct ContainerExpressionAnalyzer : ExpressionAnalyzer {
|
||||||
: ExpressionAnalyzer(expr, val, t)
|
: ExpressionAnalyzer(expr, val, t)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
virtual bool match(const Token* tok) const override {
|
bool match(const Token* tok) const override {
|
||||||
return tok->exprId() == expr->exprId() || (astIsIterator(tok) && isAliasOf(tok, expr->exprId()));
|
return tok->exprId() == expr->exprId() || (astIsIterator(tok) && isAliasOf(tok, expr->exprId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual Action isWritable(const Token* tok, Direction d) const override {
|
Action isWritable(const Token* tok, Direction d) const override {
|
||||||
if (astIsIterator(tok))
|
if (astIsIterator(tok))
|
||||||
return Action::None;
|
return Action::None;
|
||||||
if (d == Direction::Reverse)
|
if (d == Direction::Reverse)
|
||||||
|
@ -7326,7 +7326,7 @@ struct ContainerExpressionAnalyzer : ExpressionAnalyzer {
|
||||||
return Action::None;
|
return Action::None;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void writeValue(ValueFlow::Value* val, const Token* tok, Direction d) const override {
|
void writeValue(ValueFlow::Value* val, const Token* tok, Direction d) const override {
|
||||||
if (d == Direction::Reverse)
|
if (d == Direction::Reverse)
|
||||||
return;
|
return;
|
||||||
if (!val)
|
if (!val)
|
||||||
|
@ -7361,7 +7361,7 @@ struct ContainerExpressionAnalyzer : ExpressionAnalyzer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual Action isModified(const Token* tok) const override {
|
Action isModified(const Token* tok) const override {
|
||||||
Action read = Action::Read;
|
Action read = Action::Read;
|
||||||
// An iterator won't change the container size
|
// An iterator won't change the container size
|
||||||
if (astIsIterator(tok))
|
if (astIsIterator(tok))
|
||||||
|
@ -7638,7 +7638,7 @@ static std::list<ValueFlow::Value> getIteratorValues(std::list<ValueFlow::Value>
|
||||||
}
|
}
|
||||||
|
|
||||||
struct IteratorConditionHandler : SimpleConditionHandler {
|
struct IteratorConditionHandler : SimpleConditionHandler {
|
||||||
virtual std::vector<Condition> parse(const Token* tok, const Settings*) const override {
|
std::vector<Condition> parse(const Token* tok, const Settings*) const override {
|
||||||
Condition cond;
|
Condition cond;
|
||||||
|
|
||||||
ValueFlow::Value true_value;
|
ValueFlow::Value true_value;
|
||||||
|
@ -7936,7 +7936,7 @@ static void valueFlowContainerSize(TokenList* tokenlist,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ContainerConditionHandler : ConditionHandler {
|
struct ContainerConditionHandler : ConditionHandler {
|
||||||
virtual std::vector<Condition> parse(const Token* tok, const Settings* settings) const override
|
std::vector<Condition> parse(const Token* tok, const Settings* settings) const override
|
||||||
{
|
{
|
||||||
std::vector<Condition> conds;
|
std::vector<Condition> conds;
|
||||||
parseCompareEachInt(tok, [&](const Token* vartok, ValueFlow::Value true_value, ValueFlow::Value false_value) {
|
parseCompareEachInt(tok, [&](const Token* vartok, ValueFlow::Value true_value, ValueFlow::Value false_value) {
|
||||||
|
|
Loading…
Reference in New Issue