fixed clang-tidy warnings (#3006)

* clang_tidy.cmake: added clang-tidy-11 to list of executables to look for

* .clang-tidy: disabled warnings we are (currently) not interested in

* fixed clang-tidy warnings
This commit is contained in:
Oliver Stöneberg 2021-01-02 23:10:27 +01:00 committed by GitHub
parent fbf5858f76
commit d59abfd977
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 15 additions and 15 deletions

View File

@ -1,5 +1,5 @@
---
Checks: '*,-abseil-*,-android-*,-cert-*,-cppcoreguidelines-*,-fuchsia-*,-google-*,-hicpp-*,-llvm-*,-llvmlibc-*,-linuxkernel-*,-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'
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'
CheckOptions:
- key: misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic
value: '1'

View File

@ -1,4 +1,4 @@
find_program(CLANG_TIDY NAMES clang-tidy clang-tidy-10 clang-tidy-9 clang-tidy-8)
find_program(CLANG_TIDY NAMES clang-tidy clang-tidy-11 clang-tidy-10 clang-tidy-9 clang-tidy-8)
message(STATUS "CLANG_TIDY=${CLANG_TIDY}")
if (CLANG_TIDY)
set(CLANG_TIDY_SRCS ${CMAKE_SOURCE_DIR}/cli/*.cpp ${CMAKE_SOURCE_DIR}/lib/*.cpp)

View File

@ -115,7 +115,7 @@ void ResultsView::setAddedVariableContracts(const QStringList &added)
mUI.mListAddedVariables->clear();
mUI.mListAddedVariables->addItems(added);
for (const QString& var: added) {
for (auto item: mUI.mListMissingVariables->findItems(var, Qt::MatchExactly))
for (auto *item: mUI.mListMissingVariables->findItems(var, Qt::MatchExactly))
delete item;
mVariableContracts.insert(var);
}
@ -549,11 +549,11 @@ void ResultsView::variableDoubleClicked(QListWidgetItem* item)
void ResultsView::editVariablesFilter(const QString &text)
{
for (auto item: mUI.mListAddedVariables->findItems(".*", Qt::MatchRegExp)) {
for (auto *item: mUI.mListAddedVariables->findItems(".*", Qt::MatchRegExp)) {
QString varname = item->text().mid(0, item->text().indexOf(" "));
item->setHidden(!varname.contains(text));
}
for (auto item: mUI.mListMissingVariables->findItems(".*", Qt::MatchRegExp))
for (auto *item: mUI.mListMissingVariables->findItems(".*", Qt::MatchRegExp))
item->setHidden(!item->text().contains(text));
}
@ -578,7 +578,7 @@ bool ResultsView::eventFilter(QObject *target, QEvent *event)
if (target == mUI.mListAddedVariables) {
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
if (keyEvent->key() == Qt::Key_Delete) {
for (auto i: mUI.mListAddedVariables->selectedItems()) {
for (auto *i: mUI.mListAddedVariables->selectedItems()) {
emit deleteVariableContract(i->text().mid(0, i->text().indexOf(" ")));
delete i;
}
@ -589,7 +589,7 @@ bool ResultsView::eventFilter(QObject *target, QEvent *event)
if (target == mUI.mListAddedContracts) {
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
if (keyEvent->key() == Qt::Key_Delete) {
for (auto i: mUI.mListAddedContracts->selectedItems()) {
for (auto *i: mUI.mListAddedContracts->selectedItems()) {
emit deleteFunctionContract(i->text());
delete i;
}

View File

@ -445,7 +445,7 @@ static std::list<std::pair<const Token *, MathLib::bigint>> getUnsafeFunction(co
return ret;
}
std::list<CTU::FileInfo::UnsafeUsage> CTU::getUnsafeUsage(const Tokenizer *tokenizer, const Settings *settings, const Check *check, bool (*isUnsafeUsage)(const Check *check, const Token *argtok, MathLib::bigint *_value))
std::list<CTU::FileInfo::UnsafeUsage> CTU::getUnsafeUsage(const Tokenizer *tokenizer, const Settings *settings, const Check *check, bool (*isUnsafeUsage)(const Check *check, const Token *argtok, MathLib::bigint *value))
{
std::list<CTU::FileInfo::UnsafeUsage> unsafeUsage;
@ -461,8 +461,8 @@ std::list<CTU::FileInfo::UnsafeUsage> CTU::getUnsafeUsage(const Tokenizer *token
for (int argnr = 0; argnr < function->argCount(); ++argnr) {
for (const std::pair<const Token *, MathLib::bigint> &v : getUnsafeFunction(tokenizer, settings, &scope, argnr, check, isUnsafeUsage)) {
const Token *tok = v.first;
MathLib::bigint value = v.second;
unsafeUsage.emplace_back(CTU::getFunctionId(tokenizer, function), argnr+1, tok->str(), CTU::FileInfo::Location(tokenizer,tok), value);
MathLib::bigint val = v.second;
unsafeUsage.emplace_back(CTU::getFunctionId(tokenizer, function), argnr+1, tok->str(), CTU::FileInfo::Location(tokenizer,tok), val);
}
}
}

View File

@ -702,7 +702,7 @@ static bool areAllParamsTypes(const std::vector<const Token *> &params)
if (params.empty())
return false;
for (auto param : params) {
for (const auto *param : params) {
if (!Token::Match(param->previous(), "typename|class %name% ,|>"))
return false;
}

View File

@ -2243,10 +2243,10 @@ bool Tokenizer::simplifyUsing()
std::string::size_type spaceIdx = 0;
std::string::size_type startIdx = 0;
while ((spaceIdx = removed1.find(" ", startIdx)) != std::string::npos) {
tok1->previous()->insertToken(removed1.substr(startIdx, spaceIdx - startIdx).c_str());
tok1->previous()->insertToken(removed1.substr(startIdx, spaceIdx - startIdx));
startIdx = spaceIdx + 1;
}
tok1->previous()->insertToken(removed1.substr(startIdx).c_str());
tok1->previous()->insertToken(removed1.substr(startIdx));
tok1->previous()->insertToken("::");
break;
}
@ -5255,7 +5255,7 @@ void Tokenizer::splitTemplateRightAngleBrackets(bool check)
vars.insert(tok->strAt(2));
// Ticket #6181: normalize C++11 template parameter list closing syntax
if (tok->previous() && tok->str() == "<" && mTemplateSimplifier->templateParameters(tok) && vars.find(tok->previous()->str()) == vars.end()) {
if (tok->previous() && tok->str() == "<" && TemplateSimplifier::templateParameters(tok) && vars.find(tok->previous()->str()) == vars.end()) {
Token *endTok = tok->findClosingBracket();
if (check) {
if (Token::Match(endTok, ">>|>>="))

View File

@ -1821,7 +1821,7 @@ static const std::string& invertAssign(const std::string& assign)
static std::unordered_map<std::string, std::string> lookup = {
{"+=", "-="}, {"-=", "+="}, {"*=", "/="}, {"/=", "*="}, {"<<=", ">>="}, {">>=", "<<="}, {"^=", "^="}
};
static std::string empty = "";
static std::string empty;
auto it = lookup.find(assign);
if (it == lookup.end())
return empty;