fixed and enabled some more clang-tidy warnings (#3007)

This commit is contained in:
Oliver Stöneberg 2021-01-05 17:51:32 +01:00 committed by GitHub
parent e004731f1c
commit 96704c9971
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 16 additions and 15 deletions

View File

@ -1,5 +1,5 @@
---
Checks: '*,-abseil-*,-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,-modernize-use-using,-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,-modernize-use-emplace,-readability-const-return-type,-performance-unnecessary-value-param,-modernize-return-braced-init-list,-performance-inefficient-string-concatenation,-performance-for-range-copy,-misc-throw-by-value-catch-by-reference,-readability-avoid-const-params-in-decls,-readability-redundant-control-flow,-bugprone-argument-comment,-readability-non-const-parameter,-misc-non-private-member-variables-in-classes,-bugprone-suspicious-string-compare,-bugprone-use-after-move,-readability-misleading-indentation,-misc-unused-parameters-,-clang-analyzer-*,-bugprone-signed-char-misuse,-readability-make-member-function-const,-readability-inconsistent-declaration-parameter-name,-misc-no-recursion,-readability-use-anyofallof,-performance-no-automatic-move'
Checks: '*,-abseil-*,-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,-modernize-use-emplace,-readability-const-return-type,-performance-unnecessary-value-param,-modernize-return-braced-init-list,-performance-inefficient-string-concatenation,-performance-for-range-copy,-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,-readability-misleading-indentation,-misc-unused-parameters-,-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'
CheckOptions:
- key: misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic
value: '1'

View File

@ -357,7 +357,7 @@ static bool IsAddressOnStack(const void* ptr)
*/
#define DECLARE_SIGNAL(x) std::make_pair(x, #x)
typedef std::map<int, std::string> Signalmap_t;
using Signalmap_t = std::map<int, std::string>;
static const Signalmap_t listofsignals = {
DECLARE_SIGNAL(SIGABRT),
DECLARE_SIGNAL(SIGBUS),

View File

@ -2022,7 +2022,7 @@ namespace {
for (const Scope &scope : symbolDatabase->scopeList) {
// only add const functions that do not have a non-const overloaded version
// since it is pretty much impossible to tell which is being called.
typedef std::map<std::string, std::list<const Function*> > StringFunctionMap;
using StringFunctionMap = std::map<std::string, std::list<const Function*> >;
StringFunctionMap functionsByName;
for (const Function &func : scope.functionList) {
functionsByName[func.tokenDef->str()].push_back(&func);

View File

@ -296,7 +296,7 @@ namespace clangimport {
};
class AstNode;
typedef std::shared_ptr<AstNode> AstNodePtr;
using AstNodePtr = std::shared_ptr<AstNode>;
class AstNode {
public:

View File

@ -394,7 +394,7 @@ namespace {
}
}
typedef std::map<nonneg int, ExprEngine::ValuePtr> Memory;
using Memory = std::map<nonneg int, ExprEngine::ValuePtr>;
Memory memory;
int * const symbolValueIndex;
ErrorLogger *errorLogger;
@ -1108,8 +1108,8 @@ std::string ExprEngine::IntegerTruncation::getSymbolicExpression() const
class ExprData {
public:
typedef std::map<std::string, z3::expr> ValueExpr;
typedef std::vector<z3::expr> AssertionList;
using ValueExpr = std::map<std::string, z3::expr>;
using AssertionList = std::vector<z3::expr>;
class BailoutValueException: public ExprEngineException {
public:

View File

@ -32,7 +32,7 @@
*/
namespace {
typedef std::pair<std::string, struct TimerResultsData> dataElementType;
using dataElementType = std::pair<std::string, struct TimerResultsData>;
bool more_second_sec(const dataElementType& lhs, const dataElementType& rhs)
{
return lhs.second.seconds() > rhs.second.seconds();

View File

@ -1334,7 +1334,7 @@ static void valueFlowSameExpressions(TokenList *tokenlist)
static void valueFlowTerminatingCondition(TokenList *tokenlist, SymbolDatabase* symboldatabase, ErrorLogger *errorLogger, const Settings *settings)
{
const bool cpp = symboldatabase->isCPP();
typedef std::pair<const Token*, const Scope*> Condition;
using Condition = std::pair<const Token*, const Scope*>;
for (const Scope * scope : symboldatabase->functionScopes) {
bool skipFunction = false;
std::vector<Condition> conds;
@ -2430,8 +2430,9 @@ static Analyzer::Action valueFlowForwardVariable(Token* const startToken,
TokenList* const tokenlist,
const Settings* const settings)
{
auto aliases = getAliasesFromValues(values);
return valueFlowForwardVariable(
startToken, endToken, var, std::move(values), getAliasesFromValues(values), tokenlist, settings);
startToken, endToken, var, std::move(values), std::move(aliases), tokenlist, settings);
}
// Old deprecated version
@ -2777,7 +2778,7 @@ std::vector<LifetimeToken> getLifetimeTokens(const Token* tok, bool escape, Valu
for (const Token* returnTok : returns) {
if (returnTok == tok)
continue;
for (LifetimeToken& lt : getLifetimeTokens(returnTok, escape, std::move(errorPath), depth - 1)) {
for (LifetimeToken& lt : getLifetimeTokens(returnTok, escape, errorPath, depth - 1)) {
const Token* argvarTok = lt.token;
const Variable* argvar = argvarTok->variable();
if (!argvar)

View File

@ -38,7 +38,7 @@ struct CompareFixtures {
}
};
typedef std::set<TestFixture*, CompareFixtures> TestSet;
using TestSet = std::set<TestFixture*, CompareFixtures>;
class TestRegistry {
TestSet _tests;
public:

View File

@ -326,7 +326,7 @@ private:
checkUninitVar("int f() {\n"
" int a,b,c;\n"
" a = b = c;\n"
"}", "test.cpp", /*verify=*/ false);
"}", "test.cpp", /*debugwarnings=*/ false);
ASSERT_EQUALS("[test.cpp:3]: (error) Uninitialized variable: c\n", errout.str());
checkUninitVar("static void foo()\n"

View File

@ -494,7 +494,7 @@ int main(int argc, char **argv)
fout << "\txmllint --noout --relaxng cppcheck-errors.rng /tmp/example.xml\n";
fout << "\ncheckCWEEntries: /tmp/errorlist.xml\n";
fout << "\t./tools/listErrorsWithoutCWE.py -F /tmp/errorlist.xml\n";
fout << ".PHONY: validateRules\n",
fout << ".PHONY: validateRules\n";
fout << "validateRules:\n";
fout << "\txmllint --noout rules/*.xml\n";