enabled and fixed `modernize-use-override` clang-tidy warnings (#4168)

This commit is contained in:
Oliver Stöneberg 2022-06-03 21:32:39 +02:00 committed by GitHub
parent eae164371c
commit ce945ec7fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 61 additions and 61 deletions

View File

@ -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: '*'
CheckOptions:
- key: misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic

View File

@ -2634,7 +2634,7 @@ struct ValueFlowAnalyzer : Analyzer {
return Action::None;
}
virtual Action analyze(const Token* tok, Direction d) const override {
Action analyze(const Token* tok, Direction d) const override {
if (invalid())
return Action::Invalid;
// Follow references
@ -2684,7 +2684,7 @@ struct ValueFlowAnalyzer : Analyzer {
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) {
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
pms.removeModifiedVars(tok);
pms.addState(tok, getProgramState());
@ -2748,7 +2748,7 @@ struct ValueFlowAnalyzer : Analyzer {
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);
if (!value)
return;
@ -2774,7 +2774,7 @@ struct ValueFlowAnalyzer : Analyzer {
setTokenValue(tok, *value, getSettings());
}
virtual ValuePtr<Analyzer> reanalyze(Token*, const std::string&) const override {
ValuePtr<Analyzer> reanalyze(Token*, const std::string&) const override {
return {};
}
};
@ -2796,18 +2796,18 @@ struct SingleValueFlowAnalyzer : ValueFlowAnalyzer {
return aliases;
}
virtual const ValueFlow::Value* getValue(const Token*) const override {
const ValueFlow::Value* getValue(const Token*) const override {
return &value;
}
virtual ValueFlow::Value* getValue(const Token*) override {
ValueFlow::Value* getValue(const Token*) override {
return &value;
}
virtual void makeConditional() override {
void makeConditional() override {
value.conditional = true;
}
virtual bool useSymbolicValues() const override
bool useSymbolicValues() const override
{
if (value.isUninitValue())
return false;
@ -2816,11 +2816,11 @@ struct SingleValueFlowAnalyzer : ValueFlowAnalyzer {
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);
}
virtual bool isAlias(const Token* tok, bool& inconclusive) const override {
bool isAlias(const Token* tok, bool& inconclusive) const override {
if (value.isLifetimeValue())
return false;
for (const auto& m: {
@ -2838,7 +2838,7 @@ struct SingleValueFlowAnalyzer : ValueFlowAnalyzer {
return false;
}
virtual bool isGlobal() const override {
bool isGlobal() const override {
for (const auto&p:getVars()) {
const Variable* var = p.second;
if (!var->isLocal() && !var->isArgument() && !var->isConst())
@ -2847,20 +2847,20 @@ struct SingleValueFlowAnalyzer : ValueFlowAnalyzer {
return false;
}
virtual bool lowerToPossible() override {
bool lowerToPossible() override {
if (value.isImpossible())
return false;
value.changeKnownToPossible();
return true;
}
virtual bool lowerToInconclusive() override {
bool lowerToInconclusive() override {
if (value.isImpossible())
return false;
value.setInconclusive();
return true;
}
virtual bool isConditional() const override {
bool isConditional() const override {
if (value.conditional)
return true;
if (value.condition)
@ -2868,7 +2868,7 @@ struct SingleValueFlowAnalyzer : ValueFlowAnalyzer {
return false;
}
virtual bool stopOnCondition(const Token* condTok) const override
bool stopOnCondition(const Token* condTok) const override
{
if (value.isNonValue())
return false;
@ -2882,7 +2882,7 @@ struct SingleValueFlowAnalyzer : ValueFlowAnalyzer {
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();
if (!scope)
return false;
@ -2905,7 +2905,7 @@ struct SingleValueFlowAnalyzer : ValueFlowAnalyzer {
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;
newValue.errorPath.emplace_back(tok, msg);
return makeAnalyzer(tok, newValue, tokenlist);
@ -2977,29 +2977,29 @@ struct ExpressionAnalyzer : SingleValueFlowAnalyzer {
});
}
virtual bool invalid() const override {
bool invalid() const override {
return unknown;
}
virtual ProgramState getProgramState() const override {
ProgramState getProgramState() const override {
ProgramState ps;
ps[expr] = value;
return ps;
}
virtual bool match(const Token* tok) const override {
bool match(const Token* tok) const override {
return tok->exprId() == expr->exprId();
}
virtual bool dependsOnThis() const override {
bool dependsOnThis() const override {
return dependOnThis;
}
virtual bool isGlobal() const override {
bool isGlobal() const override {
return !local;
}
virtual bool isVariable() const override {
bool isVariable() const override {
return expr->varId() > 0;
}
};
@ -3013,7 +3013,7 @@ struct OppositeExpressionAnalyzer : ExpressionAnalyzer {
: 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);
}
};
@ -3030,28 +3030,28 @@ struct SubExpressionAnalyzer : ExpressionAnalyzer {
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))
return false;
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);
}
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));
}
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));
}
// No reanalysis for subexression
virtual ValuePtr<Analyzer> reanalyze(Token*, const std::string&) const override {
ValuePtr<Analyzer> reanalyze(Token*, const std::string&) const override {
return {};
}
};
@ -3064,7 +3064,7 @@ struct MemberExpressionAnalyzer : SubExpressionAnalyzer {
: 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%"))
return false;
@ -5038,11 +5038,11 @@ struct SymbolicInferModel : InferModel {
explicit SymbolicInferModel(const Token* tok) : expr(tok) {
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();
}
virtual ValueFlow::Value yield(MathLib::bigint value) const override
ValueFlow::Value yield(MathLib::bigint value) const override
{
ValueFlow::Value result(value);
result.valueType = ValueFlow::Value::ValueType::SYMBOLIC;
@ -6067,7 +6067,7 @@ static void valueFlowCondition(const ValuePtr<ConditionHandler>& handler,
}
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;
parseCompareEachInt(tok, [&](const Token* vartok, ValueFlow::Value true_value, ValueFlow::Value false_value) {
@ -6111,10 +6111,10 @@ struct SimpleConditionHandler : ConditionHandler {
};
struct IntegralInferModel : InferModel {
virtual bool match(const ValueFlow::Value& value) const override {
bool match(const ValueFlow::Value& value) const override {
return value.isIntValue();
}
virtual ValueFlow::Value yield(MathLib::bigint value) const override
ValueFlow::Value yield(MathLib::bigint value) const override
{
ValueFlow::Value result(value);
result.valueType = ValueFlow::Value::ValueType::INT;
@ -6153,10 +6153,10 @@ ValueFlow::Value inferCondition(std::string op, MathLib::bigint val, const Token
struct IteratorInferModel : InferModel {
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();
}
virtual ValueFlow::Value yield(MathLib::bigint value) const override
ValueFlow::Value yield(MathLib::bigint value) const override
{
ValueFlow::Value result(value);
result.valueType = getType();
@ -6166,13 +6166,13 @@ struct IteratorInferModel : InferModel {
};
struct EndIteratorInferModel : IteratorInferModel {
virtual ValueFlow::Value::ValueType getType() const override {
ValueFlow::Value::ValueType getType() const override {
return ValueFlow::Value::ValueType::ITERATOR_END;
}
};
struct StartIteratorInferModel : IteratorInferModel {
virtual ValueFlow::Value::ValueType getType() const override {
ValueFlow::Value::ValueType getType() const override {
return ValueFlow::Value::ValueType::ITERATOR_END;
}
};
@ -6233,7 +6233,7 @@ struct SymbolicConditionHandler : SimpleConditionHandler {
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%"))
return {};
@ -6557,7 +6557,7 @@ struct MultiValueFlowAnalyzer : ValueFlowAnalyzer {
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)
return nullptr;
auto it = values.find(tok->varId());
@ -6565,7 +6565,7 @@ struct MultiValueFlowAnalyzer : ValueFlowAnalyzer {
return nullptr;
return &it->second;
}
virtual ValueFlow::Value* getValue(const Token* tok) override {
ValueFlow::Value* getValue(const Token* tok) override {
if (tok->varId() == 0)
return nullptr;
auto it = values.find(tok->varId());
@ -6574,19 +6574,19 @@ struct MultiValueFlowAnalyzer : ValueFlowAnalyzer {
return &it->second;
}
virtual void makeConditional() override {
void makeConditional() override {
for (auto&& p:values) {
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) {
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);
for (const auto& p:getVars()) {
@ -6600,11 +6600,11 @@ struct MultiValueFlowAnalyzer : ValueFlowAnalyzer {
return false;
}
virtual bool isGlobal() const override {
bool isGlobal() const override {
return false;
}
virtual bool lowerToPossible() override {
bool lowerToPossible() override {
for (auto&& p:values) {
if (p.second.isImpossible())
return false;
@ -6612,7 +6612,7 @@ struct MultiValueFlowAnalyzer : ValueFlowAnalyzer {
}
return true;
}
virtual bool lowerToInconclusive() override {
bool lowerToInconclusive() override {
for (auto&& p:values) {
if (p.second.isImpossible())
return false;
@ -6621,7 +6621,7 @@ struct MultiValueFlowAnalyzer : ValueFlowAnalyzer {
return true;
}
virtual bool isConditional() const override {
bool isConditional() const override {
for (auto&& p:values) {
if (p.second.conditional)
return true;
@ -6631,11 +6631,11 @@ struct MultiValueFlowAnalyzer : ValueFlowAnalyzer {
return false;
}
virtual bool stopOnCondition(const Token*) const override {
bool stopOnCondition(const Token*) const override {
return isConditional();
}
virtual bool updateScope(const Token* endBlock, bool) const override {
bool updateScope(const Token* endBlock, bool) const override {
const Scope* scope = endBlock->scope();
if (!scope)
return false;
@ -6669,11 +6669,11 @@ struct MultiValueFlowAnalyzer : ValueFlowAnalyzer {
return false;
}
virtual bool match(const Token* tok) const override {
bool match(const Token* tok) const override {
return values.count(tok->varId()) > 0;
}
virtual ProgramState getProgramState() const override {
ProgramState getProgramState() const override {
ProgramState ps;
for (const auto& p : values) {
const Variable* var = vars.at(p.first);
@ -7286,11 +7286,11 @@ struct ContainerExpressionAnalyzer : ExpressionAnalyzer {
: 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()));
}
virtual Action isWritable(const Token* tok, Direction d) const override {
Action isWritable(const Token* tok, Direction d) const override {
if (astIsIterator(tok))
return Action::None;
if (d == Direction::Reverse)
@ -7326,7 +7326,7 @@ struct ContainerExpressionAnalyzer : ExpressionAnalyzer {
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)
return;
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;
// An iterator won't change the container size
if (astIsIterator(tok))
@ -7638,7 +7638,7 @@ static std::list<ValueFlow::Value> getIteratorValues(std::list<ValueFlow::Value>
}
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;
ValueFlow::Value true_value;
@ -7936,7 +7936,7 @@ static void valueFlowContainerSize(TokenList* tokenlist,
}
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;
parseCompareEachInt(tok, [&](const Token* vartok, ValueFlow::Value true_value, ValueFlow::Value false_value) {