From fe4bfd45fe46024f87ab372fc85dcab36cc1068c Mon Sep 17 00:00:00 2001 From: dan sinclair Date: Thu, 7 Apr 2022 16:55:55 +0000 Subject: [PATCH] Condense namespaces in tint/utils. This PR condenses the namespaces in the tint/utils folder. Change-Id: I6b541a6383386346a0b11ba46074a5981fe75f66 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/86028 Auto-Submit: Dan Sinclair Reviewed-by: Ben Clayton Commit-Queue: Dan Sinclair --- src/tint/utils/defer.h | 6 ++---- src/tint/utils/defer_test.cc | 6 ++---- src/tint/utils/enum_set.h | 6 ++---- src/tint/utils/enum_set_test.cc | 6 ++---- src/tint/utils/hash.h | 6 ++---- src/tint/utils/hash_test.cc | 6 ++---- src/tint/utils/io/command.h | 6 ++---- src/tint/utils/io/command_other.cc | 6 ++---- src/tint/utils/io/command_posix.cc | 6 ++---- src/tint/utils/io/command_test.cc | 6 ++---- src/tint/utils/io/command_windows.cc | 6 ++---- src/tint/utils/io/tmpfile.h | 6 ++---- src/tint/utils/io/tmpfile_other.cc | 6 ++---- src/tint/utils/io/tmpfile_posix.cc | 6 ++---- src/tint/utils/io/tmpfile_test.cc | 6 ++---- src/tint/utils/io/tmpfile_windows.cc | 6 ++---- src/tint/utils/map.h | 6 ++---- src/tint/utils/map_test.cc | 6 ++---- src/tint/utils/math.h | 6 ++---- src/tint/utils/math_test.cc | 6 ++---- src/tint/utils/reverse.h | 6 ++---- src/tint/utils/reverse_test.cc | 6 ++---- src/tint/utils/scoped_assignment.h | 6 ++---- src/tint/utils/scoped_assignment_test.cc | 6 ++---- src/tint/utils/string.h | 6 ++---- src/tint/utils/string_test.cc | 6 ++---- src/tint/utils/to_const_ptr_vec.h | 6 ++---- src/tint/utils/transform.h | 6 ++---- src/tint/utils/transform_test.cc | 6 ++---- src/tint/utils/unique_vector.h | 6 ++---- src/tint/utils/unique_vector_test.cc | 6 ++---- 31 files changed, 62 insertions(+), 124 deletions(-) diff --git a/src/tint/utils/defer.h b/src/tint/utils/defer.h index 4be704e961..ce586f94c7 100644 --- a/src/tint/utils/defer.h +++ b/src/tint/utils/defer.h @@ -19,8 +19,7 @@ #include "src/tint/utils/concat.h" -namespace tint { -namespace utils { +namespace tint::utils { /// Defer executes a function or function like object when it is destructed. template @@ -51,8 +50,7 @@ inline Defer MakeDefer(F&& f) { return Defer(std::forward(f)); } -} // namespace utils -} // namespace tint +} // namespace tint::utils /// TINT_DEFER(S) executes the statement(s) `S` when exiting the current lexical /// scope. diff --git a/src/tint/utils/defer_test.cc b/src/tint/utils/defer_test.cc index fe1034c4cf..27fd9b5ef3 100644 --- a/src/tint/utils/defer_test.cc +++ b/src/tint/utils/defer_test.cc @@ -16,8 +16,7 @@ #include "gtest/gtest.h" -namespace tint { -namespace utils { +namespace tint::utils { namespace { TEST(DeferTest, Basic) { @@ -40,5 +39,4 @@ TEST(DeferTest, DeferOrder) { } } // namespace -} // namespace utils -} // namespace tint +} // namespace tint::utils diff --git a/src/tint/utils/enum_set.h b/src/tint/utils/enum_set.h index a4fc621ae5..c5af0f9f07 100644 --- a/src/tint/utils/enum_set.h +++ b/src/tint/utils/enum_set.h @@ -21,8 +21,7 @@ #include #include -namespace tint { -namespace utils { +namespace tint::utils { /// EnumSet is a set of enum values. /// @note As the EnumSet is backed by a single uint64_t value, it can only hold @@ -237,8 +236,7 @@ inline std::ostream& operator<<(std::ostream& out, EnumSet set) { return out << "}"; } -} // namespace utils -} // namespace tint +} // namespace tint::utils namespace std { diff --git a/src/tint/utils/enum_set_test.cc b/src/tint/utils/enum_set_test.cc index 566701ca24..f0e4e67bea 100644 --- a/src/tint/utils/enum_set_test.cc +++ b/src/tint/utils/enum_set_test.cc @@ -19,8 +19,7 @@ #include "gmock/gmock.h" -namespace tint { -namespace utils { +namespace tint::utils { namespace { using ::testing::ElementsAre; @@ -240,5 +239,4 @@ TEST(EnumSetTest, Ostream) { } } // namespace -} // namespace utils -} // namespace tint +} // namespace tint::utils diff --git a/src/tint/utils/hash.h b/src/tint/utils/hash.h index 1158021b10..e043e81fe8 100644 --- a/src/tint/utils/hash.h +++ b/src/tint/utils/hash.h @@ -20,8 +20,7 @@ #include #include -namespace tint { -namespace utils { +namespace tint::utils { namespace detail { /// Helper for obtaining a seed bias value for HashCombine with a bit-width @@ -77,7 +76,6 @@ size_t Hash(const ARGS&... args) { return hash; } -} // namespace utils -} // namespace tint +} // namespace tint::utils #endif // SRC_TINT_UTILS_HASH_H_ diff --git a/src/tint/utils/hash_test.cc b/src/tint/utils/hash_test.cc index caeba57160..ec88a8ca23 100644 --- a/src/tint/utils/hash_test.cc +++ b/src/tint/utils/hash_test.cc @@ -18,8 +18,7 @@ #include "gtest/gtest.h" -namespace tint { -namespace utils { +namespace tint::utils { namespace { TEST(HashTests, Basic) { @@ -45,5 +44,4 @@ TEST(HashTests, Vector) { } } // namespace -} // namespace utils -} // namespace tint +} // namespace tint::utils diff --git a/src/tint/utils/io/command.h b/src/tint/utils/io/command.h index dbf587ef77..63ddab83a3 100644 --- a/src/tint/utils/io/command.h +++ b/src/tint/utils/io/command.h @@ -18,8 +18,7 @@ #include #include -namespace tint { -namespace utils { +namespace tint::utils { /// Command is a helper used by tests for executing a process with a number of /// arguments and an optional stdin string, and then collecting and returning @@ -78,7 +77,6 @@ class Command { std::string input_; }; -} // namespace utils -} // namespace tint +} // namespace tint::utils #endif // SRC_TINT_UTILS_IO_COMMAND_H_ diff --git a/src/tint/utils/io/command_other.cc b/src/tint/utils/io/command_other.cc index 5562e372a4..5ae73daaa9 100644 --- a/src/tint/utils/io/command_other.cc +++ b/src/tint/utils/io/command_other.cc @@ -14,8 +14,7 @@ #include "src/tint/utils/io/command.h" -namespace tint { -namespace utils { +namespace tint::utils { Command::Command(const std::string&) {} @@ -33,5 +32,4 @@ Command::Output Command::Exec(std::initializer_list) const { return out; } -} // namespace utils -} // namespace tint +} // namespace tint::utils diff --git a/src/tint/utils/io/command_posix.cc b/src/tint/utils/io/command_posix.cc index dc6068438c..3696921d2e 100644 --- a/src/tint/utils/io/command_posix.cc +++ b/src/tint/utils/io/command_posix.cc @@ -21,8 +21,7 @@ #include #include -namespace tint { -namespace utils { +namespace tint::utils { namespace { @@ -261,5 +260,4 @@ Command::Output Command::Exec( } } -} // namespace utils -} // namespace tint +} // namespace tint::utils diff --git a/src/tint/utils/io/command_test.cc b/src/tint/utils/io/command_test.cc index f76dcaeee5..1b8bb83680 100644 --- a/src/tint/utils/io/command_test.cc +++ b/src/tint/utils/io/command_test.cc @@ -16,8 +16,7 @@ #include "gtest/gtest.h" -namespace tint { -namespace utils { +namespace tint::utils { namespace { #ifdef _WIN32 @@ -88,5 +87,4 @@ TEST(CommandTest, False) { #endif } // namespace -} // namespace utils -} // namespace tint +} // namespace tint::utils diff --git a/src/tint/utils/io/command_windows.cc b/src/tint/utils/io/command_windows.cc index 576fc4c3e1..d59f849c7c 100644 --- a/src/tint/utils/io/command_windows.cc +++ b/src/tint/utils/io/command_windows.cc @@ -19,8 +19,7 @@ #include #include -namespace tint { -namespace utils { +namespace tint::utils { namespace { @@ -245,5 +244,4 @@ Command::Output Command::Exec( return output; } -} // namespace utils -} // namespace tint +} // namespace tint::utils diff --git a/src/tint/utils/io/tmpfile.h b/src/tint/utils/io/tmpfile.h index 07f48afd10..6f81a891e9 100644 --- a/src/tint/utils/io/tmpfile.h +++ b/src/tint/utils/io/tmpfile.h @@ -18,8 +18,7 @@ #include #include -namespace tint { -namespace utils { +namespace tint::utils { /// TmpFile constructs a temporary file that can be written to, and is /// automatically deleted on destruction. @@ -70,7 +69,6 @@ class TmpFile { std::string path_; }; -} // namespace utils -} // namespace tint +} // namespace tint::utils #endif // SRC_TINT_UTILS_IO_TMPFILE_H_ diff --git a/src/tint/utils/io/tmpfile_other.cc b/src/tint/utils/io/tmpfile_other.cc index b4c1a18ee9..7ddbb58155 100644 --- a/src/tint/utils/io/tmpfile_other.cc +++ b/src/tint/utils/io/tmpfile_other.cc @@ -14,8 +14,7 @@ #include "src/tint/utils/io/tmpfile.h" -namespace tint { -namespace utils { +namespace tint::utils { TmpFile::TmpFile(std::string) {} @@ -25,5 +24,4 @@ bool TmpFile::Append(const void*, size_t) const { return false; } -} // namespace utils -} // namespace tint +} // namespace tint::utils diff --git a/src/tint/utils/io/tmpfile_posix.cc b/src/tint/utils/io/tmpfile_posix.cc index db9ee47d83..00c20fe8da 100644 --- a/src/tint/utils/io/tmpfile_posix.cc +++ b/src/tint/utils/io/tmpfile_posix.cc @@ -19,8 +19,7 @@ #include "src/tint/debug.h" -namespace tint { -namespace utils { +namespace tint::utils { namespace { @@ -66,5 +65,4 @@ bool TmpFile::Append(const void* data, size_t size) const { return false; } -} // namespace utils -} // namespace tint +} // namespace tint::utils diff --git a/src/tint/utils/io/tmpfile_test.cc b/src/tint/utils/io/tmpfile_test.cc index abd9511023..d312922f28 100644 --- a/src/tint/utils/io/tmpfile_test.cc +++ b/src/tint/utils/io/tmpfile_test.cc @@ -18,8 +18,7 @@ #include "gtest/gtest.h" -namespace tint { -namespace utils { +namespace tint::utils { namespace { TEST(TmpFileTest, WriteReadAppendDelete) { @@ -86,5 +85,4 @@ TEST(TmpFileTest, FileExtension) { } } // namespace -} // namespace utils -} // namespace tint +} // namespace tint::utils diff --git a/src/tint/utils/io/tmpfile_windows.cc b/src/tint/utils/io/tmpfile_windows.cc index 2b57b6878e..40dffc826d 100644 --- a/src/tint/utils/io/tmpfile_windows.cc +++ b/src/tint/utils/io/tmpfile_windows.cc @@ -17,8 +17,7 @@ #include #include -namespace tint { -namespace utils { +namespace tint::utils { namespace { @@ -59,5 +58,4 @@ bool TmpFile::Append(const void* data, size_t size) const { return true; } -} // namespace utils -} // namespace tint +} // namespace tint::utils diff --git a/src/tint/utils/map.h b/src/tint/utils/map.h index 0f60d13edc..12c93d4971 100644 --- a/src/tint/utils/map.h +++ b/src/tint/utils/map.h @@ -17,8 +17,7 @@ #include -namespace tint { -namespace utils { +namespace tint::utils { /// Lookup is a utility function for fetching a value from an unordered map if /// it exists, otherwise returning the `if_missing` argument. @@ -56,7 +55,6 @@ V GetOrCreate(std::unordered_map& map, return value; } -} // namespace utils -} // namespace tint +} // namespace tint::utils #endif // SRC_TINT_UTILS_MAP_H_ diff --git a/src/tint/utils/map_test.cc b/src/tint/utils/map_test.cc index a1e8decc83..ae35aeb36e 100644 --- a/src/tint/utils/map_test.cc +++ b/src/tint/utils/map_test.cc @@ -18,8 +18,7 @@ #include "gtest/gtest.h" -namespace tint { -namespace utils { +namespace tint::utils { namespace { TEST(Lookup, Test) { @@ -54,5 +53,4 @@ TEST(GetOrCreateTest, ExistingKey) { } } // namespace -} // namespace utils -} // namespace tint +} // namespace tint::utils diff --git a/src/tint/utils/math.h b/src/tint/utils/math.h index 155e39fb49..c6d7d461f0 100644 --- a/src/tint/utils/math.h +++ b/src/tint/utils/math.h @@ -19,8 +19,7 @@ #include #include -namespace tint { -namespace utils { +namespace tint::utils { /// @param alignment the next multiple to round `value` to /// @param value the value to round to the next multiple of `alignment` @@ -51,7 +50,6 @@ inline std::enable_if_t::value, T> MaxAlignOf(T value) { return pot; } -} // namespace utils -} // namespace tint +} // namespace tint::utils #endif // SRC_TINT_UTILS_MATH_H_ diff --git a/src/tint/utils/math_test.cc b/src/tint/utils/math_test.cc index 057f142918..d6be3f6787 100644 --- a/src/tint/utils/math_test.cc +++ b/src/tint/utils/math_test.cc @@ -16,8 +16,7 @@ #include "gtest/gtest.h" -namespace tint { -namespace utils { +namespace tint::utils { namespace { TEST(MathTests, RoundUp) { @@ -79,5 +78,4 @@ TEST(MathTests, MaxAlignOf) { } } // namespace -} // namespace utils -} // namespace tint +} // namespace tint::utils diff --git a/src/tint/utils/reverse.h b/src/tint/utils/reverse.h index 17b1346a19..fb4f237cd0 100644 --- a/src/tint/utils/reverse.h +++ b/src/tint/utils/reverse.h @@ -17,8 +17,7 @@ #include -namespace tint { -namespace utils { +namespace tint::utils { namespace detail { /// Used by utils::Reverse to hold the underlying iterable. @@ -58,7 +57,6 @@ detail::ReverseIterable Reverse(T&& iterable) { return {iterable}; } -} // namespace utils -} // namespace tint +} // namespace tint::utils #endif // SRC_TINT_UTILS_REVERSE_H_ diff --git a/src/tint/utils/reverse_test.cc b/src/tint/utils/reverse_test.cc index 64734cdf4d..b23c799508 100644 --- a/src/tint/utils/reverse_test.cc +++ b/src/tint/utils/reverse_test.cc @@ -18,8 +18,7 @@ #include "gmock/gmock.h" -namespace tint { -namespace utils { +namespace tint::utils { namespace { TEST(ReverseTest, Vector) { @@ -32,5 +31,4 @@ TEST(ReverseTest, Vector) { } } // namespace -} // namespace utils -} // namespace tint +} // namespace tint::utils diff --git a/src/tint/utils/scoped_assignment.h b/src/tint/utils/scoped_assignment.h index 0ff3421195..fdd787f1e5 100644 --- a/src/tint/utils/scoped_assignment.h +++ b/src/tint/utils/scoped_assignment.h @@ -20,8 +20,7 @@ #include "src/tint/utils/concat.h" -namespace tint { -namespace utils { +namespace tint::utils { /// Helper class that temporarily assigns a value to a variable for the lifetime /// of the ScopedAssignment object. Once the ScopedAssignment is destructed, the @@ -50,8 +49,7 @@ class ScopedAssignment { T old_value_; }; -} // namespace utils -} // namespace tint +} // namespace tint::utils /// TINT_SCOPED_ASSIGNMENT(var, val) assigns `val` to `var`, and automatically /// restores the original value of `var` when exiting the current lexical scope. diff --git a/src/tint/utils/scoped_assignment_test.cc b/src/tint/utils/scoped_assignment_test.cc index 20cd8d003b..3055afe5d7 100644 --- a/src/tint/utils/scoped_assignment_test.cc +++ b/src/tint/utils/scoped_assignment_test.cc @@ -16,8 +16,7 @@ #include "gtest/gtest.h" -namespace tint { -namespace utils { +namespace tint::utils { namespace { TEST(ScopedAssignmentTest, Scopes) { @@ -43,5 +42,4 @@ TEST(ScopedAssignmentTest, Scopes) { } } // namespace -} // namespace utils -} // namespace tint +} // namespace tint::utils diff --git a/src/tint/utils/string.h b/src/tint/utils/string.h index 0355819c75..011e326c0c 100644 --- a/src/tint/utils/string.h +++ b/src/tint/utils/string.h @@ -17,8 +17,7 @@ #include -namespace tint { -namespace utils { +namespace tint::utils { /// @param str the string to apply replacements to /// @param substr the string to search for @@ -35,7 +34,6 @@ inline std::string ReplaceAll(std::string str, return str; } -} // namespace utils -} // namespace tint +} // namespace tint::utils #endif // SRC_TINT_UTILS_STRING_H_ diff --git a/src/tint/utils/string_test.cc b/src/tint/utils/string_test.cc index 3dbb4861d5..f394ed73ee 100644 --- a/src/tint/utils/string_test.cc +++ b/src/tint/utils/string_test.cc @@ -16,8 +16,7 @@ #include "gtest/gtest.h" -namespace tint { -namespace utils { +namespace tint::utils { namespace { TEST(StringTest, ReplaceAll) { @@ -34,5 +33,4 @@ TEST(StringTest, ReplaceAll) { } } // namespace -} // namespace utils -} // namespace tint +} // namespace tint::utils diff --git a/src/tint/utils/to_const_ptr_vec.h b/src/tint/utils/to_const_ptr_vec.h index e36fe0c9ff..a46b3badef 100644 --- a/src/tint/utils/to_const_ptr_vec.h +++ b/src/tint/utils/to_const_ptr_vec.h @@ -18,8 +18,7 @@ #include -namespace tint { -namespace utils { +namespace tint::utils { /// @param in a vector of `T*` /// @returns a vector of `const T*` with the content of `in`. @@ -33,7 +32,6 @@ std::vector ToConstPtrVec(const std::vector& in) { return out; } -} // namespace utils -} // namespace tint +} // namespace tint::utils #endif // SRC_TINT_UTILS_TO_CONST_PTR_VEC_H_ diff --git a/src/tint/utils/transform.h b/src/tint/utils/transform.h index 97711fddf0..29a9740893 100644 --- a/src/tint/utils/transform.h +++ b/src/tint/utils/transform.h @@ -22,8 +22,7 @@ #include "src/tint/traits.h" -namespace tint { -namespace utils { +namespace tint::utils { /// Transform performs an element-wise transformation of a vector. /// @param in the input vector. @@ -56,7 +55,6 @@ auto Transform(const std::vector& in, TRANSFORMER&& transform) return result; } -} // namespace utils -} // namespace tint +} // namespace tint::utils #endif // SRC_TINT_UTILS_TRANSFORM_H_ diff --git a/src/tint/utils/transform_test.cc b/src/tint/utils/transform_test.cc index 6686eeb200..e6688242b0 100644 --- a/src/tint/utils/transform_test.cc +++ b/src/tint/utils/transform_test.cc @@ -23,8 +23,7 @@ static_assert(std::is_same::value, \ "unexpected result vector element type") -namespace tint { -namespace utils { +namespace tint::utils { namespace { TEST(TransformTest, Empty) { @@ -90,5 +89,4 @@ TEST(TransformTest, TransformDifferentType) { } } // namespace -} // namespace utils -} // namespace tint +} // namespace tint::utils diff --git a/src/tint/utils/unique_vector.h b/src/tint/utils/unique_vector.h index 96d3ac3f7d..32d593ef0b 100644 --- a/src/tint/utils/unique_vector.h +++ b/src/tint/utils/unique_vector.h @@ -21,8 +21,7 @@ #include #include -namespace tint { -namespace utils { +namespace tint::utils { /// UniqueVector is an ordered container that only contains unique items. /// Attempting to add a duplicate is a no-op. @@ -107,7 +106,6 @@ struct UniqueVector { std::unordered_set set; }; -} // namespace utils -} // namespace tint +} // namespace tint::utils #endif // SRC_TINT_UTILS_UNIQUE_VECTOR_H_ diff --git a/src/tint/utils/unique_vector_test.cc b/src/tint/utils/unique_vector_test.cc index 892282b240..c2c47a4067 100644 --- a/src/tint/utils/unique_vector_test.cc +++ b/src/tint/utils/unique_vector_test.cc @@ -17,8 +17,7 @@ #include "gtest/gtest.h" -namespace tint { -namespace utils { +namespace tint::utils { namespace { TEST(UniqueVectorTest, Empty) { @@ -141,5 +140,4 @@ TEST(UniqueVectorTest, PopBack) { } } // namespace -} // namespace utils -} // namespace tint +} // namespace tint::utils