Skip to content

Commit

Permalink
fixes for Clang and clang-tidy 10 (danmar#2588)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
firewave authored Apr 4, 2020
1 parent ac45bf7 commit 1dd8d4a
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
@@ -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:
- key: misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic
value: '1'
2 changes: 1 addition & 1 deletion cmake/clang_tidy.cmake
Original file line number Diff line number Diff line change
@@ -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}")
if (CLANG_TIDY)
set(CLANG_TIDY_SRCS ${CMAKE_SOURCE_DIR}/cli/*.cpp ${CMAKE_SOURCE_DIR}/lib/*.cpp)
Expand Down
4 changes: 2 additions & 2 deletions lib/exprengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ ExprEngine::ConditionalValue::Vector ExprEngine::ArrayValue::read(ExprEngine::Va
ExprEngine::ConditionalValue::Vector ret;
if (!index)
return ret;
for (const auto indexAndValue : data) {
for (const auto &indexAndValue : data) {
if (::isEqual(index, indexAndValue.index))
ret.clear();
if (isNonOverlapping(index, indexAndValue.index))
Expand Down Expand Up @@ -542,7 +542,7 @@ std::string ExprEngine::ArrayValue::getSymbolicExpression() const
{
std::ostringstream ostr;
ostr << "size=" << (size ? size->name : std::string("(null)"));
for (const auto indexAndValue : data) {
for (const auto &indexAndValue : data) {
ostr << ",["
<< (!indexAndValue.index ? std::string(":") : indexAndValue.index->name)
<< "]="
Expand Down
8 changes: 4 additions & 4 deletions lib/token.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,11 +250,11 @@ void Token::swapWithNext()
std::swap(mTokType, mNext->mTokType);
std::swap(mFlags, mNext->mFlags);
std::swap(mImpl, mNext->mImpl);
for (auto templateSimplifierPointer : mImpl->mTemplateSimplifierPointers) {
for (auto *templateSimplifierPointer : mImpl->mTemplateSimplifierPointers) {
templateSimplifierPointer->token(this);
}

for (auto templateSimplifierPointer : mNext->mImpl->mTemplateSimplifierPointers) {
for (auto *templateSimplifierPointer : mNext->mImpl->mTemplateSimplifierPointers) {
templateSimplifierPointer->token(mNext);
}
if (mNext->mLink)
Expand All @@ -273,7 +273,7 @@ void Token::takeData(Token *fromToken)
delete mImpl;
mImpl = fromToken->mImpl;
fromToken->mImpl = nullptr;
for (auto templateSimplifierPointer : mImpl->mTemplateSimplifierPointers) {
for (auto *templateSimplifierPointer : mImpl->mTemplateSimplifierPointers) {
templateSimplifierPointer->token(this);
}
mLink = fromToken->mLink;
Expand Down Expand Up @@ -2105,7 +2105,7 @@ TokenImpl::~TokenImpl()
delete mValueType;
delete mValues;

for (auto templateSimplifierPointer : mTemplateSimplifierPointers) {
for (auto *templateSimplifierPointer : mTemplateSimplifierPointers) {
templateSimplifierPointer->token(nullptr);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/tokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2876,7 +2876,7 @@ void Tokenizer::simplifyCaseRange()

void Tokenizer::calculateScopes()
{
for (auto tok = list.front(); tok; tok = tok->next())
for (auto *tok = list.front(); tok; tok = tok->next())
tok->scopeInfo(nullptr);

std::string nextScopeNameAddition;
Expand Down
2 changes: 1 addition & 1 deletion test/testexprengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class TestExprEngine : public TestFixture {
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)
return;
auto b = dynamic_cast<const ExprEngine::BinOpResult *>(&value);
const auto *b = dynamic_cast<const ExprEngine::BinOpResult *>(&value);
if (!b)
return;
if (!ret.empty())
Expand Down

0 comments on commit 1dd8d4a

Please sign in to comment.