diff options
author | Maksim Denisov <denisov.maksim@huawei.com> | 2024-10-08 10:58:25 +0200 |
---|---|---|
committer | Maksim Denisov <denisov.maksim@huawei.com> | 2024-10-08 15:41:50 +0200 |
commit | a054488f8417a40e22c4e1e0f9738f705785aa9e (patch) | |
tree | cf89fa8eb82af22b4a789e4ed8fcf8f0e4eba0f5 /src | |
parent | 6832ded200f7a563b9e2cf81148fd26fdb064fdd (diff) | |
download | justbuild-a054488f8417a40e22c4e1e0f9738f705785aa9e.tar.gz |
Name type template parameters using CamelCase.
Diffstat (limited to 'src')
-rw-r--r-- | src/buildtool/build_engine/base_maps/field_reader.hpp | 8 | ||||
-rw-r--r-- | src/buildtool/build_engine/base_maps/user_rule.hpp | 61 | ||||
-rw-r--r-- | src/buildtool/common/remote/client_common.hpp | 4 | ||||
-rw-r--r-- | src/buildtool/execution_api/remote/bazel/bazel_cas_client.cpp | 38 | ||||
-rw-r--r-- | src/buildtool/execution_api/remote/bazel/bazel_cas_client.hpp | 38 | ||||
-rw-r--r-- | src/buildtool/execution_api/remote/bazel/bazel_network.cpp | 6 | ||||
-rw-r--r-- | src/buildtool/execution_api/remote/bazel/bazel_network.hpp | 6 | ||||
-rw-r--r-- | src/buildtool/execution_engine/dag/dag.hpp | 20 | ||||
-rw-r--r-- | src/buildtool/logging/log_sink_file.hpp | 8 | ||||
-rw-r--r-- | src/buildtool/logging/logger.hpp | 24 | ||||
-rw-r--r-- | src/buildtool/system/system.hpp | 18 |
11 files changed, 115 insertions, 116 deletions
diff --git a/src/buildtool/build_engine/base_maps/field_reader.hpp b/src/buildtool/build_engine/base_maps/field_reader.hpp index f66c0b1b..a28999ab 100644 --- a/src/buildtool/build_engine/base_maps/field_reader.hpp +++ b/src/buildtool/build_engine/base_maps/field_reader.hpp @@ -58,10 +58,10 @@ class FieldReader { names_.reserve(size); ids_.reserve(size); } - template <class T_Name, class T_Id> - auto emplace_back(T_Name&& name, T_Id&& id) -> void { - names_.emplace_back(std::forward<T_Name>(name)); - ids_.emplace_back(std::forward<T_Id>(id)); + template <class TName, class TId> + auto emplace_back(TName&& name, TId&& id) -> void { + names_.emplace_back(std::forward<TName>(name)); + ids_.emplace_back(std::forward<TId>(id)); } private: diff --git a/src/buildtool/build_engine/base_maps/user_rule.hpp b/src/buildtool/build_engine/base_maps/user_rule.hpp index 327d1466..c2d46420 100644 --- a/src/buildtool/build_engine/base_maps/user_rule.hpp +++ b/src/buildtool/build_engine/base_maps/user_rule.hpp @@ -41,16 +41,15 @@ namespace BuildMaps::Base { // kTriangular=true Performs triangular compare, everyone with everyone. // kTriangular=false Performs linear compare, first with each of the rest. template <bool kTriangular, - InputIterableContainer T_Container, - InputIterableContainer... T_Rest, - OutputIterableContainer T_Result = - std::unordered_set<typename T_Container::value_type>> -[[nodiscard]] static inline auto GetDuplicates(T_Container const& first, - T_Rest const&... rest) - -> T_Result; - -template <InputIterableStringContainer T_Container> -[[nodiscard]] static inline auto JoinContainer(T_Container const& c, + InputIterableContainer TContainer, + InputIterableContainer... TRest, + OutputIterableContainer TResult = + std::unordered_set<typename TContainer::value_type>> +[[nodiscard]] static inline auto GetDuplicates(TContainer const& first, + TRest const&... rest) -> TResult; + +template <InputIterableStringContainer TContainer> +[[nodiscard]] static inline auto JoinContainer(TContainer const& c, std::string const& sep) -> std::string; @@ -342,9 +341,9 @@ using UserRulePtr = UserRule::Ptr; namespace detail { -template <HasSize T_Container, HasSize... T_Rest> -[[nodiscard]] static inline auto MaxSize(T_Container const& first, - T_Rest const&... rest) -> std::size_t { +template <HasSize TContainer, HasSize... TRest> +[[nodiscard]] static inline auto MaxSize(TContainer const& first, + TRest const&... rest) -> std::size_t { if constexpr (sizeof...(rest) > 0) { return std::max(first.size(), MaxSize(rest...)); } @@ -352,14 +351,14 @@ template <HasSize T_Container, HasSize... T_Rest> } template <bool kTriangular, - OutputIterableContainer T_Result, - InputIterableContainer T_First, - InputIterableContainer T_Second, - InputIterableContainer... T_Rest> -static auto inline FindDuplicates(gsl::not_null<T_Result*> const& dups, - T_First const& first, - T_Second const& second, - T_Rest const&... rest) -> void { + OutputIterableContainer TResult, + InputIterableContainer TFirst, + InputIterableContainer TSecond, + InputIterableContainer... TRest> +static auto inline FindDuplicates(gsl::not_null<TResult*> const& dups, + TFirst const& first, + TSecond const& second, + TRest const&... rest) -> void { ExpectsAudit(std::is_sorted(first.begin(), first.end()) and std::is_sorted(second.begin(), second.end())); std::set_intersection(first.begin(), @@ -382,13 +381,13 @@ static auto inline FindDuplicates(gsl::not_null<T_Result*> const& dups, } // namespace detail template <bool kTriangular, - InputIterableContainer T_Container, - InputIterableContainer... T_Rest, - OutputIterableContainer T_Result> -[[nodiscard]] static inline auto GetDuplicates(T_Container const& first, - T_Rest const&... rest) - -> T_Result { - auto dups = T_Result{}; + InputIterableContainer TContainer, + InputIterableContainer... TRest, + OutputIterableContainer TResult> +[[nodiscard]] static inline auto GetDuplicates(TContainer const& first, + TRest const&... rest) + -> TResult { + auto dups = TResult{}; constexpr auto kNumContainers = 1 + sizeof...(rest); if constexpr (kNumContainers > 1) { std::size_t size{}; @@ -400,13 +399,13 @@ template <bool kTriangular, size = std::min(first.size(), detail::MaxSize(rest...)); } dups.reserve(size); - detail::FindDuplicates<kTriangular, T_Result>(&dups, first, rest...); + detail::FindDuplicates<kTriangular, TResult>(&dups, first, rest...); } return dups; } -template <InputIterableStringContainer T_Container> -[[nodiscard]] static inline auto JoinContainer(T_Container const& c, +template <InputIterableStringContainer TContainer> +[[nodiscard]] static inline auto JoinContainer(TContainer const& c, std::string const& sep) -> std::string { std::ostringstream oss{}; diff --git a/src/buildtool/common/remote/client_common.hpp b/src/buildtool/common/remote/client_common.hpp index 58c19458..aecbf02f 100644 --- a/src/buildtool/common/remote/client_common.hpp +++ b/src/buildtool/common/remote/client_common.hpp @@ -72,11 +72,11 @@ s.message()); } -template <typename T_Status> +template <typename TStatus> [[maybe_unused]] static inline void LogStatus( Logger const* logger, LogLevel level, - T_Status const& s, + TStatus const& s, std::optional<std::string> const& prefix = std::nullopt) noexcept { auto msg = [&s, &prefix]() { return StatusString(s, prefix); }; if (logger == nullptr) { diff --git a/src/buildtool/execution_api/remote/bazel/bazel_cas_client.cpp b/src/buildtool/execution_api/remote/bazel/bazel_cas_client.cpp index e4ce1ce0..54654233 100644 --- a/src/buildtool/execution_api/remote/bazel/bazel_cas_client.cpp +++ b/src/buildtool/execution_api/remote/bazel/bazel_cas_client.cpp @@ -421,10 +421,10 @@ auto BazelCasClient::BlobSpliceSupport( hash_function, instance_name, stub_, &logger_); } -template <class T_ForwardIter> +template <class TForwardIter> auto BazelCasClient::FindMissingBlobs(std::string const& instance_name, - T_ForwardIter const& start, - T_ForwardIter const& end) const noexcept + TForwardIter const& start, + TForwardIter const& end) const noexcept -> std::vector<bazel_re::Digest> { std::vector<bazel_re::Digest> result; if (start == end) { @@ -606,9 +606,9 @@ auto BazelCasClient::BatchUpdateBlobs( namespace detail { // Getter for response contents (needs specialization, never implemented) -template <class T_Content, class T_Response> -static auto GetResponseContents(T_Response const&) noexcept - -> pb::RepeatedPtrField<T_Content> const&; +template <class TContent, class TResponse> +static auto GetResponseContents(TResponse const&) noexcept + -> pb::RepeatedPtrField<TContent> const&; // Specialization of GetResponseContents for 'FindMissingBlobsResponse' template <> @@ -636,26 +636,26 @@ auto GetResponseContents<bazel_re::Digest, bazel_re::SplitBlobResponse>( } // namespace detail -template <typename T_Request, typename T_ForwardIter> +template <typename TRequest, typename TForwardIter> auto BazelCasClient::CreateBatchRequestsMaxSize( std::string const& instance_name, - T_ForwardIter const& first, - T_ForwardIter const& last, + TForwardIter const& first, + TForwardIter const& last, std::string const& heading, - std::function<void(T_Request*, - typename T_ForwardIter::value_type const&)> const& - request_builder) const noexcept -> std::vector<T_Request> { + std::function<void(TRequest*, + typename TForwardIter::value_type const&)> const& + request_builder) const noexcept -> std::vector<TRequest> { if (first == last) { return {}; } - std::vector<T_Request> result; - T_Request accumulating_request; + std::vector<TRequest> result; + TRequest accumulating_request; std::for_each( first, last, [&instance_name, &accumulating_request, &result, &request_builder]( auto const& blob) { - T_Request request; + TRequest request; request.set_instance_name(instance_name); request_builder(&request, blob); if (accumulating_request.ByteSizeLong() + request.ByteSizeLong() > @@ -704,11 +704,11 @@ auto BazelCasClient::CreateGetTreeRequest( return request; } -template <class T_Content, class T_Response> +template <class TContent, class TResponse> auto BazelCasClient::ProcessResponseContents( - T_Response const& response) const noexcept -> std::vector<T_Content> { - std::vector<T_Content> output; - auto const& contents = detail::GetResponseContents<T_Content>(response); + TResponse const& response) const noexcept -> std::vector<TContent> { + std::vector<TContent> output; + auto const& contents = detail::GetResponseContents<TContent>(response); std::copy(contents.begin(), contents.end(), std::back_inserter(output)); return output; } diff --git a/src/buildtool/execution_api/remote/bazel/bazel_cas_client.hpp b/src/buildtool/execution_api/remote/bazel/bazel_cas_client.hpp index 3d23c235..e2ddc561 100644 --- a/src/buildtool/execution_api/remote/bazel/bazel_cas_client.hpp +++ b/src/buildtool/execution_api/remote/bazel/bazel_cas_client.hpp @@ -157,21 +157,21 @@ class BazelCasClient { std::unique_ptr<bazel_re::ContentAddressableStorage::Stub> stub_; Logger logger_{"RemoteCasClient"}; - template <class T_OutputIter> + template <class TOutputIter> [[nodiscard]] auto FindMissingBlobs(std::string const& instance_name, - T_OutputIter const& start, - T_OutputIter const& end) const noexcept + TOutputIter const& start, + TOutputIter const& end) const noexcept -> std::vector<bazel_re::Digest>; - template <typename T_Request, typename T_ForwardIter> + template <typename TRequest, typename TForwardIter> [[nodiscard]] auto CreateBatchRequestsMaxSize( std::string const& instance_name, - T_ForwardIter const& first, - T_ForwardIter const& last, + TForwardIter const& first, + TForwardIter const& last, std::string const& heading, - std::function<void(T_Request*, - typename T_ForwardIter::value_type const&)> const& - request_builder) const noexcept -> std::vector<T_Request>; + std::function<void(TRequest*, + typename TForwardIter::value_type const&)> const& + request_builder) const noexcept -> std::vector<TRequest>; [[nodiscard]] static auto CreateUpdateBlobsSingleRequest( BazelBlob const& b) noexcept @@ -185,22 +185,22 @@ class BazelCasClient { /// \brief Utility class for supporting the Retry strategy while parsing a /// BatchResponse - template <typename T_Content> + template <typename TContent> struct RetryProcessBatchResponse { bool ok{false}; - std::vector<T_Content> result; + std::vector<TContent> result; bool exit_retry_loop{false}; std::optional<std::string> error_msg; }; // If this function is defined in the .cpp file, clang raises an error // while linking - template <class T_Content, class T_Inner, class T_Response> + template <class TContent, class TInner, class TResponse> [[nodiscard]] auto ProcessBatchResponse( - T_Response const& response, - std::function<void(std::vector<T_Content>*, T_Inner const&)> const& - inserter) const noexcept -> RetryProcessBatchResponse<T_Content> { - std::vector<T_Content> output; + TResponse const& response, + std::function<void(std::vector<TContent>*, TInner const&)> const& + inserter) const noexcept -> RetryProcessBatchResponse<TContent> { + std::vector<TContent> output; for (auto const& res : response.responses()) { auto const& res_status = res.status(); if (res_status.code() == static_cast<int>(grpc::StatusCode::OK)) { @@ -220,9 +220,9 @@ class BazelCasClient { return {.ok = true, .result = std::move(output)}; } - template <class T_Content, class T_Response> - auto ProcessResponseContents(T_Response const& response) const noexcept - -> std::vector<T_Content>; + template <class TContent, class TResponse> + auto ProcessResponseContents(TResponse const& response) const noexcept + -> std::vector<TContent>; }; #endif // INCLUDED_SRC_BUILDTOOL_EXECUTION_API_REMOTE_BAZEL_BAZEL_CAS_CLIENT_HPP diff --git a/src/buildtool/execution_api/remote/bazel/bazel_network.cpp b/src/buildtool/execution_api/remote/bazel/bazel_network.cpp index 6cb7e905..0d53643d 100644 --- a/src/buildtool/execution_api/remote/bazel/bazel_network.cpp +++ b/src/buildtool/execution_api/remote/bazel/bazel_network.cpp @@ -73,9 +73,9 @@ auto BazelNetwork::BlobSpliceSupport() const noexcept -> bool { return cas_->BlobSpliceSupport(hash_function_, instance_name_); } -template <class T_Iter> -auto BazelNetwork::DoUploadBlobs(T_Iter const& first, - T_Iter const& last) noexcept -> bool { +template <class TIter> +auto BazelNetwork::DoUploadBlobs(TIter const& first, + TIter const& last) noexcept -> bool { try { // Partition the blobs according to their size. The first group collects // all the blobs that can be uploaded in batch, the second group gathers diff --git a/src/buildtool/execution_api/remote/bazel/bazel_network.hpp b/src/buildtool/execution_api/remote/bazel/bazel_network.hpp index 9a9f6139..0dce2fbd 100644 --- a/src/buildtool/execution_api/remote/bazel/bazel_network.hpp +++ b/src/buildtool/execution_api/remote/bazel/bazel_network.hpp @@ -99,9 +99,9 @@ class BazelNetwork { ExecutionConfiguration exec_config_{}; HashFunction const& hash_function_; - template <class T_Iter> - [[nodiscard]] auto DoUploadBlobs(T_Iter const& first, - T_Iter const& last) noexcept -> bool; + template <class TIter> + [[nodiscard]] auto DoUploadBlobs(TIter const& first, + TIter const& last) noexcept -> bool; }; #endif // INCLUDED_SRC_BUILDTOOL_EXECUTION_API_REMOTE_BAZEL_BAZEL_NETWORK_HPP diff --git a/src/buildtool/execution_engine/dag/dag.hpp b/src/buildtool/execution_engine/dag/dag.hpp index a479d8b6..ac205da9 100644 --- a/src/buildtool/execution_engine/dag/dag.hpp +++ b/src/buildtool/execution_engine/dag/dag.hpp @@ -47,23 +47,23 @@ class DirectedAcyclicGraph { public: /// \brief Abstract class for DAG nodes. - /// \tparam T_Content Type of content. - /// \tparam T_Other Type of neighboring nodes. + /// \tparam TContent Type of content. + /// \tparam TOther Type of neighboring nodes. /// TODO: once we have hashes, require sub classes to implement generating /// IDs depending on its unique content. - template <typename T_Content, typename T_Other> + template <typename TContent, typename TOther> class Node { public: - using OtherNode = T_Other; + using OtherNode = TOther; using OtherNodePtr = gsl::not_null<OtherNode*>; - explicit Node(T_Content&& content) noexcept + explicit Node(TContent&& content) noexcept : content_{std::move(content)} {} // NOLINTNEXTLINE(modernize-pass-by-value) - explicit Node(T_Content const& content) noexcept : content_{content} {} + explicit Node(TContent const& content) noexcept : content_{content} {} - Node(T_Content const& content, + Node(TContent const& content, std::vector<OtherNodePtr> const& parents, std::vector<OtherNodePtr> const& children) noexcept : content_{content}, parents_{parents}, children_{children} {} @@ -76,11 +76,11 @@ class DirectedAcyclicGraph { auto operator=(Node&&) -> Node& = delete; ~Node() = default; - [[nodiscard]] auto Content() const& noexcept -> T_Content const& { + [[nodiscard]] auto Content() const& noexcept -> TContent const& { return content_; } - [[nodiscard]] auto Content() && noexcept -> T_Content { + [[nodiscard]] auto Content() && noexcept -> TContent { return std::move(content_); } @@ -115,7 +115,7 @@ class DirectedAcyclicGraph { } private: - T_Content content_{}; + TContent content_{}; std::vector<OtherNodePtr> parents_{}; std::vector<OtherNodePtr> children_{}; }; diff --git a/src/buildtool/logging/log_sink_file.hpp b/src/buildtool/logging/log_sink_file.hpp index f4d16099..c6f0126c 100644 --- a/src/buildtool/logging/log_sink_file.hpp +++ b/src/buildtool/logging/log_sink_file.hpp @@ -40,12 +40,12 @@ #include "src/buildtool/logging/logger.hpp" /// \brief Thread-safe map of mutexes. -template <class T_Key> +template <class TKey> class MutexMap { public: /// \brief Create mutex for key and run callback if successfully created. /// Callback is executed while the internal map is still held exclusively. - void Create(T_Key const& key, std::function<void()> const& callback) { + void Create(TKey const& key, std::function<void()> const& callback) { std::lock_guard lock(mutex_); if (not map_.contains(key)) { [[maybe_unused]] auto& mutex = map_[key]; @@ -53,14 +53,14 @@ class MutexMap { } } /// \brief Get mutex for key, creates mutex if key does not exist. - [[nodiscard]] auto Get(T_Key const& key) noexcept -> std::mutex& { + [[nodiscard]] auto Get(TKey const& key) noexcept -> std::mutex& { std::lock_guard lock(mutex_); return map_[key]; } private: std::mutex mutex_; - std::unordered_map<T_Key, std::mutex> map_; + std::unordered_map<TKey, std::mutex> map_; }; class LogSinkFile final : public ILogSink { diff --git a/src/buildtool/logging/logger.hpp b/src/buildtool/logging/logger.hpp index f224edd8..613f2b25 100644 --- a/src/buildtool/logging/logger.hpp +++ b/src/buildtool/logging/logger.hpp @@ -67,13 +67,13 @@ class Logger { void SetLogLimit(LogLevel level) noexcept { log_limit_ = level; } /// \brief Emit log message from string via this logger instance. - template <class... T_Args> + template <class... TArgs> void Emit(LogLevel level, std::string const& msg, - T_Args&&... args) const noexcept { + TArgs&&... args) const noexcept { if (static_cast<int>(level) <= static_cast<int>(log_limit_)) { FormatAndForward( - this, sinks_, level, msg, std::forward<T_Args>(args)...); + this, sinks_, level, msg, std::forward<TArgs>(args)...); } } @@ -86,17 +86,17 @@ class Logger { } /// \brief Log message from string via LogConfig's sinks and log limit. - template <class... T_Args> + template <class... TArgs> static void Log(LogLevel level, std::string const& msg, - T_Args&&... args) noexcept { + TArgs&&... args) noexcept { if (static_cast<int>(level) <= static_cast<int>(LogConfig::LogLimit())) { FormatAndForward(nullptr, LogConfig::Sinks(), level, msg, - std::forward<T_Args>(args)...); + std::forward<TArgs>(args)...); } } @@ -112,11 +112,11 @@ class Logger { /// \brief Generic logging method. Provides a common interface between the /// global logger and named instances, hidden from the outside caller. /// For named instances no global configuration is used. - template <class... T_Args> + template <class... TArgs> static void Log(Logger const* logger, LogLevel level, std::string const& msg, - T_Args&&... args) noexcept { + TArgs&&... args) noexcept { if (static_cast<int>(level) <= static_cast<int>(logger != nullptr ? logger->log_limit_ : LogConfig::LogLimit())) { @@ -125,7 +125,7 @@ class Logger { logger != nullptr ? logger->sinks_ : LogConfig::Sinks(), level, msg, - std::forward<T_Args>(args)...); + std::forward<TArgs>(args)...); } } @@ -153,15 +153,15 @@ class Logger { std::vector<ILogSink::Ptr> sinks_; /// \brief Format message and forward to sinks. - template <class... T_Args> + template <class... TArgs> static void FormatAndForward( Logger const* logger, std::vector<ILogSink::Ptr> const& sinks, LogLevel level, std::string const& msg, // NOLINTNEXTLINE(cppcoreguidelines-missing-std-forward) - T_Args&&... args) noexcept { - if constexpr (sizeof...(T_Args) == 0) { + TArgs&&... args) noexcept { + if constexpr (sizeof...(TArgs) == 0) { // forward to sinks std::for_each(sinks.cbegin(), sinks.cend(), [&](auto& sink) { sink->Emit(logger, level, msg); diff --git a/src/buildtool/system/system.hpp b/src/buildtool/system/system.hpp index 06b45d79..5077351e 100644 --- a/src/buildtool/system/system.hpp +++ b/src/buildtool/system/system.hpp @@ -26,19 +26,19 @@ void ExitWithoutCleanup(int exit_code); /// \brief Obtain POSIX epoch time for a given clock. /// Clocks may have different epoch times. To obtain the POSIX epoch time /// (1970-01-01 00:00:00 UTC) for a given clock, it must be converted. -template <class T_Clock> -static auto GetPosixEpoch() -> std::chrono::time_point<T_Clock> { +template <class TClock> +static auto GetPosixEpoch() -> std::chrono::time_point<TClock> { // Since C++20, the system clock's default value is the POSIX epoch time. std::chrono::time_point<std::chrono::system_clock> sys_epoch{}; - if constexpr (std::is_same_v<T_Clock, std::chrono::system_clock>) { + if constexpr (std::is_same_v<TClock, std::chrono::system_clock>) { // No conversion necessary for the system clock. return sys_epoch; } - else if constexpr (ClockHasFromSys<T_Clock>) { + else if constexpr (ClockHasFromSys<TClock>) { // The correct C++20 way to perform the time point conversion. - return T_Clock::from_sys(sys_epoch); + return TClock::from_sys(sys_epoch); } - else if constexpr (ClockHasFromTime<T_Clock>) { + else if constexpr (ClockHasFromTime<TClock>) { // Older releases of libcxx did not implement the standard conversion // function from_sys() for std::chrono::file_clock. Instead the // non-standard function file_clock::from_time_t() must be used. Since @@ -46,11 +46,11 @@ static auto GetPosixEpoch() -> std::chrono::time_point<T_Clock> { // - https://reviews.llvm.org/D113027 // - https://reviews.llvm.org/D113430 // TODO(modernize): remove this once we require clang version >= 14.0.0 - return T_Clock::from_time_t( + return TClock::from_time_t( std::chrono::system_clock::to_time_t(sys_epoch)); } - static_assert(std::is_same_v<T_Clock, std::chrono::system_clock> or - ClockHasFromSys<T_Clock> or ClockHasFromTime<T_Clock>, + static_assert(std::is_same_v<TClock, std::chrono::system_clock> or + ClockHasFromSys<TClock> or ClockHasFromTime<TClock>, "Time point conversion function unavailable."); return {}; } |