Skip to content

Commit

Permalink
IOSS: Clang-tidy suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
gsjaardema committed Apr 10, 2024
1 parent 14680f2 commit a741dd6
Show file tree
Hide file tree
Showing 12 changed files with 35 additions and 43 deletions.
2 changes: 1 addition & 1 deletion packages/seacas/libraries/ioss/src/Ioss_CoordinateFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace Ioss {
IOSS_NODISCARD bool equal(const Ioss::CoordinateFrame &rhs) const;

private:
bool equal_(const Ioss::CoordinateFrame &rhs, bool quiet) const;
IOSS_NODISCARD bool equal_(const Ioss::CoordinateFrame &rhs, bool quiet) const;
std::vector<double> pointList_{};
int64_t id_{};
char tag_;
Expand Down
9 changes: 4 additions & 5 deletions packages/seacas/libraries/ioss/src/Ioss_ElementTopology.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ namespace Ioss {
}

~ETRegistry();
std::map<std::string, std::string> customFieldTypes;

private:
Ioss::ElementTopologyMap m_registry;
Expand Down Expand Up @@ -147,12 +146,12 @@ namespace Ioss {

protected:
ElementTopology(std::string type, std::string master_elem_name, bool delete_me = false);
virtual bool validate_permutation_nodes() const { return true; }
IOSS_NODISCARD virtual bool validate_permutation_nodes() const { return true; }

private:
bool equal_(const Ioss::ElementTopology &rhs, bool quiet) const;
const std::string name_;
const std::string masterElementName_;
IOSS_NODISCARD bool equal_(const Ioss::ElementTopology &rhs, bool quiet) const;
const std::string name_;
const std::string masterElementName_;

static const std::string &topology_shape_to_permutation_name(Ioss::ElementShape topoShape);

Expand Down
2 changes: 0 additions & 2 deletions packages/seacas/libraries/ioss/src/Ioss_FaceBlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ namespace Ioss {
FaceBlock(DatabaseIO *io_database, const std::string &my_name, const std::string &face_type,
int64_t number_faces);

FaceBlock(const FaceBlock &) = default;

IOSS_NODISCARD std::string type_string() const override { return "FaceBlock"; }
IOSS_NODISCARD std::string short_type_string() const override { return "faceblock"; }
IOSS_NODISCARD std::string contains_string() const override { return "Face"; }
Expand Down
2 changes: 1 addition & 1 deletion packages/seacas/libraries/ioss/src/Ioss_FieldManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ namespace Ioss {
void erase(const std::string &field_name);

// Checks if a field with 'field_name' exists in the database.
bool exists(const std::string &field_name) const;
IOSS_NODISCARD bool exists(const std::string &field_name) const;

IOSS_NODISCARD Field get(const std::string &field_name) const;
IOSS_NODISCARD const Field &getref(const std::string &field_name) const;
Expand Down
12 changes: 4 additions & 8 deletions packages/seacas/libraries/ioss/src/Ioss_GetLongOpt.C
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
// Copyright(C) 1999-2021, 2023 National Technology & Engineering Solutions
// Copyright(C) 1999-2021, 2023, 2024 National Technology & Engineering Solutions
// of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
// NTESS, the U.S. Government retains certain rights in this software.
//
// See packages/seacas/LICENSE for details

/* S Manoharan. Advanced Computer Research Institute. Lyon. France */
#include "Ioss_GetLongOpt.h"
#include <cstdio>
#include <cstring>
#include <fmt/color.h>
#include <fmt/core.h>
#include <fmt/ostream.h>
#include <sstream>
#include <stdio.h>

namespace Ioss {
/** \brief Create an empty options database.
*
* \param optmark The command line symbol designating options.
*/
GetLongOption::GetLongOption(const char optmark) : optmarker(optmark)
{
ustring = "[valid options and arguments]";
}
GetLongOption::GetLongOption(const char optmark) : optmarker(optmark) {}

/** \brief Frees dynamically allocated memory.
*
Expand Down Expand Up @@ -108,8 +105,7 @@ namespace Ioss {
*/
const char *GetLongOption::retrieve(const char *const opt) const
{
Cell *t;
for (t = table; t != nullptr; t = t->next) {
for (Cell *t = table; t != nullptr; t = t->next) {
if (strcmp(opt, t->option) == 0) {
return t->value;
}
Expand Down
6 changes: 3 additions & 3 deletions packages/seacas/libraries/ioss/src/Ioss_GetLongOpt.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright(C) 1999-2023 National Technology & Engineering Solutions
* Copyright(C) 1999-2024 National Technology & Engineering Solutions
* of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
* NTESS, the U.S. Government retains certain rights in this software.
*
Expand Down Expand Up @@ -41,8 +41,8 @@ namespace Ioss {
Cell() = default;
};

Cell *table{nullptr}; // option table
const char *ustring{nullptr}; // usage message
Cell *table{nullptr}; // option table
const char *ustring{"[valid options and arguments]"};
char *pname{nullptr}; // program basename
Cell *last{nullptr}; // last entry in option table
char optmarker; // option marker
Expand Down
1 change: 1 addition & 0 deletions packages/seacas/libraries/ioss/src/Ioss_NullEntity.C
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
//
// See packages/seacas/LICENSE for details

#include "Ioss_GroupingEntity.h"
#include "Ioss_NullEntity.h"

namespace Ioss {
Expand Down
2 changes: 1 addition & 1 deletion packages/seacas/libraries/ioss/src/Ioss_Property.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ namespace Ioss {
IOSS_NODISCARD bool operator!=(const Ioss::Property &rhs) const;
IOSS_NODISCARD bool operator==(const Ioss::Property &rhs) const;

friend void swap(Ioss::Property &first, Ioss::Property &second) // nothrow
friend void swap(Ioss::Property &first, Ioss::Property &second) noexcept
{
using std::swap;
swap(first.name_, second.name_);
Expand Down
1 change: 0 additions & 1 deletion packages/seacas/libraries/ioss/src/Ioss_PropertyManager.C
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include "Ioss_Utils.h"
#include <cstddef>
#include <fmt/ostream.h>
#include <ostream>
#include <string>

#include "Ioss_CodeTypes.h"
Expand Down
29 changes: 13 additions & 16 deletions packages/seacas/libraries/ioss/src/Ioss_Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,15 @@ template <typename T> IOSS_NODISCARD constexpr T *Data(std::vector<T> &vec)
if (vec.empty()) {
return nullptr;
}
else {
return vec.data();
}
return vec.data();
}

template <typename T> IOSS_NODISCARD constexpr const T *Data(const std::vector<T> &vec)
{
if (vec.empty()) {
return nullptr;
}
else {
return vec.data();
}
return vec.data();
}

template <typename T, size_t N> IOSS_NODISCARD constexpr T *Data(std::array<T, N> &arr)
Expand All @@ -88,18 +84,17 @@ namespace Ioss {
*/
class IOSS_EXPORT Utils
{
public:
/**
* \defgroup IossStreams Streams used for IOSS output
*@{
*/
static std::ostream
*m_outputStream; ///< general informational output (very rare). Default std::cerr
static std::ostream *m_debugStream; ///< debug output when requested. Default std::cerr
static std::ostream *m_warningStream; ///< IOSS warning output. Default std::cerr
static std::string m_preWarningText; ///< is a string that prepends all warning message output.
///< Default is "\nIOSS WARNING: "

public:
/**
* \defgroup IossStreams Streams used for IOSS output
*@{
*/
/** \brief set the stream for all streams (output, debug, and warning) to the specified
* `out_stream`
*/
Expand All @@ -117,6 +112,8 @@ namespace Ioss {
*/
IOSS_NODISCARD static std::ostream &get_output_stream();

IOSS_NODISCARD static std::string &get_warning_text() { return m_preWarningText; }

/** \brief set the output stream to the specified `output_stream`
*/
static void set_output_stream(std::ostream &output_stream);
Expand Down Expand Up @@ -608,16 +605,16 @@ namespace Ioss {
}
};

inline std::ostream &OUTPUT() { return *Utils::m_outputStream; }
inline std::ostream &OUTPUT() { return Utils::get_output_stream(); }

inline std::ostream &DebugOut() { return *Utils::m_debugStream; }
inline std::ostream &DebugOut() { return Utils::get_debug_stream(); }

inline std::ostream &WarnOut(bool output_prewarning = true)
{
if (output_prewarning) {
*Utils::m_warningStream << Utils::m_preWarningText;
Utils::get_warning_stream() << Utils::get_warning_text();
}
return *Utils::m_warningStream;
return Utils::get_warning_stream();
}

} // namespace Ioss
8 changes: 5 additions & 3 deletions packages/seacas/libraries/ioss/src/Ioss_VariableType.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ namespace Ioss {

class IOSS_EXPORT Registry
{
friend class VariableType;

public:
void insert(const Ioss::VTM_ValuePair &value, bool delete_me);
IOSS_NODISCARD VariableTypeMap::iterator begin() { return m_registry.begin(); }
Expand All @@ -36,11 +38,11 @@ namespace Ioss {
}

~Registry();
std::map<std::string, std::string> customFieldTypes;

private:
Ioss::VariableTypeMap m_registry;
std::vector<Ioss::VariableType *> m_deleteThese;
std::map<std::string, std::string> customFieldTypes;
Ioss::VariableTypeMap m_registry;
std::vector<Ioss::VariableType *> m_deleteThese;
};

struct IOSS_EXPORT Suffix
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright(C) 1999-2023 National Technology & Engineering Solutions
// Copyright(C) 1999-2024 National Technology & Engineering Solutions
// of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
// NTESS, the U.S. Government retains certain rights in this software.
//
Expand All @@ -8,9 +8,9 @@
#include "Ioss_SmartAssert.h"
#include "cgns/Iocgns_StructuredZoneData.h"
#include <assert.h>
#include <cstdlib>
#include <fmt/core.h>
#include <fmt/format.h>
#include <stdlib.h>
#if !defined __NVCC__
#include <fmt/color.h>
#endif
Expand Down

0 comments on commit a741dd6

Please sign in to comment.