fixes for Clang and clang-tidy 10 (#2588)

* clang_tidy.cmake: added clang-tidy-10 to program list

* fixed -Wrange-loop-construct Clang warnings

* fixed readability-qualified-auto clang-tidy warnings

* .clang-tidy: actually disable clang-analyzer-* warnings

* .clang-tidy: disabled some new warnings introduced with clang-tidy-10
This commit is contained in:
Oliver Stöneberg 2020-04-04 11:44:59 +02:00 committed by GitHub
parent ac45bf7af2
commit 1dd8d4afaf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 10 additions and 10 deletions

View File

@ -1,5 +1,5 @@
--- ---
Checks: '*,-abseil-*,-android-*,-cert-*,-cppcoreguidelines-*,-fuchsia-*,-google-*,-hicpp-*,-llvm-*,-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,-readability-static-accessed-through-instance,-modernize-return-braced-init-list,-performance-inefficient-string-concatenation,-performance-for-range-copy,-misc-throw-by-value-catch-by-reference,-modernize-use-bool-literals,-readability-avoid-const-params-in-decls,-readability-redundant-control-flow,-bugprone-argument-comment,-readability-redundant-string-cstr,-readability-non-const-parameter,-misc-non-private-member-variables-in-classes,-performance-unnecessary-copy-initialization,-readability-redundant-string-init,-bugprone-suspicious-string-compare,-bugprone-use-after-move,-readability-misleading-indentation,-misc-unused-parameters-,clang-analyzer-*' Checks: '*,-abseil-*,-android-*,-cert-*,-cppcoreguidelines-*,-fuchsia-*,-google-*,-hicpp-*,-llvm-*,-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,-readability-static-accessed-through-instance,-modernize-return-braced-init-list,-performance-inefficient-string-concatenation,-performance-for-range-copy,-misc-throw-by-value-catch-by-reference,-modernize-use-bool-literals,-readability-avoid-const-params-in-decls,-readability-redundant-control-flow,-bugprone-argument-comment,-readability-redundant-string-cstr,-readability-non-const-parameter,-misc-non-private-member-variables-in-classes,-performance-unnecessary-copy-initialization,-readability-redundant-string-init,-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'
CheckOptions: CheckOptions:
- key: misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic - key: misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic
value: '1' value: '1'

View File

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

View File

@ -462,7 +462,7 @@ ExprEngine::ConditionalValue::Vector ExprEngine::ArrayValue::read(ExprEngine::Va
ExprEngine::ConditionalValue::Vector ret; ExprEngine::ConditionalValue::Vector ret;
if (!index) if (!index)
return ret; return ret;
for (const auto indexAndValue : data) { for (const auto &indexAndValue : data) {
if (::isEqual(index, indexAndValue.index)) if (::isEqual(index, indexAndValue.index))
ret.clear(); ret.clear();
if (isNonOverlapping(index, indexAndValue.index)) if (isNonOverlapping(index, indexAndValue.index))
@ -542,7 +542,7 @@ std::string ExprEngine::ArrayValue::getSymbolicExpression() const
{ {
std::ostringstream ostr; std::ostringstream ostr;
ostr << "size=" << (size ? size->name : std::string("(null)")); ostr << "size=" << (size ? size->name : std::string("(null)"));
for (const auto indexAndValue : data) { for (const auto &indexAndValue : data) {
ostr << ",[" ostr << ",["
<< (!indexAndValue.index ? std::string(":") : indexAndValue.index->name) << (!indexAndValue.index ? std::string(":") : indexAndValue.index->name)
<< "]=" << "]="

View File

@ -250,11 +250,11 @@ void Token::swapWithNext()
std::swap(mTokType, mNext->mTokType); std::swap(mTokType, mNext->mTokType);
std::swap(mFlags, mNext->mFlags); std::swap(mFlags, mNext->mFlags);
std::swap(mImpl, mNext->mImpl); std::swap(mImpl, mNext->mImpl);
for (auto templateSimplifierPointer : mImpl->mTemplateSimplifierPointers) { for (auto *templateSimplifierPointer : mImpl->mTemplateSimplifierPointers) {
templateSimplifierPointer->token(this); templateSimplifierPointer->token(this);
} }
for (auto templateSimplifierPointer : mNext->mImpl->mTemplateSimplifierPointers) { for (auto *templateSimplifierPointer : mNext->mImpl->mTemplateSimplifierPointers) {
templateSimplifierPointer->token(mNext); templateSimplifierPointer->token(mNext);
} }
if (mNext->mLink) if (mNext->mLink)
@ -273,7 +273,7 @@ void Token::takeData(Token *fromToken)
delete mImpl; delete mImpl;
mImpl = fromToken->mImpl; mImpl = fromToken->mImpl;
fromToken->mImpl = nullptr; fromToken->mImpl = nullptr;
for (auto templateSimplifierPointer : mImpl->mTemplateSimplifierPointers) { for (auto *templateSimplifierPointer : mImpl->mTemplateSimplifierPointers) {
templateSimplifierPointer->token(this); templateSimplifierPointer->token(this);
} }
mLink = fromToken->mLink; mLink = fromToken->mLink;
@ -2105,7 +2105,7 @@ TokenImpl::~TokenImpl()
delete mValueType; delete mValueType;
delete mValues; delete mValues;
for (auto templateSimplifierPointer : mTemplateSimplifierPointers) { for (auto *templateSimplifierPointer : mTemplateSimplifierPointers) {
templateSimplifierPointer->token(nullptr); templateSimplifierPointer->token(nullptr);
} }

View File

@ -2876,7 +2876,7 @@ void Tokenizer::simplifyCaseRange()
void Tokenizer::calculateScopes() void Tokenizer::calculateScopes()
{ {
for (auto tok = list.front(); tok; tok = tok->next()) for (auto *tok = list.front(); tok; tok = tok->next())
tok->scopeInfo(nullptr); tok->scopeInfo(nullptr);
std::string nextScopeNameAddition; std::string nextScopeNameAddition;

View File

@ -100,7 +100,7 @@ private:
std::function<void(const Token *, const ExprEngine::Value &, ExprEngine::DataBase *)> f = [&](const Token *tok, const ExprEngine::Value &value, ExprEngine::DataBase *dataBase) { std::function<void(const Token *, const ExprEngine::Value &, ExprEngine::DataBase *)> f = [&](const Token *tok, const ExprEngine::Value &value, ExprEngine::DataBase *dataBase) {
if (tok->str() != binop) if (tok->str() != binop)
return; return;
auto b = dynamic_cast<const ExprEngine::BinOpResult *>(&value); const auto *b = dynamic_cast<const ExprEngine::BinOpResult *>(&value);
if (!b) if (!b)
return; return;
if (!ret.empty()) if (!ret.empty())