summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/buildtool/build_engine/base_maps/entity_name.hpp19
-rw-r--r--src/buildtool/build_engine/expression/evaluator.cpp20
-rw-r--r--src/buildtool/build_engine/expression/target_node.hpp30
-rw-r--r--src/buildtool/common/repository_config.hpp5
-rw-r--r--src/buildtool/execution_api/bazel_msg/bazel_msg_factory.cpp2
-rw-r--r--src/buildtool/execution_api/common/tree_reader.hpp4
-rw-r--r--src/buildtool/file_system/file_root.hpp48
-rw-r--r--src/buildtool/file_system/git_repo.cpp11
-rw-r--r--src/buildtool/storage/local_cas.tpp1
-rw-r--r--src/other_tools/just_mr/main.cpp1
10 files changed, 63 insertions, 78 deletions
diff --git a/src/buildtool/build_engine/base_maps/entity_name.hpp b/src/buildtool/build_engine/base_maps/entity_name.hpp
index 8190157d..def2cbe6 100644
--- a/src/buildtool/build_engine/base_maps/entity_name.hpp
+++ b/src/buildtool/build_engine/base_maps/entity_name.hpp
@@ -96,10 +96,10 @@ template <typename T>
GetString(list[0]),
GetString(list[1])};
}
-
+ return std::nullopt;
} catch (...) {
+ return std::nullopt;
}
- return std::nullopt;
}
template <typename T>
@@ -141,9 +141,10 @@ template <typename T>
}
}
}
+ return std::nullopt;
} catch (...) {
+ return std::nullopt;
}
- return std::nullopt;
}
template <typename T>
// IsList(list) == true
@@ -171,9 +172,10 @@ template <typename T>
relmodule));
}
}
+ return std::nullopt;
} catch (...) {
+ return std::nullopt;
}
- return std::nullopt;
}
template <typename T>
@@ -202,10 +204,10 @@ template <typename T>
local_repo_name));
}
}
-
+ return std::nullopt;
} catch (...) {
+ return std::nullopt;
}
- return std::nullopt;
}
template <typename T>
@@ -243,9 +245,10 @@ template <typename T>
s0, list, list_size, current, logger);
}
}
+ return std::nullopt;
} catch (...) {
+ return std::nullopt;
}
- return std::nullopt;
}
template <typename T>
@@ -278,8 +281,8 @@ template <typename T>
}
return res;
} catch (...) {
+ return std::nullopt;
}
- return std::nullopt;
}
[[nodiscard]] inline auto ParseEntityNameFromJson(
diff --git a/src/buildtool/build_engine/expression/evaluator.cpp b/src/buildtool/build_engine/expression/evaluator.cpp
index 18fe7a76..ea2f547e 100644
--- a/src/buildtool/build_engine/expression/evaluator.cpp
+++ b/src/buildtool/build_engine/expression/evaluator.cpp
@@ -1399,17 +1399,11 @@ auto Evaluator::EvaluateExpression(
FunctionMap::MakePtr(kBuiltInFunctions, provider_functions));
} catch (EvaluationError const& ex) {
if (ex.UserContext()) {
- try {
- note_user_context();
- } catch (...) {
- // should not throw
- }
+ note_user_context();
}
- else {
- if (ex.WhileEvaluation()) {
- ss << "Expression evaluation traceback (most recent call last):"
- << std::endl;
- }
+ else if (ex.WhileEvaluation()) {
+ ss << "Expression evaluation traceback (most recent call last):"
+ << std::endl;
}
ss << ex.what();
for (auto const& object : ex.InvolvedObjects()) {
@@ -1418,11 +1412,7 @@ auto Evaluator::EvaluateExpression(
} catch (std::exception const& ex) {
ss << ex.what();
}
- try {
- logger(ss.str());
- } catch (...) {
- // should not throw
- }
+ logger(ss.str());
return ExpressionPtr{nullptr};
}
diff --git a/src/buildtool/build_engine/expression/target_node.hpp b/src/buildtool/build_engine/expression/target_node.hpp
index feed94d6..1e7cbd2e 100644
--- a/src/buildtool/build_engine/expression/target_node.hpp
+++ b/src/buildtool/build_engine/expression/target_node.hpp
@@ -62,21 +62,23 @@ class TargetNode {
[[nodiscard]] auto operator==(TargetNode const& other) const noexcept
-> bool {
- if (data_.index() == other.data_.index()) {
- try {
- if (IsValue()) {
- return GetValue() == other.GetValue();
- }
- auto const& abs_l = GetAbstract();
- auto const& abs_r = other.GetAbstract();
- return abs_l.node_type == abs_r.node_type and
- abs_l.string_fields == abs_r.string_fields and
- abs_l.target_fields == abs_r.string_fields;
- } catch (...) {
- // should never happen
+ if (data_.index() != other.data_.index()) {
+ return false;
+ }
+
+ try {
+ if (IsValue()) {
+ return GetValue() == other.GetValue();
}
+ auto const& abs_l = GetAbstract();
+ auto const& abs_r = other.GetAbstract();
+ return abs_l.node_type == abs_r.node_type and
+ abs_l.string_fields == abs_r.string_fields and
+ abs_l.target_fields == abs_r.string_fields;
+ } catch (...) {
+ // should never happen
+ return false;
}
- return false;
}
[[nodiscard]] auto ToString() const noexcept -> std::string {
@@ -84,8 +86,8 @@ class TargetNode {
return ToJson().dump();
} catch (...) {
// should never happen
+ return {};
}
- return {};
}
[[nodiscard]] auto ToJson() const -> nlohmann::json;
diff --git a/src/buildtool/common/repository_config.hpp b/src/buildtool/common/repository_config.hpp
index 3319a710..a9d01e34 100644
--- a/src/buildtool/common/repository_config.hpp
+++ b/src/buildtool/common/repository_config.hpp
@@ -172,10 +172,7 @@ class RepositoryConfig {
std::function<T const*(RepositoryInfo const&)> const&
getter) const noexcept -> T const* {
if (auto const* info = Info(repo)) {
- try { // satisfy clang-tidy's bugprone-exception-escape
- return getter(*info);
- } catch (...) {
- }
+ return getter(*info);
}
return nullptr;
}
diff --git a/src/buildtool/execution_api/bazel_msg/bazel_msg_factory.cpp b/src/buildtool/execution_api/bazel_msg/bazel_msg_factory.cpp
index 4a29f5f7..5bed3dfc 100644
--- a/src/buildtool/execution_api/bazel_msg/bazel_msg_factory.cpp
+++ b/src/buildtool/execution_api/bazel_msg/bazel_msg_factory.cpp
@@ -42,8 +42,8 @@ template <class T>
gsl::narrow<int>(content.size()));
return content;
} catch (...) {
+ return std::nullopt;
}
- return std::nullopt;
}
/// \brief Create protobuf message 'Platform'.
diff --git a/src/buildtool/execution_api/common/tree_reader.hpp b/src/buildtool/execution_api/common/tree_reader.hpp
index 857573df..20e73d7d 100644
--- a/src/buildtool/execution_api/common/tree_reader.hpp
+++ b/src/buildtool/execution_api/common/tree_reader.hpp
@@ -102,10 +102,10 @@ class TreeReader final {
store, parent, digest, include_trees)) {
return result;
}
+ return std::nullopt;
} catch (...) {
- // fallthrough
+ return std::nullopt;
}
- return std::nullopt;
}
private:
diff --git a/src/buildtool/file_system/file_root.hpp b/src/buildtool/file_system/file_root.hpp
index 6a34409c..82e30b89 100644
--- a/src/buildtool/file_system/file_root.hpp
+++ b/src/buildtool/file_system/file_root.hpp
@@ -185,23 +185,14 @@ class FileRoot {
[[nodiscard]] auto ContainsBlob(std::string const& name) const noexcept
-> bool {
- try {
- if (std::holds_alternative<tree_t>(data_)) {
- auto const& data = std::get<tree_t>(data_);
- auto ptr = data->LookupEntryByName(name);
- if (static_cast<bool>(ptr)) {
- return IsBlobObject(ptr->Type());
- }
- return false;
- }
- if (std::holds_alternative<pairs_t>(data_)) {
- auto const& data = std::get<pairs_t>(data_);
- auto it = data.find(name);
- return (it != data.end() and IsBlobObject(it->second));
- }
- } catch (...) {
+ if (auto const* const data = std::get_if<tree_t>(&data_)) {
+ auto const ptr = (*data)->LookupEntryByName(name);
+ return ptr != nullptr and IsBlobObject(ptr->Type());
+ }
+ if (auto const* const data = std::get_if<pairs_t>(&data_)) {
+ auto const it = data->find(name);
+ return it != data->end() and IsBlobObject(it->second);
}
-
return false;
}
@@ -339,18 +330,21 @@ class FileRoot {
std::string const& git_tree_id,
bool ignore_special = false) noexcept
-> std::optional<FileRoot> {
- if (auto cas = GitCAS::Open(repo_path)) {
- if (auto tree = GitTree::Read(cas, git_tree_id, ignore_special)) {
- try {
- return FileRoot{
- cas,
- std::make_shared<GitTree const>(std::move(*tree)),
- ignore_special};
- } catch (...) {
- }
- }
+ auto cas = GitCAS::Open(repo_path);
+ if (not cas) {
+ return std::nullopt;
+ }
+ auto tree = GitTree::Read(cas, git_tree_id, ignore_special);
+ if (not tree) {
+ return std::nullopt;
+ }
+ try {
+ return FileRoot{cas,
+ std::make_shared<GitTree const>(std::move(*tree)),
+ ignore_special};
+ } catch (...) {
+ return std::nullopt;
}
- return std::nullopt;
}
/// \brief Return a complete description of the content of this root, if
diff --git a/src/buildtool/file_system/git_repo.cpp b/src/buildtool/file_system/git_repo.cpp
index 489d50a7..481c0461 100644
--- a/src/buildtool/file_system/git_repo.cpp
+++ b/src/buildtool/file_system/git_repo.cpp
@@ -504,13 +504,10 @@ GitRepo::GitRepo(GitRepo&& other) noexcept
}
auto GitRepo::operator=(GitRepo&& other) noexcept -> GitRepo& {
- try {
- git_cas_ = std::move(other.git_cas_);
- repo_ = std::move(other.repo_);
- is_repo_fake_ = other.is_repo_fake_;
- other.git_cas_ = nullptr;
- } catch (...) {
- }
+ git_cas_ = std::move(other.git_cas_);
+ repo_ = std::move(other.repo_);
+ is_repo_fake_ = other.is_repo_fake_;
+ other.git_cas_ = nullptr;
return *this;
}
diff --git a/src/buildtool/storage/local_cas.tpp b/src/buildtool/storage/local_cas.tpp
index e47cffa4..29bf28f5 100644
--- a/src/buildtool/storage/local_cas.tpp
+++ b/src/buildtool/storage/local_cas.tpp
@@ -266,6 +266,7 @@ auto LocalCAS<kDoGlobalUplink>::LocalUplinkBazelDirectory(
seen->emplace(digest);
return true;
} catch (...) {
+ return false;
}
}
return false;
diff --git a/src/other_tools/just_mr/main.cpp b/src/other_tools/just_mr/main.cpp
index 42054395..dfe705d2 100644
--- a/src/other_tools/just_mr/main.cpp
+++ b/src/other_tools/just_mr/main.cpp
@@ -237,6 +237,7 @@ auto main(int argc, char* argv[]) -> int {
my_name = std::filesystem::path(argv[0]).filename().string();
} catch (...) {
// ignore, as my_name is only used for error messages
+ my_name.clear();
}
}
try {