Skip to content

Commit

Permalink
Clang-Tidy 17: misc-use-anonymous-namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
WeiqunZhang committed Mar 19, 2024
1 parent 8afec3e commit 45bc21e
Show file tree
Hide file tree
Showing 13 changed files with 100 additions and 63 deletions.
9 changes: 6 additions & 3 deletions Src/Amr/AMReX_AmrLevel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -726,12 +726,13 @@ FillPatchIterator::FillPatchIterator (AmrLevel& amrlevel,
#endif
}

static
namespace {
bool
NeedToTouchUpPhysCorners (const Geometry& geom)
{
return geom.isAnyPeriodic() && !geom.isAllPeriodic();
}
}

void
FillPatchIteratorHelper::Initialize (int boxGrow,
Expand Down Expand Up @@ -1154,7 +1155,8 @@ FillPatchIterator::FillFromTwoLevels (Real time, int idx, int scomp, int dcomp,
desc.getBCs(),scomp);
}

static
namespace {

bool
HasPhysBndry (const Box& b,
const Box& dmn,
Expand All @@ -1174,7 +1176,6 @@ HasPhysBndry (const Box& b,
return false;
}

static
void
FixUpPhysCorners (FArrayBox& fab,
AmrLevel& TheLevel,
Expand Down Expand Up @@ -1258,6 +1259,8 @@ FixUpPhysCorners (FArrayBox& fab,
}
}

}

void
FillPatchIteratorHelper::fill (FArrayBox& fab,
int dcomp,
Expand Down
4 changes: 2 additions & 2 deletions Src/AmrCore/AMReX_Cluster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ Cluster::minBox () noexcept
// Finds best cut location in histogram.
//

static
namespace {

int
FindCut (const int* hist,
int lo,
Expand Down Expand Up @@ -236,7 +237,6 @@ FindCut (const int* hist,
return lo + cutpoint;
}

namespace {
//
// Predicate in call to std::partition() in Cluster::chop().
//
Expand Down
4 changes: 3 additions & 1 deletion Src/AmrCore/AMReX_ErrorList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,9 @@ ErrorList::operator[] (int k) const noexcept
return *vec[k];
}

static const char* err_name[] = { "Special", "Standard", "UseAverage" };
namespace {
const char* err_name[] = { "Special", "Standard", "UseAverage" };
}

std::ostream&
operator << (std::ostream& os,
Expand Down
6 changes: 4 additions & 2 deletions Src/Base/AMReX_DistributionMapping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ struct WeightedBoxList
}
};

static
namespace {
void
knapsack (const std::vector<Long>& wgts,
int nprocs,
Expand Down Expand Up @@ -712,6 +712,7 @@ top: ;
}
}
}
}

void
DistributionMapping::KnapSackDoIt (const std::vector<Long>& wgts,
Expand Down Expand Up @@ -1171,7 +1172,7 @@ namespace {
}
}

static
namespace {
void
Distribute (const std::vector<SFCToken>& tokens,
const std::vector<Long>& wgts,
Expand Down Expand Up @@ -1254,6 +1255,7 @@ Distribute (const std::vector<SFCToken>& tokens,
BL_ASSERT(cnt == tokens.size());
#endif
}
}

void
DistributionMapping::SFCProcessorMapDoIt (const BoxArray& boxes,
Expand Down
27 changes: 16 additions & 11 deletions Src/Base/AMReX_FabConv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ RealDescriptor::clone () const
// This exists solely to support reading "old" FABs.
//

static
namespace {
const int*
selectOrdering (int prec,
int ordering)
Expand Down Expand Up @@ -208,6 +208,7 @@ selectOrdering (int prec,
}
return nullptr;
}
}

//
// This is here solely to support reading "old" FABs.
Expand Down Expand Up @@ -293,7 +294,7 @@ _pd_get_bit (char const* base,
// for longer fields
//

static
namespace {
Long
_pd_extract_field (char const* in,
int offs,
Expand Down Expand Up @@ -367,7 +368,6 @@ _pd_extract_field (char const* in,
//

template <int NB>
static
void
_pd_btrvout (char* out, Long nitems)
{
Expand All @@ -387,8 +387,10 @@ _pd_btrvout (char* out, Long nitems)
}
}

const int BitsMax = 8*sizeof(Long);
const int REVERSE_ORDER = 2;
constexpr int BitsMax = 8*sizeof(Long);
constexpr int REVERSE_ORDER = 2;

}

//
// Copy the least significant NB bits from the given Long into the byte array
Expand Down Expand Up @@ -487,7 +489,7 @@ _pd_set_bit (char* base, int offs)
// on input.
//

static
namespace {
void
_pd_reorder (char* arr,
Long nitems,
Expand All @@ -512,7 +514,6 @@ _pd_reorder (char* arr,
// from inord to outord.
//

static
void
permute_real_word_order (void* out,
const void* in,
Expand Down Expand Up @@ -786,7 +787,6 @@ PD_fconvert (void* out,
_pd_reorder((char*)out, nitems, outbytes, outord);
}

static
void
PD_fixdenormals (void* out,
Long nitems,
Expand Down Expand Up @@ -816,13 +816,15 @@ PD_fixdenormals (void* out,
}
}

}

//
// It's really sad that I need to do this ...
//

#undef GETARRAY
namespace {
#define GETARRAY(TYPE) \
static \
void \
getarray (std::istream& is, \
Vector< TYPE >& ar) \
Expand Down Expand Up @@ -852,11 +854,12 @@ getarray (std::istream& is, \
}
GETARRAY(int)
GETARRAY(Long)
}
#undef GETARRAY

#undef PUTARRAY
namespace {
#define PUTARRAY(TYPE) \
static \
void \
putarray (std::ostream& os, \
const Vector< TYPE >& ar) \
Expand All @@ -874,6 +877,7 @@ putarray (std::ostream& os, \
}
PUTARRAY(int)
PUTARRAY(Long)
}
#undef PUTARRAY

std::ostream&
Expand Down Expand Up @@ -917,7 +921,7 @@ operator>> (std::istream& is,
return is;
}

static
namespace {
void
PD_convert (void* out,
const void* in,
Expand Down Expand Up @@ -960,6 +964,7 @@ PD_convert (void* out,
PD_fixdenormals(out, nitems, ord.format(), ord.order());
}
}
}

//
// Convert nitems in RealDescriptor format to native Real format.
Expand Down
20 changes: 10 additions & 10 deletions Src/Base/AMReX_GpuControl.H
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,13 @@ namespace Gpu {

#else

[[nodiscard]] inline static constexpr bool inLaunchRegion () { return false; }
[[nodiscard]] inline static constexpr bool notInLaunchRegion () { return true; }
[[nodiscard]] inline static constexpr bool setLaunchRegion (bool) { return false; }
[[nodiscard]] inline constexpr bool inLaunchRegion () { return false; }
[[nodiscard]] inline constexpr bool notInLaunchRegion () { return true; }
[[nodiscard]] inline constexpr bool setLaunchRegion (bool) { return false; }

[[nodiscard]] inline static constexpr bool inGraphRegion () { return false; }
[[nodiscard]] inline static constexpr bool notInGraphRegion () { return true; }
[[nodiscard]] inline static constexpr bool setGraphRegion (bool) { return false; }
[[nodiscard]] inline constexpr bool inGraphRegion () { return false; }
[[nodiscard]] inline constexpr bool notInGraphRegion () { return true; }
[[nodiscard]] inline constexpr bool setGraphRegion (bool) { return false; }

struct [[nodiscard]] LaunchSafeGuard
{
Expand All @@ -202,10 +202,10 @@ namespace Gpu {
explicit GraphSafeGuard (bool) {}
};

[[nodiscard]] inline static constexpr bool inSingleStreamRegion () { return false; }
[[nodiscard]] inline static constexpr bool inNoSyncRegion () { return true; }
[[nodiscard]] inline static constexpr bool setSingleStreamRegion (bool) { return false; }
[[nodiscard]] inline static constexpr bool setNoSyncRegion (bool) { return true; }
[[nodiscard]] inline constexpr bool inSingleStreamRegion () { return false; }
[[nodiscard]] inline constexpr bool inNoSyncRegion () { return true; }
[[nodiscard]] inline constexpr bool setSingleStreamRegion (bool) { return false; }
[[nodiscard]] inline constexpr bool setNoSyncRegion (bool) { return true; }
struct [[nodiscard]] SingleStreamRegion {};
struct [[nodiscard]] NoSyncRegion {};

Expand Down
4 changes: 2 additions & 2 deletions Src/Base/AMReX_GpuLaunch.H
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ namespace amrex {
namespace Gpu {

#ifdef AMREX_USE_GPU
static constexpr std::size_t numThreadsPerBlockParallelFor () {
inline constexpr std::size_t numThreadsPerBlockParallelFor () {
return AMREX_GPU_MAX_THREADS;
}
#else
static constexpr std::size_t numThreadsPerBlockParallelFor () { return 0; }
inline constexpr std::size_t numThreadsPerBlockParallelFor () { return 0; }
#endif

// ************************************************
Expand Down
15 changes: 10 additions & 5 deletions Src/Base/AMReX_ParmParse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@ extern "C" void amrex_finalize_namelist ();

namespace amrex {

namespace {
#ifdef AMREX_XSDK
static bool finalize_verbose = false;
bool finalize_verbose = false;
#else
static bool finalize_verbose = true;
bool finalize_verbose = true;
#endif
}

std::string const ParmParse::FileKeyword = "FILE";

Expand Down Expand Up @@ -1178,7 +1180,8 @@ ParmParse::appendTable(ParmParse::Table& tab)
g_table.splice(g_table.end(), tab);
}

static
namespace {

bool
unused_table_entries_q (const ParmParse::Table& table, const std::string& prefix = std::string())
{
Expand Down Expand Up @@ -1215,7 +1218,6 @@ unused_table_entries_q (const ParmParse::Table& table, const std::string& prefix
return false;
}

static
void
finalize_table (const std::string& pfx, const ParmParse::Table& table)
{
Expand Down Expand Up @@ -1243,6 +1245,8 @@ finalize_table (const std::string& pfx, const ParmParse::Table& table)
}
}

}

void
ParmParse::Initialize (int argc,
char** argv,
Expand Down Expand Up @@ -1278,7 +1282,7 @@ ParmParse::hasUnusedInputs (const std::string& prefix)
return unused_table_entries_q(g_table, prefix);
}

static
namespace {
void
get_entries_under_prefix (std::vector<std::string>& found_entries,
const ParmParse::Table& table,
Expand Down Expand Up @@ -1307,6 +1311,7 @@ get_entries_under_prefix (std::vector<std::string>& found_entries,
}
}
}
}

std::vector<std::string>
ParmParse::getUnusedInputs (const std::string& prefix)
Expand Down
14 changes: 9 additions & 5 deletions Src/Base/AMReX_VisMF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@

namespace amrex {

static const char *TheMultiFabHdrFileSuffix = "_H";
static const char *FabFileSuffix = "_D_";
static const char *TheFabOnDiskPrefix = "FabOnDisk:";
namespace {
const char *TheMultiFabHdrFileSuffix = "_H";
const char *FabFileSuffix = "_D_";
const char *TheFabOnDiskPrefix = "FabOnDisk:";
}

std::map<std::string, VisMF::PersistentIFStream> VisMF::persistentIFStreams;

Expand Down Expand Up @@ -192,7 +194,8 @@ operator>> (std::istream& is,
return is;
}

static
namespace {

std::ostream&
operator<< (std::ostream& os,
const Vector< Vector<Real> >& ar)
Expand All @@ -217,7 +220,6 @@ operator<< (std::ostream& os,
return os;
}

static
std::istream&
operator>> (std::istream& is,
Vector< Vector<Real> >& ar)
Expand Down Expand Up @@ -265,6 +267,8 @@ operator>> (std::istream& is,
return is;
}

}

std::ostream&
operator<< (std::ostream &os,
const VisMF::Header &hd)
Expand Down
Loading

0 comments on commit 45bc21e

Please sign in to comment.