Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions include/bout/boutexception.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ public:
BoutException(std::string msg);

template <class S, class... Args>
BoutException(const S& format, const Args&... args)
: BoutException(fmt::format(format, args...)) {}
BoutException(S&& format, Args&&... args)
: BoutException(fmt::format(fmt::runtime(std::forward<S>(format)),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: no header providing "fmt::runtime" is directly included [misc-include-cleaner]

include/bout/boutexception.hxx:10:

- #include "fmt/core.h"
+ #include "fmt/base.h"
+ #include "fmt/core.h"

std::forward<decltype(args)>(args)...)) {}

~BoutException() override;

Expand All @@ -46,16 +47,18 @@ class BoutRhsFail : public BoutException {
public:
BoutRhsFail(std::string message) : BoutException(std::move(message)) {}
template <class S, class... Args>
BoutRhsFail(const S& format, const Args&... args)
: BoutRhsFail(fmt::format(format, args...)) {}
BoutRhsFail(S&& format, Args&&... args)
: BoutRhsFail(fmt::format(fmt::runtime(std::forward<S>(format)),
std::forward<decltype(args)>(args)...)) {}
};

class BoutIterationFail : public BoutException {
public:
BoutIterationFail(std::string message) : BoutException(std::move(message)) {}
template <class S, class... Args>
BoutIterationFail(const S& format, const Args&... args)
: BoutIterationFail(fmt::format(format, args...)) {}
BoutIterationFail(S&& format, Args&&... args)
: BoutIterationFail(fmt::format(fmt::runtime(std::forward<S>(format)),
std::forward<decltype(args)>(args)...)) {}
};

#endif
6 changes: 3 additions & 3 deletions include/bout/msg_stack.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public:

template <class S, class... Args>
int push(const S& format, const Args&... args) {
return push(fmt::format(format, args...));
return push(fmt::format(fmt::runtime(format), args...));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay]

    return push(fmt::format(fmt::runtime(format), args...));
                                         ^

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: no header providing "fmt::runtime" is directly included [misc-include-cleaner]

include/bout/msg_stack.hxx:26:

- class MsgStack;
+ #include "fmt/base.h"
+ class MsgStack;

}

void pop(); ///< Remove the last message
Expand Down Expand Up @@ -145,8 +145,8 @@ public:

