summaryrefslogtreecommitdiff
path: root/src/buildtool/file_system/precomputed_root.hpp
diff options
context:
space:
mode:
authorKlaus T. Aehlig <aehlig@linta.de>2025-06-13 16:37:40 +0200
committerKlaus T. Aehlig <aehlig@linta.de>2025-06-16 17:23:33 +0200
commita78bd0abe451cde450bbc1eb56c1450b350dc255 (patch)
tree744679bcb9b550ae79d2bb4461f9048f136020cb /src/buildtool/file_system/precomputed_root.hpp
parentf4d3c39d9a5efa066adba7da13bef39d846b556f (diff)
downloadjustbuild-a78bd0abe451cde450bbc1eb56c1450b350dc255.tar.gz
Ensure equality operators are really noexcept.
... by explicitly catching any possible exception. Mainly to make clang-tidy happy. ...
Diffstat (limited to 'src/buildtool/file_system/precomputed_root.hpp')
-rw-r--r--src/buildtool/file_system/precomputed_root.hpp31
1 files changed, 29 insertions, 2 deletions
diff --git a/src/buildtool/file_system/precomputed_root.hpp b/src/buildtool/file_system/precomputed_root.hpp
index f95f7d73..a405d680 100644
--- a/src/buildtool/file_system/precomputed_root.hpp
+++ b/src/buildtool/file_system/precomputed_root.hpp
@@ -16,6 +16,7 @@
#define INCLUDED_SRC_BUILDTOOL_FILE_SYSTEM_PRECOMPUTED_ROOT_HPP
#include <cstddef>
+#include <exception>
#include <functional>
#include <optional>
#include <string>
@@ -23,6 +24,8 @@
#include <variant>
#include "nlohmann/json.hpp"
+#include "src/buildtool/logging/log_level.hpp"
+#include "src/buildtool/logging/logger.hpp"
#include "src/utils/cpp/expected.hpp"
struct ComputedRoot final {
@@ -86,11 +89,35 @@ class PrecomputedRoot final {
[[nodiscard]] auto operator==(PrecomputedRoot const& other) const noexcept
-> bool {
- return root_ == other.root_;
+ try {
+ return root_ == other.root_;
+ } catch (std::exception const& e) {
+ try {
+ Logger::Log(
+ LogLevel::Error, "Unexpected excpetion: {}", e.what());
+ std::terminate();
+ } catch (...) {
+ std::terminate();
+ }
+ } catch (...) {
+ std::terminate();
+ }
}
[[nodiscard]] auto operator<(PrecomputedRoot const& other) const noexcept
-> bool {
- return root_ < other.root_;
+ try {
+ return root_ < other.root_;
+ } catch (std::exception const& e) {
+ try {
+ Logger::Log(
+ LogLevel::Error, "Unexpected excpetion: {}", e.what());
+ std::terminate();
+ } catch (...) {
+ std::terminate();
+ }
+ } catch (...) {
+ std::terminate();
+ }
}
[[nodiscard]] auto ToString() const noexcept -> std::string;