From 35f2fb4c6316e568068fcc6972e10955e5eb768f Mon Sep 17 00:00:00 2001 From: Jon Rood Date: Wed, 29 Dec 2021 11:41:44 -0700 Subject: [PATCH] Reintroduce modernize-loop-convert check and fix. (#531) --- .clang-tidy | 2 +- amr-wind/core/SimTime.cpp | 4 ++-- amr-wind/physics/SyntheticTurbulence.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 185d1f8c35..61148d5af7 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,5 +1,5 @@ --- -Checks: 'clang-diagnostic-*,clang-analyzer-*,corecppguidelines-*,modernize-*,readability-*,-readability-magic-numbers,-readability-identifier-naming,-modernize-avoid-c-arrays,-modernize-use-trailing-return-type,-readability-named-parameter,-readability-implicit-bool-conversion,-readability-isolate-declaration,-readability-braces-around-statements,-readability-inconsistent-declaration-parameter-name,-modernize-use-emplace,-readability-qualified-auto,-readability-static-accessed-through-instance,-readability-container-size-empty,-readability-make-member-function-const,-readability-uppercase-literal-suffix,-readability-convert-member-functions-to-static,-readability-redundant-member-init,-modernize-use-bool-literals,-readability-const-return-type,-readability-avoid-const-params-in-decls,-modernize-pass-by-value,-modernize-loop-convert,-clang-analyzer-optin.cplusplus.VirtualCall' +Checks: 'clang-diagnostic-*,clang-analyzer-*,corecppguidelines-*,modernize-*,readability-*,-readability-magic-numbers,-readability-identifier-naming,-modernize-avoid-c-arrays,-modernize-use-trailing-return-type,-readability-named-parameter,-readability-implicit-bool-conversion,-readability-isolate-declaration,-readability-braces-around-statements,-readability-inconsistent-declaration-parameter-name,-modernize-use-emplace,-readability-qualified-auto,-readability-static-accessed-through-instance,-readability-container-size-empty,-readability-make-member-function-const,-readability-uppercase-literal-suffix,-readability-convert-member-functions-to-static,-readability-redundant-member-init,-modernize-use-bool-literals,-readability-const-return-type,-readability-avoid-const-params-in-decls,-modernize-pass-by-value,-clang-analyzer-optin.cplusplus.VirtualCall,-clang-analyzer-core.NonNullParamChecker' WarningsAsErrors: '' HeaderFilterRegex: '^((?!/amrex/Src/|/googletest/).)*$' AnalyzeTemporaryDtors: false diff --git a/amr-wind/core/SimTime.cpp b/amr-wind/core/SimTime.cpp index 32e17e945a..f677c6a1f3 100644 --- a/amr-wind/core/SimTime.cpp +++ b/amr-wind/core/SimTime.cpp @@ -8,8 +8,8 @@ namespace amr_wind { void SimTime::parse_parameters() { // Initialize deltaT to negative values - for (int i = 0; i < max_time_states; ++i) { - m_dt[i] = -1.0; + for (double& i : m_dt) { + i = -1.0; } // Parse options in "time" namespace diff --git a/amr-wind/physics/SyntheticTurbulence.cpp b/amr-wind/physics/SyntheticTurbulence.cpp index 3325137b3f..4fad3c65a2 100644 --- a/amr-wind/physics/SyntheticTurbulence.cpp +++ b/amr-wind/physics/SyntheticTurbulence.cpp @@ -322,7 +322,7 @@ AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void interp_perturb_vel( wt.yr * wt.zr * t_grid.wvel[qidx[2]] + wt.yl * wt.zr * t_grid.wvel[qidx[3]]; - for (int i = 0; i < 4; ++i) qidx[i] += nynz; + for (int& i : qidx) i += nynz; // Right quad (t = t+deltaT) vel_r[0] = wt.yl * wt.zl * t_grid.uvel[qidx[0]] +