Skip to content

Commit

Permalink
Fix Clang-Tidy Header Filter (AMReX-Codes#3342)
Browse files Browse the repository at this point in the history
Fix regex in the clang-tidy header filter. The issue was the old regex
filtered out headers like AMReX_Any.H (because of its letter n) and
AMReX_IntVect.H (because of it's letter t before .H) in addition to
files ending with nolint.H.

Fix warnings.
  • Loading branch information
WeiqunZhang authored Jun 5, 2023
1 parent 79f6283 commit a2a22da
Show file tree
Hide file tree
Showing 111 changed files with 1,099 additions and 1,075 deletions.
3 changes: 2 additions & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,5 @@ Checks: >
mpi-*
'
HeaderFilterRegex: '[^n][^o][^l][^i][^n][^t]\.H$'
# Files not ending with nolint.H will be filtered in.
HeaderFilterRegex: '([^n].....|[^o]....|[^l]...|[^i]..|[^n].|[^t])\.H$'
3 changes: 2 additions & 1 deletion .github/workflows/cuda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,12 @@ jobs:
nvfortran --version
cmake --version
# Disable Fortran due to space limit
cmake -S . -B build \
-DCMAKE_VERBOSE_MAKEFILE=ON \
-DAMReX_ENABLE_TESTS=ON \
-DAMReX_PARTICLES=ON \
-DAMReX_FORTRAN=ON \
-DAMReX_FORTRAN=OFF \
-DAMReX_GPU_BACKEND=CUDA \
-DCMAKE_C_COMPILER=$(which nvc) \
-DCMAKE_CXX_COMPILER=$(which nvc++) \
Expand Down
40 changes: 24 additions & 16 deletions Src/Amr/AMReX_Derive.H
Original file line number Diff line number Diff line change
Expand Up @@ -122,60 +122,65 @@ public:
*/
~DeriveRec ();

DeriveRec (DeriveRec const&) = delete;
DeriveRec (DeriveRec &&) = delete;
DeriveRec& operator= (DeriveRec const&) = delete;
DeriveRec& operator= (DeriveRec &&) = delete;

/**
* \brief The name of the derived type.
*/
const std::string& name () const noexcept;
[[nodiscard]] const std::string& name () const noexcept;

/**
* \brief The names of components
*
* \param comp
*/
const std::string& variableName (int comp) const noexcept;
[[nodiscard]] const std::string& variableName (int comp) const noexcept;

/**
* \brief The IndexType of the derived type.
*/
IndexType deriveType () const noexcept;
[[nodiscard]] IndexType deriveType () const noexcept;

/**
* \brief The DeriveFunc used to calculate the derived type.
*/
DeriveFunc derFunc () const noexcept;
DeriveFunc3D derFunc3D () const noexcept;
DeriveFuncFab derFuncFab () const noexcept;
[[nodiscard]] DeriveFunc derFunc () const noexcept;
[[nodiscard]] DeriveFunc3D derFunc3D () const noexcept;
[[nodiscard]] DeriveFuncFab derFuncFab () const noexcept;

/**
* \brief Maps state data box to derived data box.
*/
DeriveBoxMap boxMap () const noexcept;
[[nodiscard]] DeriveBoxMap boxMap () const noexcept;

/**
* \brief Type of interpolater to use in computing derived type.
*/
Interpolater* interp () const noexcept;
[[nodiscard]] Interpolater* interp () const noexcept;

/**
* \brief Number of components in the derived type.
*/
int numDerive () const noexcept;
[[nodiscard]] int numDerive () const noexcept;

/**
* \brief Number of different chunks of state data needed for derived type.
*/
int numRange () const noexcept;
[[nodiscard]] int numRange () const noexcept;

/**
* \brief Total number of state variables needed for derived type.
*/
int numState () const noexcept;
[[nodiscard]] int numState () const noexcept;

/**
* \brief The boundary conditions.
*/
const int* getBC () const noexcept;
const int* getBC3D () const noexcept;
[[nodiscard]] const int* getBC () const noexcept;
[[nodiscard]] const int* getBC3D () const noexcept;

/**
* \brief Sets state_indx, src_comp and num_comp for the kth
Expand Down Expand Up @@ -344,22 +349,25 @@ public:
*/
DeriveList () = default;

~DeriveList () = default;
DeriveList (const DeriveList&) = delete;
DeriveList (DeriveList &&) = delete;
DeriveList& operator= (const DeriveList&) = delete;
DeriveList& operator= (DeriveList &&) = delete;

/**
* \brief Determines whether quantity identified by \<name\> is in the registry.
*
* \param name
*/
bool canDerive (const std::string& name) const;
[[nodiscard]] bool canDerive (const std::string& name) const;

/**
* \brief Access the particular record in registry.
*
* \param name
*/
const DeriveRec* get (const std::string& name) const;
[[nodiscard]] const DeriveRec* get (const std::string& name) const;

/**
* \brief Adds another entry to the registry.
Expand Down Expand Up @@ -456,7 +464,7 @@ public:
int s_comp,
int n_comp);

std::list<DeriveRec>& dlist ();
[[nodiscard]] std::list<DeriveRec>& dlist ();

void clear () { lst.clear(); }

Expand Down
7 changes: 6 additions & 1 deletion Src/Amr/AMReX_LevelBld.H
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ class LevelBld
{
public:

virtual ~LevelBld () {}
virtual ~LevelBld () = default;
LevelBld () noexcept = default;
LevelBld (LevelBld const&) = default;
LevelBld (LevelBld &&) noexcept = default;
LevelBld& operator= (LevelBld const&) = default;
LevelBld& operator= (LevelBld &&) noexcept = default;

/**
* \brief Perform any problem-dependent setup such as physical
Expand Down
87 changes: 56 additions & 31 deletions Src/AmrCore/AMReX_ErrorList.H
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,18 @@ public:
* \brief Return a ptr to a clone of this object.
* It is the responsibility of the caller to delete the result.
*/
virtual ErrorFunc* clone () const;
[[nodiscard]] virtual ErrorFunc* clone () const;

/**
* \brief Destructor.
*/
virtual ~ErrorFunc () = default;

ErrorFunc (ErrorFunc const&) = default;
ErrorFunc (ErrorFunc &&) = delete;
ErrorFunc& operator= (ErrorFunc const&) = default;
ErrorFunc& operator= (ErrorFunc &&) = delete;

/**
* \brief Tag cells using "regular" function.
*
Expand Down Expand Up @@ -212,8 +217,8 @@ public:
const int* level) const;
protected:

ErrorFuncDefault m_func;
ErrorFunc3DDefault m_func3D;
ErrorFuncDefault m_func{nullptr};
ErrorFunc3DDefault m_func3D{nullptr};
};
class ErrorFunc2
{
Expand All @@ -236,13 +241,18 @@ public:
* \brief Return a ptr to a clone of this object.
* It is the responsibility of the caller to delete the result.
*/
virtual ErrorFunc2* clone () const;
[[nodiscard]] virtual ErrorFunc2* clone () const;

/**
* \brief Destructor.
*/
virtual ~ErrorFunc2 () = default;

ErrorFunc2 (ErrorFunc2 const&) = default;
ErrorFunc2 (ErrorFunc2 &&) = delete;
ErrorFunc2& operator= (ErrorFunc2 const&) = default;
ErrorFunc2& operator= (ErrorFunc2 &&) = delete;

/**
* \brief Tag cells cells using "v2" interface
*
Expand Down Expand Up @@ -271,7 +281,7 @@ public:
const Real* dx, const int* level, const Real* avg) const;
protected:

ErrorFunc2Default m_func;
ErrorFunc2Default m_func{nullptr};
};

/**
Expand All @@ -288,28 +298,33 @@ public:
ErrorRec (std::string nm, int ng, ErrorType etyp,
const ErrorRec::ErrorFunc& f);

virtual ~ErrorRec();
virtual ~ErrorRec ();

ErrorRec (ErrorRec const&) = delete;
ErrorRec (ErrorRec &&) = delete;
ErrorRec& operator= (ErrorRec const&) = delete;
ErrorRec& operator= (ErrorRec &&) = delete;

/**
* \brief The name of the quantity to derive.
*/
const std::string& name () const noexcept;
[[nodiscard]] const std::string& name () const noexcept;

/**
* \brief The number of extra zones needed for derivation.
*/
int nGrow () const noexcept;
[[nodiscard]] int nGrow () const noexcept;

/**
* \brief The type of the error tagging.
*/
ErrorType errType () const noexcept;
[[nodiscard]] ErrorType errType () const noexcept;

/**
* \brief The extern "C" functions to do the error tagging.
*/
virtual const ErrorRec::ErrorFunc& errFunc () const;
virtual const ErrorRec::ErrorFunc2& errFunc2() const;
[[nodiscard]] virtual const ErrorRec::ErrorFunc& errFunc () const;
[[nodiscard]] virtual const ErrorRec::ErrorFunc2& errFunc2() const;

private:

Expand Down Expand Up @@ -337,12 +352,12 @@ private:
class ErrorList
{
public:
ErrorList() noexcept {}
ErrorList() noexcept = default;

/**
* \brief The number of ErrorRecs in the list.
*/
int size () const noexcept;
[[nodiscard]] int size () const noexcept;

/**
* \brief Append a new ErrorRec to the list.
Expand All @@ -363,7 +378,7 @@ public:
const ErrorRec::ErrorFunc2& func);

//! The kth ErrorRec.
const ErrorRec& operator[] (int k) const noexcept;
[[nodiscard]] const ErrorRec& operator[] (int k) const noexcept;

void clear (bool rs0 = false) { vec.clear(); if(rs0) { vec.resize(0); } }

Expand Down Expand Up @@ -417,7 +432,12 @@ std::ostream& operator << (std::ostream& os, const ErrorList& elst);

struct UserFunc
{
virtual ~UserFunc () {}
virtual ~UserFunc () = default;

UserFunc (UserFunc const&) = default;
UserFunc (UserFunc &&) = delete;
UserFunc& operator= (UserFunc const&) = default;
UserFunc& operator= (UserFunc &&) = delete;

virtual void operator() (const amrex::Box& bx,
amrex::Array4<const amrex::Real> const& dat,
Expand All @@ -429,13 +449,13 @@ std::ostream& operator << (std::ostream& os, const ErrorList& elst);
};

explicit AMRErrorTag (const AMRErrorTagInfo& info = AMRErrorTagInfo()) noexcept
: m_test(BOX), m_field(std::string()), m_info(info) {m_ngrow = SetNGrow();}
: m_info(info), m_ngrow(SetNGrow()) {}

AMRErrorTag (amrex::Real value,
AMRErrorTag::TEST test,
const std::string& field,
std::string field,
const AMRErrorTagInfo& info = AMRErrorTagInfo()) noexcept
: m_test(test), m_field(field), m_info(info)
: m_test(test), m_field(std::move(field)), m_info(info)
{
m_value.resize(info.m_max_level);
for (int i = 0; i < m_value.size(); ++i) {
Expand All @@ -446,30 +466,35 @@ std::ostream& operator << (std::ostream& os, const ErrorList& elst);

AMRErrorTag (amrex::Vector<amrex::Real> value,
AMRErrorTag::TEST test,
const std::string& field,
std::string field,
const AMRErrorTagInfo& info = AMRErrorTagInfo()) noexcept
: m_test(test), m_field(field), m_info(info)
: m_test(test), m_field(std::move(field)), m_info(info)
{
AMREX_ASSERT(value.size() > 0);
AMREX_ASSERT(!value.empty());
m_value.resize(info.m_max_level);
for (int i = 0; i < m_value.size() && i < value.size(); ++i) {
m_value[i] = value[i];
}
// If the user didn't provided a value for every level,
// assume the last value holds for all higher levels.
for (int i = value.size(); i < m_value.size(); ++i) {
for (auto i = int(value.size()); i < m_value.size(); ++i) {
m_value[i] = value[value.size()-1];
}
m_ngrow = SetNGrow();
}

AMRErrorTag (AMRErrorTag::UserFunc* userfunc,
const std::string& field,
std::string field,
int ngrow,
const AMRErrorTagInfo& info = AMRErrorTagInfo()) noexcept
: m_userfunc(userfunc), m_field(field), m_info(info), m_ngrow(ngrow) {}
: m_userfunc(userfunc), m_field(std::move(field)), m_info(info), m_ngrow(ngrow) {}

virtual ~AMRErrorTag () = default;

virtual ~AMRErrorTag () {}
AMRErrorTag (AMRErrorTag const&) = default;
AMRErrorTag (AMRErrorTag &&) = delete;
AMRErrorTag& operator= (AMRErrorTag const&) = default;
AMRErrorTag& operator= (AMRErrorTag &&) = delete;

virtual void operator() (amrex::TagBoxArray& tb,
const amrex::MultiFab* mf,
Expand All @@ -479,18 +504,18 @@ std::ostream& operator << (std::ostream& os, const ErrorList& elst);
int level,
const amrex::Geometry& geom) const noexcept;

int NGrow() const noexcept {return m_ngrow;}
const std::string& Field () const noexcept {return m_field;}
[[nodiscard]] int NGrow() const noexcept {return m_ngrow;}
[[nodiscard]] const std::string& Field () const noexcept {return m_field;}

AMRErrorTagInfo& GetInfo () noexcept {return m_info;}
AMRErrorTagInfo const& GetInfo () const noexcept {return m_info;}
[[nodiscard]] AMRErrorTagInfo& GetInfo () noexcept {return m_info;}
[[nodiscard]] AMRErrorTagInfo const& GetInfo () const noexcept {return m_info;}
void SetInfo (AMRErrorTagInfo const& info) noexcept {m_info = info;}

protected:
int SetNGrow () const noexcept;
[[nodiscard]] int SetNGrow () const noexcept;

Vector<Real> m_value;
TEST m_test;
TEST m_test{BOX};
UserFunc* m_userfunc = nullptr;
std::string m_field;
AMRErrorTagInfo m_info;
Expand Down
Loading

0 comments on commit a2a22da

Please sign in to comment.