diff options
Diffstat (limited to 'src/utils/cpp')
-rw-r--r-- | src/utils/cpp/TARGETS | 7 | ||||
-rw-r--r-- | src/utils/cpp/atomic.hpp | 6 | ||||
-rw-r--r-- | src/utils/cpp/concepts.hpp | 2 | ||||
-rw-r--r-- | src/utils/cpp/file_locking.cpp | 8 | ||||
-rw-r--r-- | src/utils/cpp/file_locking.hpp | 2 | ||||
-rw-r--r-- | src/utils/cpp/gsl.hpp | 3 | ||||
-rw-r--r-- | src/utils/cpp/hash_combine.hpp | 1 | ||||
-rw-r--r-- | src/utils/cpp/hex_string.hpp | 1 | ||||
-rw-r--r-- | src/utils/cpp/json.hpp | 5 | ||||
-rw-r--r-- | src/utils/cpp/path.hpp | 1 | ||||
-rw-r--r-- | src/utils/cpp/prefix.hpp | 1 | ||||
-rw-r--r-- | src/utils/cpp/tmp_dir.cpp | 3 | ||||
-rw-r--r-- | src/utils/cpp/tmp_dir.hpp | 2 | ||||
-rw-r--r-- | src/utils/cpp/transformed_range.hpp | 2 | ||||
-rw-r--r-- | src/utils/cpp/type_safe_arithmetic.hpp | 99 | ||||
-rw-r--r-- | src/utils/cpp/vector.hpp | 1 |
16 files changed, 24 insertions, 120 deletions
diff --git a/src/utils/cpp/TARGETS b/src/utils/cpp/TARGETS index f32a34b0..2a0b3f10 100644 --- a/src/utils/cpp/TARGETS +++ b/src/utils/cpp/TARGETS @@ -16,12 +16,7 @@ { "type": ["@", "rules", "CC", "library"] , "name": ["json"] , "hdrs": ["json.hpp"] - , "deps": - [ "gsl" - , ["@", "fmt", "", "fmt"] - , ["@", "gsl", "", "gsl"] - , ["@", "json", "", "json"] - ] + , "deps": ["gsl", ["@", "fmt", "", "fmt"], ["@", "json", "", "json"]] , "stage": ["src", "utils", "cpp"] } , "concepts": diff --git a/src/utils/cpp/atomic.hpp b/src/utils/cpp/atomic.hpp index 94bda75f..179e7f7a 100644 --- a/src/utils/cpp/atomic.hpp +++ b/src/utils/cpp/atomic.hpp @@ -17,9 +17,11 @@ #include <atomic> #include <condition_variable> +#include <memory> +#include <mutex> //std::unique_lock #include <shared_mutex> -#include <type_traits> -#include <utility> // std::move +#include <type_traits> // IWYU pragma: keep +#include <utility> // IWYU pragma: keep // Atomic wrapper with notify/wait capabilities. // TODO(modernize): Replace any use this class by C++20's std::atomic<T>, once diff --git a/src/utils/cpp/concepts.hpp b/src/utils/cpp/concepts.hpp index 7cf943b6..d1500e85 100644 --- a/src/utils/cpp/concepts.hpp +++ b/src/utils/cpp/concepts.hpp @@ -17,6 +17,8 @@ #include <chrono> #include <cstddef> +#include <ctime> +#include <iterator> #include <string> #include <type_traits> diff --git a/src/utils/cpp/file_locking.cpp b/src/utils/cpp/file_locking.cpp index 53cba2bf..34670708 100644 --- a/src/utils/cpp/file_locking.cpp +++ b/src/utils/cpp/file_locking.cpp @@ -14,15 +14,17 @@ #include "src/utils/cpp/file_locking.hpp" -#include <cerrno> // for errno -#include <cstring> // for strerror() - #ifdef __unix__ #include <sys/file.h> #else #error "Non-unix is not supported yet" #endif +#include <cerrno> // for errno +#include <cstring> // for strerror() +#include <exception> +#include <mutex> + #include "src/buildtool/file_system/file_system_manager.hpp" #include "src/buildtool/logging/log_level.hpp" #include "src/buildtool/logging/logger.hpp" diff --git a/src/utils/cpp/file_locking.hpp b/src/utils/cpp/file_locking.hpp index abcca121..cada63a1 100644 --- a/src/utils/cpp/file_locking.hpp +++ b/src/utils/cpp/file_locking.hpp @@ -15,8 +15,8 @@ #ifndef INCLUDED_SRC_OTHER_TOOLS_FILE_LOCKING_HPP #define INCLUDED_SRC_OTHER_TOOLS_FILE_LOCKING_HPP +#include <cstdio> #include <filesystem> -#include <memory> #include <optional> #include <utility> // std::move diff --git a/src/utils/cpp/gsl.hpp b/src/utils/cpp/gsl.hpp index 97e0afe7..c691d3d5 100644 --- a/src/utils/cpp/gsl.hpp +++ b/src/utils/cpp/gsl.hpp @@ -15,8 +15,6 @@ #ifndef INCLUDED_SRC_UTILS_CPP_GSL_HPP #define INCLUDED_SRC_UTILS_CPP_GSL_HPP -#include "gsl/gsl" - // implement EnsuresAudit/ExpectsAudit (from gsl-lite) only run in debug mode #ifdef NDEBUG // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) @@ -24,6 +22,7 @@ // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) #define EnsuresAudit(x) (void)0 #else +#include "gsl/gsl" // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) #define ExpectsAudit(x) Expects(x) // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) diff --git a/src/utils/cpp/hash_combine.hpp b/src/utils/cpp/hash_combine.hpp index 5a63abfa..5f098507 100644 --- a/src/utils/cpp/hash_combine.hpp +++ b/src/utils/cpp/hash_combine.hpp @@ -16,6 +16,7 @@ #define INCLUDED_SRC_UTILS_CPP_HASH_COMBINE_HPP #include <cstddef> +#include <functional> #include "gsl/gsl" diff --git a/src/utils/cpp/hex_string.hpp b/src/utils/cpp/hex_string.hpp index 5cca094a..3edb46af 100644 --- a/src/utils/cpp/hex_string.hpp +++ b/src/utils/cpp/hex_string.hpp @@ -19,7 +19,6 @@ #include <cctype> #include <cstddef> #include <iomanip> -#include <iostream> #include <optional> #include <sstream> #include <string> diff --git a/src/utils/cpp/json.hpp b/src/utils/cpp/json.hpp index 589a5884..8932e71f 100644 --- a/src/utils/cpp/json.hpp +++ b/src/utils/cpp/json.hpp @@ -17,14 +17,17 @@ #include <algorithm> #include <cstddef> +#include <exception> +#include <functional> +#include <iterator> #include <optional> #include <sstream> #include <string> #include <unordered_map> +#include <utility> #include "fmt/core.h" #include "fmt/ostream.h" -#include "gsl/gsl" #include "nlohmann/json.hpp" #include "src/utils/cpp/gsl.hpp" diff --git a/src/utils/cpp/path.hpp b/src/utils/cpp/path.hpp index 77ea647c..26d25e50 100644 --- a/src/utils/cpp/path.hpp +++ b/src/utils/cpp/path.hpp @@ -16,7 +16,6 @@ #define INCLUDED_SRC_UTILS_CPP_PATH_HPP #include <filesystem> -#include <sstream> [[nodiscard]] static inline auto ToNormalPath( std::filesystem::path const& p) noexcept -> std::filesystem::path { diff --git a/src/utils/cpp/prefix.hpp b/src/utils/cpp/prefix.hpp index 5574c01a..d6268b9c 100644 --- a/src/utils/cpp/prefix.hpp +++ b/src/utils/cpp/prefix.hpp @@ -15,7 +15,6 @@ #ifndef INCLUDED_SRC_UTILS_CPP_PREFIX_HPP #define INCLUDED_SRC_UTILS_CPP_PREFIX_HPP -#include <algorithm> #include <sstream> #include <string> diff --git a/src/utils/cpp/tmp_dir.cpp b/src/utils/cpp/tmp_dir.cpp index db41512b..7382ce5c 100644 --- a/src/utils/cpp/tmp_dir.cpp +++ b/src/utils/cpp/tmp_dir.cpp @@ -14,6 +14,9 @@ #include "src/utils/cpp/tmp_dir.hpp" +#include <cstdlib> +#include <vector> + #include "src/buildtool/file_system/file_system_manager.hpp" #include "src/buildtool/logging/log_level.hpp" #include "src/buildtool/logging/logger.hpp" diff --git a/src/utils/cpp/tmp_dir.hpp b/src/utils/cpp/tmp_dir.hpp index bff73916..92d24f52 100644 --- a/src/utils/cpp/tmp_dir.hpp +++ b/src/utils/cpp/tmp_dir.hpp @@ -15,10 +15,8 @@ #ifndef INCLUDED_SRC_OTHER_TOOLS_TMP_DIR_HPP #define INCLUDED_SRC_OTHER_TOOLS_TMP_DIR_HPP -#include <cstdlib> #include <filesystem> #include <memory> -#include <optional> #include <string> std::string const kDefaultTemplate{"tmp.XXXXXX"}; diff --git a/src/utils/cpp/transformed_range.hpp b/src/utils/cpp/transformed_range.hpp index cc3fe5d6..3d064d9c 100644 --- a/src/utils/cpp/transformed_range.hpp +++ b/src/utils/cpp/transformed_range.hpp @@ -19,7 +19,7 @@ #include <functional> #include <iterator> #include <type_traits> -#include <utility> //std::move +#include <utility> // IWYU pragma: keep #include <vector> #include "gsl/gsl" diff --git a/src/utils/cpp/type_safe_arithmetic.hpp b/src/utils/cpp/type_safe_arithmetic.hpp index 2076a5bf..8b84e89b 100644 --- a/src/utils/cpp/type_safe_arithmetic.hpp +++ b/src/utils/cpp/type_safe_arithmetic.hpp @@ -16,7 +16,6 @@ #define INCLUDED_SRC_UTILS_CPP_TYPE_SAFE_ARITHMETIC_HPP #include <limits> -#include <type_traits> #include "gsl/gsl" @@ -94,48 +93,6 @@ class TypeSafeArithmetic { auto pointer() const -> const_pointer_t { return &value_; } }; -// template <typename TAG> -// bool operator==(TypeSafeArithmetic<TAG> lhs, TypeSafeArithmetic<TAG> rhs) -// { -// return lhs.get() == rhs.get(); -// } -// -// template <typename TAG> -// bool operator!=(TypeSafeArithmetic<TAG> lhs, TypeSafeArithmetic<TAG> rhs) -// { -// return !(lhs == rhs); -// } -// -// template <typename TAG> -// bool operator>(TypeSafeArithmetic<TAG> lhs, TypeSafeArithmetic<TAG> rhs) -// { -// return lhs.get() > rhs.get(); -// } -// -// template <typename TAG> -// bool operator>=(TypeSafeArithmetic<TAG> lhs, TypeSafeArithmetic<TAG> rhs) -// { -// return lhs.get() >= rhs.get(); -// } -// -// template <typename TAG> -// bool operator<(TypeSafeArithmetic<TAG> lhs, TypeSafeArithmetic<TAG> rhs) -// { -// return lhs.get() < rhs.get(); -// } -// -// template <typename TAG> -// bool operator<=(TypeSafeArithmetic<TAG> lhs, TypeSafeArithmetic<TAG> rhs) -// { -// return lhs.get() <= rhs.get(); -// } -// -// template <typename TAG> -// TypeSafeArithmetic<TAG> operator+(TypeSafeArithmetic<TAG> lhs, -// TypeSafeArithmetic<TAG> rhs) { -// return TypeSafeArithmetic<TAG>{lhs.get() + rhs.get()}; -// } - template <typename TAG> auto operator+=(TypeSafeArithmetic<TAG>& lhs, TypeSafeArithmetic<TAG> rhs) -> TypeSafeArithmetic<TAG>& { @@ -143,50 +100,6 @@ auto operator+=(TypeSafeArithmetic<TAG>& lhs, return lhs; } -// template <typename TAG> -// TypeSafeArithmetic<TAG> operator-(TypeSafeArithmetic<TAG> lhs, -// TypeSafeArithmetic<TAG> rhs) { -// return TypeSafeArithmetic<TAG>{lhs.get() - rhs.get()}; -// } -// -// template <typename TAG> -// TypeSafeArithmetic<TAG>& operator-=(TypeSafeArithmetic<TAG>& lhs, -// TypeSafeArithmetic<TAG> rhs) { -// lhs.set(lhs.get() - rhs.get()); -// return lhs; -// } -// -// template <typename TAG> -// TypeSafeArithmetic<TAG> operator*(TypeSafeArithmetic<TAG> lhs, -// typename TAG::value_t rhs) { -// return TypeSafeArithmetic<TAG>{lhs.get() - rhs}; -// } -// -// template <typename TAG> -// TypeSafeArithmetic<TAG>& operator*=(TypeSafeArithmetic<TAG>& lhs, -// typename TAG::value_t rhs) { -// lhs.set(lhs.get() * rhs); -// return lhs; -// } -// -// template <typename TAG> -// TypeSafeArithmetic<TAG> operator/(TypeSafeArithmetic<TAG> lhs, -// typename TAG::value_t rhs) { -// return TypeSafeArithmetic<TAG>{lhs.get() / rhs}; -// } -// -// template <typename TAG> -// TypeSafeArithmetic<TAG>& operator/=(TypeSafeArithmetic<TAG>& lhs, -// typename TAG::value_t rhs) { -// lhs.set(lhs.get() / rhs); -// return lhs; -// } -// -// template <typename TAG> -// TypeSafeArithmetic<TAG>& operator++(TypeSafeArithmetic<TAG>& a) { -// return a += TypeSafeArithmetic<TAG>{1}; -// } - template <typename TAG> auto operator++(TypeSafeArithmetic<TAG>& a, int) -> TypeSafeArithmetic<TAG> { auto r = a; @@ -194,16 +107,4 @@ auto operator++(TypeSafeArithmetic<TAG>& a, int) -> TypeSafeArithmetic<TAG> { return r; } -// template <typename TAG> -// TypeSafeArithmetic<TAG>& operator--(TypeSafeArithmetic<TAG>& a) { -// return a -= TypeSafeArithmetic<TAG>{1}; -// } -// -// template <typename TAG> -// TypeSafeArithmetic<TAG> operator--(TypeSafeArithmetic<TAG>& a, int) { -// auto r = a; -// a += TypeSafeArithmetic<TAG>{1}; -// return r; -// } - #endif // INCLUDED_SRC_UTILS_CPP_TYPE_SAFE_ARITHMETIC_HPP diff --git a/src/utils/cpp/vector.hpp b/src/utils/cpp/vector.hpp index e5bcd3da..f89e3bea 100644 --- a/src/utils/cpp/vector.hpp +++ b/src/utils/cpp/vector.hpp @@ -16,6 +16,7 @@ #define INCLUDED_SRC_UTILS_CPP_VECTOR_HPP // small library to manipulate vectors +#include <algorithm> // IWYU pragma: keep #include <vector> // sort the passed vector and remove repeated entries |