template <class S, class... Args>
MsgStackItem(const std::string& file, int line, const S& msg, const Args&... args)
: point(msg_stack.push("{:s} on line {:d} of '{:s}'", fmt::format(msg, args...),
line, file)) {}
: point(msg_stack.push("{:s} on line {:d} of '{:s}'",
fmt::format(fmt::runtime(msg), args...), line, file)) {}
~MsgStackItem() {
// If an exception has occurred, don't pop the message
if (exception_count == std::uncaught_exceptions()) {
Expand Down
4 changes: 2 additions & 2 deletions include/bout/optionsreader.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public:

template <class S, class... Args>
void read(Options* options, const S& format, const Args&... args) {
return read(options, fmt::format(format, args...));
return read(options, fmt::format(fmt::runtime(format), args...));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: no header providing "fmt::runtime" is directly included [misc-include-cleaner]

include/bout/optionsreader.hxx:31:

- class OptionsReader;
+ #include "fmt/base.h"
+ class OptionsReader;

}

/// Write options to file
Expand All @@ -82,7 +82,7 @@ public:

template <class S, class... Args>
void write(Options* options, const S& format, const Args&... args) {
return write(options, fmt::format(format, args...));
return write(options, fmt::format(fmt::runtime(format), args...));
}

/// Parse options from the command line
Expand Down
15 changes: 9 additions & 6 deletions include/bout/output.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ public:
}

template <class S, class... Args>
Output(const S& format, const Args&... args) : Output(fmt::format(format, args...)) {}
Output(const S& format, const Args&... args)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: no header providing "fmt::runtime" is directly included [misc-include-cleaner]

include/bout/output.hxx:25:

- class Output;
+ #include "fmt/base.h"
+ class Output;

: Output(fmt::format(fmt::runtime(format), args...)) {}

~Output() override { close(); }

Expand All @@ -88,7 +89,7 @@ public:

template <class S, class... Args>
int open(const S& format, const Args&... args) {
return open(fmt::format(format, args...));
return open(fmt::format(fmt::runtime(format), args...));
}

/// Close the log file
Expand All @@ -99,14 +100,14 @@ public:

template <class S, class... Args>
void write(const S& format, const Args&... args) {
write(fmt::format(format, args...));
write(fmt::format(fmt::runtime(format), args...));
}
/// Same as write, but only to screen
virtual void print(const std::string& message);

template <class S, class... Args>
void print(const S& format, const Args&... args) {
print(fmt::format(format, args...));
print(fmt::format(fmt::runtime(format), args...));
}

/// Add an output stream. All output will be sent to all streams
Expand Down Expand Up @@ -173,7 +174,8 @@ public:
void write(const S& format, const Args&... args) {
if (enabled) {
ASSERT1(base != nullptr);
base->write(fmt::format(format, args...));
base->write(
fmt::format(fmt::runtime(format), std::forward<decltype(args)>(args)...));
}
}

Expand All @@ -185,7 +187,8 @@ public:
void print(const S& format, const Args&... args) {
if (enabled) {
ASSERT1(base != nullptr);
base->print(fmt::format(format, args...));
base->print(
fmt::format(fmt::runtime(format), std::forward<decltype(args)>(args)...));
}
}

Expand Down
2 changes: 1 addition & 1 deletion include/bout/sys/expressionparser.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ public:

template <class S, class... Args>
ParseException(const S& format, const Args&... args)
: message(fmt::format(format, args...)) {}
: message(fmt::format(fmt::runtime(format), args...)) {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: no header providing "fmt::runtime" is directly included [misc-include-cleaner]

include/bout/sys/expressionparser.hxx:31:

- #include "fmt/core.h"
+ #include "fmt/base.h"
+ #include "fmt/core.h"


~ParseException() override = default;

Expand Down
1 change: 1 addition & 0 deletions include/bout/utils.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ typename std::vector<T, Alloc>::size_type erase_if(std::vector<T, Alloc>& c, Pre
return r;
}
#else
using std::erase;
using std::erase_if;
#endif
} // namespace utils
Expand Down
2 changes: 1 addition & 1 deletion src/bout++.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ template <class Factory>
// type. Note that this does require all the options are used in the
// constructor, and not in a `init` method or similar
std::cout << fmt::format("Input options for {} '{}':\n\n", Factory::type_name, type);
std::cout << fmt::format("{:id}\n", help_options);
std::cout << fmt::format(fmt::runtime("{:id}\n"), help_options);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: no header providing "fmt::runtime" is directly included [misc-include-cleaner]

src/bout++.cxx:27:

- #include "bout/build_config.hxx"
+ #include "fmt/base.h"
+ #include "bout/build_config.hxx"

std::exit(EXIT_SUCCESS);
}

Expand Down
59 changes: 34 additions & 25 deletions src/mesh/impls/bout/boutmesh.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,16 @@ CheckMeshResult checkBoutMeshYDecomposition(int num_y_processors, int ny,
// Check size of Y mesh if we've got multiple processors in Y
if (num_local_y_points < num_y_guards and num_y_processors != 1) {
return {false,
fmt::format(_("\t -> ny/NYPE ({:d}/{:d} = {:d}) must be >= MYG ({:d})\n"), ny,
num_y_processors, num_local_y_points, num_y_guards)};
fmt::format(fmt::runtime(_(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: no header providing "_" is directly included [misc-include-cleaner]

src/mesh/impls/bout/boutmesh.cxx:28:

- #include <bout/boundary_region.hxx>
+ #include "bout/sys/gettext.hxx"
+ #include <bout/boundary_region.hxx>

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: no header providing "fmt::format" is directly included [misc-include-cleaner]

src/mesh/impls/bout/boutmesh.cxx:27:

+ #include "fmt/format.h"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: no header providing "fmt::runtime" is directly included [misc-include-cleaner]

src/mesh/impls/bout/boutmesh.cxx:27:

+ #include "fmt/base.h"

"\t -> ny/NYPE ({:d}/{:d} = {:d}) must be >= MYG ({:d})\n")),
ny, num_y_processors, num_local_y_points, num_y_guards)};
}
// Check branch cuts
if ((jyseps1_1 + 1) % num_local_y_points != 0) {
return {false, fmt::format(_("\t -> Leg region jyseps1_1+1 ({:d}) must be a "
"multiple of MYSUB ({:d})\n"),
jyseps1_1 + 1, num_local_y_points)};
return {false,
fmt::format(fmt::runtime(_("\t -> Leg region jyseps1_1+1 ({:d}) must be a "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: no header providing "fmt::format" is directly included [misc-include-cleaner]

            fmt::format(fmt::runtime(_("\t -> Leg region jyseps1_1+1 ({:d}) must be a "
                 ^

"multiple of MYSUB ({:d})\n")),
jyseps1_1 + 1, num_local_y_points)};
}

if (jyseps2_1 != jyseps1_2) {
Expand All @@ -179,50 +181,57 @@ CheckMeshResult checkBoutMeshYDecomposition(int num_y_processors, int ny,
if ((jyseps2_1 - jyseps1_1) % num_local_y_points != 0) {
return {
false,
fmt::format(_("\t -> Core region jyseps2_1-jyseps1_1 ({:d}-{:d} = {:d}) must "
"be a multiple of MYSUB ({:d})\n"),
fmt::format(fmt::runtime(_(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: no header providing "fmt::format" is directly included [misc-include-cleaner]

          fmt::format(fmt::runtime(_(
               ^

"\t -> Core region jyseps2_1-jyseps1_1 ({:d}-{:d} = {:d}) must "
"be a multiple of MYSUB ({:d})\n")),
jyseps2_1, jyseps1_1, jyseps2_1 - jyseps1_1, num_local_y_points)};
}

if ((jyseps2_2 - jyseps1_2) % num_local_y_points != 0) {
return {
false,
fmt::format(_("\t -> Core region jyseps2_2-jyseps1_2 ({:d}-{:d} = {:d}) must "
"be a multiple of MYSUB ({:d})\n"),
fmt::format(fmt::runtime(_(
"\t -> Core region jyseps2_2-jyseps1_2 ({:d}-{:d} = {:d}) must "
"be a multiple of MYSUB ({:d})\n")),
jyseps2_2, jyseps1_2, jyseps2_2 - jyseps1_2, num_local_y_points)};
}

// Check upper legs
if ((ny_inner - jyseps2_1 - 1) % num_local_y_points != 0) {
return {
false,
fmt::format(_("\t -> leg region ny_inner-jyseps2_1-1 ({:d}-{:d}-1 = {:d}) must "
"be a multiple of MYSUB ({:d})\n"),
ny_inner, jyseps2_1, ny_inner - jyseps2_1 - 1, num_local_y_points)};
return {false,
fmt::format(
fmt::runtime(
_("\t -> leg region ny_inner-jyseps2_1-1 ({:d}-{:d}-1 = {:d}) must "
"be a multiple of MYSUB ({:d})\n")),
ny_inner, jyseps2_1, ny_inner - jyseps2_1 - 1, num_local_y_points)};
}
if ((jyseps1_2 - ny_inner + 1) % num_local_y_points != 0) {
return {
false,
fmt::format(_("\t -> leg region jyseps1_2-ny_inner+1 ({:d}-{:d}+1 = {:d}) must "
"be a multiple of MYSUB ({:d})\n"),
jyseps1_2, ny_inner, jyseps1_2 - ny_inner + 1, num_local_y_points)};
return {false,
fmt::format(
fmt::runtime(
_("\t -> leg region jyseps1_2-ny_inner+1 ({:d}-{:d}+1 = {:d}) must "
"be a multiple of MYSUB ({:d})\n")),
jyseps1_2, ny_inner, jyseps1_2 - ny_inner + 1, num_local_y_points)};
}
} else {
// Single Null
if ((jyseps2_2 - jyseps1_1) % num_local_y_points != 0) {
return {
false,
fmt::format(_("\t -> Core region jyseps2_2-jyseps1_1 ({:d}-{:d} = {:d}) must "
"be a multiple of MYSUB ({:d})\n"),
fmt::format(fmt::runtime(_(
"\t -> Core region jyseps2_2-jyseps1_1 ({:d}-{:d} = {:d}) must "
"be a multiple of MYSUB ({:d})\n")),
jyseps2_2, jyseps1_1, jyseps2_2 - jyseps1_1, num_local_y_points)};
}
}

if ((ny - jyseps2_2 - 1) % num_local_y_points != 0) {
return {false, fmt::format(
_("\t -> leg region ny-jyseps2_2-1 ({:d}-{:d}-1 = {:d}) must be a "
"multiple of MYSUB ({:d})\n"),
ny, jyseps2_2, ny - jyseps2_2 - 1, num_local_y_points)};
return {
false,
fmt::format(fmt::runtime(_(
"\t -> leg region ny-jyseps2_2-1 ({:d}-{:d}-1 = {:d}) must be a "
"multiple of MYSUB ({:d})\n")),
ny, jyseps2_2, ny - jyseps2_2 - 1, num_local_y_points)};
}

return {true, ""};
Expand Down
1 change: 0 additions & 1 deletion src/sys/boutexception.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include <bout/boutcomm.hxx>
#include <bout/boutexception.hxx>
#include <bout/msg_stack.hxx>
#include <bout/utils.hxx>
#include <mpi.h>

#if BOUT_USE_BACKTRACE
Expand Down
10 changes: 6 additions & 4 deletions src/sys/expressionparser.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -333,13 +333,15 @@ may need to change your input file.

// No matches, just point out the error
if (possible_matches.empty()) {
return fmt::format(message_template, name, problem_bit);
return fmt::format(fmt::runtime(message_template), name, problem_bit);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: no header providing "fmt::format" is directly included [misc-include-cleaner]

      return fmt::format(fmt::runtime(message_template), name, problem_bit);
                  ^

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: no header providing "fmt::runtime" is directly included [misc-include-cleaner]

src/sys/expressionparser.cxx:24:

- #include <bout/sys/expressionparser.hxx>
+ #include "fmt/base.h"
+ #include <bout/sys/expressionparser.hxx>

}

// Give the first suggestion as a possible alternative
std::string error_message = fmt::format(message_template, name, problem_bit);
error_message += fmt::format(_("\n {1: ^{2}}{0}\n Did you mean '{0}'?"),
possible_matches.begin()->name, "", start);
std::string error_message =
fmt::format(fmt::runtime(message_template), name, problem_bit);
error_message +=
fmt::format(fmt::runtime(_("\n {1: ^{2}}{0}\n Did you mean '{0}'?")),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: no header providing "fmt::format" is directly included [misc-include-cleaner]

        fmt::format(fmt::runtime(_("\n  {1: ^{2}}{0}\n  Did you mean '{0}'?")),
             ^

possible_matches.begin()->name, "", start);
return error_message;
};

Expand Down
19 changes: 12 additions & 7 deletions src/sys/options.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,8 @@ Array<BoutReal> Options::as<Array<BoutReal>>(const Array<BoutReal>& similar_to)
Array<BoutReal> result = bout::utils::visit(
ConvertContainer<Array<BoutReal>>{
fmt::format(
_("Value for option {:s} cannot be converted to an Array<BoutReal>"),
fmt::runtime(
_("Value for option {:s} cannot be converted to an Array<BoutReal>")),
full_name),
similar_to},
value);
Expand All @@ -770,7 +771,8 @@ Matrix<BoutReal> Options::as<Matrix<BoutReal>>(const Matrix<BoutReal>& similar_t
auto result = bout::utils::visit(
ConvertContainer<Matrix<BoutReal>>{
fmt::format(
_("Value for option {:s} cannot be converted to an Matrix<BoutReal>"),
fmt::runtime(
_("Value for option {:s} cannot be converted to an Matrix<BoutReal>")),
full_name),
similar_to},
value);
Expand All @@ -792,7 +794,8 @@ Tensor<BoutReal> Options::as<Tensor<BoutReal>>(const Tensor<BoutReal>& similar_t
auto result = bout::utils::visit(
ConvertContainer<Tensor<BoutReal>>{
fmt::format(
_("Value for option {:s} cannot be converted to an Tensor<BoutReal>"),
fmt::runtime(
_("Value for option {:s} cannot be converted to an Tensor<BoutReal>")),
full_name),
similar_to},
value);
Expand Down Expand Up @@ -1083,20 +1086,22 @@ bout::details::OptionsFormatterBase::format(const Options& options,
// Get all the child values first
for (const auto& child : children) {
if (child.second.isValue()) {
fmt::format_to(ctx.out(), format_string, child.second);
fmt::format_to(ctx.out(), fmt::runtime(format_string), child.second);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: no header providing "fmt::format_to" is directly included [misc-include-cleaner]

      fmt::format_to(ctx.out(), fmt::runtime(format_string), child.second);
           ^

fmt::format_to(ctx.out(), "\n");
}
}

// Now descend the tree, accumulating subsections
for (const auto& subsection : options.subsections()) {
fmt::format_to(ctx.out(), format_string, *subsection.second);
fmt::format_to(ctx.out(), fmt::runtime(format_string), *subsection.second);
}

return ctx.out();
}

std::string toString(const Options& value) { return fmt::format("{}", value); }
std::string toString(const Options& value) {
return fmt::format(fmt::runtime("{}"), value);
}

namespace bout {
void checkForUnusedOptions() {
Expand Down Expand Up @@ -1142,7 +1147,7 @@ void checkForUnusedOptions(const Options& options, const std::string& data_dir,
}
possible_misspellings += fmt::format("\nUnused option '{}', did you mean:\n", key);
for (const auto& match : fuzzy_matches) {
possible_misspellings += fmt::format("\t{:idk}\n", match.match);
possible_misspellings += fmt::format(fmt::runtime("\t{:idk}\n"), match.match);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/sys/options/options_ini.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ void OptionINI::write(Options* options, const std::string& filename) {
}

// Call recursive function to write to file
fout << fmt::format("{:uds}", *options);
fout << fmt::format(fmt::runtime("{:uds}"), *options);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: no header providing "fmt::format" is directly included [misc-include-cleaner]

src/sys/options/options_ini.cxx:52:

- #include <bout/boutexception.hxx>
+ #include "fmt/format.h"
+ #include <bout/boutexception.hxx>

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: no header providing "fmt::runtime" is directly included [misc-include-cleaner]

src/sys/options/options_ini.cxx:52:

- #include <bout/boutexception.hxx>
+ #include "fmt/base.h"
+ #include <bout/boutexception.hxx>


fout.close();
}
Expand Down
15 changes: 7 additions & 8 deletions tests/unit/fake_mesh.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -212,18 +212,17 @@ public:
"RGN_OUTER_X"};

// Sum up and get unique points in the boundaries defined above
addRegion2D("RGN_BNDRY",
std::accumulate(begin(boundary_names), end(boundary_names),
Region<Ind2D>{},
[this](Region<Ind2D>& a, const std::string& b) {
return a + getRegion2D(b);
})
.unique());
addRegion2D("RGN_BNDRY", std::accumulate(begin(boundary_names), end(boundary_names),
Region<Ind2D>{},
[&](Region<Ind2D> a, const std::string& b) {
return a + getRegion2D(b);
})
.unique());

addRegion3D("RGN_BNDRY",
std::accumulate(begin(boundary_names), end(boundary_names),
Region<Ind3D>{},
[this](Region<Ind3D>& a, const std::string& b) {
[this](Region<Ind3D> a, const std::string& b) {
return a + getRegion3D(b);
})
.unique());
Expand Down
Loading