Enable `Wunsafe-buffer-usage` in Tint cmake.

Add the `Wunsafe-buffer-usage` flag to the Tint CMake build. Each file
which triggered the warning has had a pragma added to suppress the
warning for that file. The spirv-tools includes have also been wrapped
as they trigger the warning.

Change-Id: I69959b1e4c0ec9d017ca12bfcb4fb2328e58b621
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/222574
Auto-Submit: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
diff --git a/src/tint/CMakeLists.txt b/src/tint/CMakeLists.txt
index 5877c61..9b1465c 100644
--- a/src/tint/CMakeLists.txt
+++ b/src/tint/CMakeLists.txt
@@ -112,14 +112,13 @@
     -Wno-c++98-compat
     -Wno-c++98-compat-pedantic
     -Wno-format-pedantic
-    -Wno-gnu-zero-variadic-macro-arguments
     -Wno-poison-system-directories
     -Wno-return-std-move-in-c++11
     -Wno-undefined-var-template
     -Wno-unknown-warning-option
-    -Wno-unsafe-buffer-usage
     -Wno-used-but-marked-unused
     -Weverything
+    -Wunsafe-buffer-usage
   )
 
   if(COMPILER_IS_GNU)
diff --git a/src/tint/cmd/info/main.cc b/src/tint/cmd/info/main.cc
index ae35de9..7943cb6 100644
--- a/src/tint/cmd/info/main.cc
+++ b/src/tint/cmd/info/main.cc
@@ -35,6 +35,8 @@
 #include "src/tint/lang/wgsl/inspector/entry_point.h"
 #include "src/tint/utils/text/string.h"
 
+TINT_BEGIN_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
+
 namespace {
 
 struct Options {
@@ -324,3 +326,5 @@
 
     return 0;
 }
+
+TINT_END_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
diff --git a/src/tint/cmd/loopy/main.cc b/src/tint/cmd/loopy/main.cc
index f0a3d91..2ac68ee 100644
--- a/src/tint/cmd/loopy/main.cc
+++ b/src/tint/cmd/loopy/main.cc
@@ -64,6 +64,8 @@
 #include "src/tint/lang/wgsl/writer/writer.h"
 #endif  // TINT_BUILD_WGSL_WRITER
 
+TINT_BEGIN_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
+
 namespace {
 
 enum class Format {
@@ -470,3 +472,5 @@
 
     return 0;
 }
+
+TINT_END_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
diff --git a/src/tint/cmd/remote_compile/main.cc b/src/tint/cmd/remote_compile/main.cc
index 187d2c9..1366345 100644
--- a/src/tint/cmd/remote_compile/main.cc
+++ b/src/tint/cmd/remote_compile/main.cc
@@ -43,6 +43,8 @@
 #include "src/tint/utils/macros/compiler.h"
 #include "src/tint/utils/socket.h"
 
+TINT_BEGIN_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
+
 namespace {
 
 /// The return structure of a compile function
@@ -533,3 +535,5 @@
     }
     return true;
 }
+
+TINT_END_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
diff --git a/src/tint/cmd/tint/main.cc b/src/tint/cmd/tint/main.cc
index 69a15e4..3986b8f 100644
--- a/src/tint/cmd/tint/main.cc
+++ b/src/tint/cmd/tint/main.cc
@@ -98,6 +98,8 @@
 #include "src/tint/lang/glsl/validate/validate.h"
 #endif  // TINT_BUILD_GLSL_VALIDATOR
 
+TINT_BEGIN_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
+
 namespace {
 
 /// Prints the given hash value in a format string that the end-to-end test runner can parse.
@@ -1451,3 +1453,5 @@
     }
     return success ? 0 : 1;
 }
+
+TINT_END_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
diff --git a/src/tint/lang/core/constant/eval.cc b/src/tint/lang/core/constant/eval.cc
index e255a57..c0dd1e2 100644
--- a/src/tint/lang/core/constant/eval.cc
+++ b/src/tint/lang/core/constant/eval.cc
@@ -62,6 +62,8 @@
 using namespace tint::core::fluent_types;     // NOLINT
 using namespace tint::core::number_suffixes;  // NOLINT
 
+TINT_BEGIN_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
+
 namespace tint::core::constant {
 namespace {
 
@@ -4028,3 +4030,5 @@
 }
 
 }  // namespace tint::core::constant
+
+TINT_END_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
diff --git a/src/tint/lang/core/intrinsic/table_data.h b/src/tint/lang/core/intrinsic/table_data.h
index 15cb837..8d55f3e 100644
--- a/src/tint/lang/core/intrinsic/table_data.h
+++ b/src/tint/lang/core/intrinsic/table_data.h
@@ -40,6 +40,8 @@
 #include "src/tint/utils/text/styled_text.h"
 #include "src/tint/utils/text/text_style.h"
 
+TINT_BEGIN_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
+
 /// Forward declaration
 namespace tint::core::intrinsic {
 struct TableData;
@@ -673,4 +675,6 @@
 
 }  // namespace tint::core::intrinsic
 
+TINT_END_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
+
 #endif  // SRC_TINT_LANG_CORE_INTRINSIC_TABLE_DATA_H_
diff --git a/src/tint/lang/glsl/validate/validate.cc b/src/tint/lang/glsl/validate/validate.cc
index eacb251..1f378e3 100644
--- a/src/tint/lang/glsl/validate/validate.cc
+++ b/src/tint/lang/glsl/validate/validate.cc
@@ -30,7 +30,11 @@
 #include <string>
 
 #include "glslang/Public/ResourceLimits.h"
+
+TINT_BEGIN_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
 #include "glslang/Public/ShaderLang.h"
+TINT_END_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
+
 #include "src/tint/utils/macros/static_init.h"
 #include "src/tint/utils/text/string_stream.h"
 
diff --git a/src/tint/lang/hlsl/writer/ast_printer/ast_printer.cc b/src/tint/lang/hlsl/writer/ast_printer/ast_printer.cc
index 5d39af6..b15fbcf 100644
--- a/src/tint/lang/hlsl/writer/ast_printer/ast_printer.cc
+++ b/src/tint/lang/hlsl/writer/ast_printer/ast_printer.cc
@@ -102,6 +102,8 @@
 using namespace tint::core::number_suffixes;  // NOLINT
 using namespace tint::core::fluent_types;     // NOLINT
 
+TINT_BEGIN_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
+
 namespace tint::hlsl::writer {
 namespace {
 
@@ -4901,3 +4903,5 @@
 }
 
 }  // namespace tint::hlsl::writer
+
+TINT_END_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
diff --git a/src/tint/lang/msl/writer/common/printer_support.cc b/src/tint/lang/msl/writer/common/printer_support.cc
index a303738..9bf56c3 100644
--- a/src/tint/lang/msl/writer/common/printer_support.cc
+++ b/src/tint/lang/msl/writer/common/printer_support.cc
@@ -43,6 +43,8 @@
 #include "src/tint/utils/rtti/switch.h"
 #include "src/tint/utils/strconv/float_to_string.h"
 
+TINT_BEGIN_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
+
 namespace tint::msl::writer {
 
 std::string BuiltinToAttribute(core::BuiltinValue builtin) {
@@ -271,3 +273,5 @@
 }
 
 }  // namespace tint::msl::writer
+
+TINT_END_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
diff --git a/src/tint/lang/spirv/reader/ast_parser/ast_parser.h b/src/tint/lang/spirv/reader/ast_parser/ast_parser.h
index 760f31b..f53f371 100644
--- a/src/tint/lang/spirv/reader/ast_parser/ast_parser.h
+++ b/src/tint/lang/spirv/reader/ast_parser/ast_parser.h
@@ -43,7 +43,9 @@
 TINT_BEGIN_DISABLE_WARNING(OLD_STYLE_CAST);
 TINT_BEGIN_DISABLE_WARNING(SIGN_CONVERSION);
 TINT_BEGIN_DISABLE_WARNING(WEAK_VTABLES);
+TINT_BEGIN_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
 #include "source/opt/ir_context.h"
+TINT_END_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
 TINT_END_DISABLE_WARNING(WEAK_VTABLES);
 TINT_END_DISABLE_WARNING(SIGN_CONVERSION);
 TINT_END_DISABLE_WARNING(OLD_STYLE_CAST);
diff --git a/src/tint/lang/spirv/reader/ast_parser/function.cc b/src/tint/lang/spirv/reader/ast_parser/function.cc
index cbc8af0..786b189 100644
--- a/src/tint/lang/spirv/reader/ast_parser/function.cc
+++ b/src/tint/lang/spirv/reader/ast_parser/function.cc
@@ -157,8 +157,9 @@
 using namespace tint::core::number_suffixes;  // NOLINT
 using namespace tint::core::fluent_types;     // NOLINT
 
-namespace tint::spirv::reader::ast_parser {
+TINT_BEGIN_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
 
+namespace tint::spirv::reader::ast_parser {
 namespace {
 
 constexpr uint32_t kMaxVectorLen = 4;
@@ -6474,3 +6475,5 @@
 TINT_INSTANTIATE_TYPEINFO(tint::spirv::reader::ast_parser::SwitchStatementBuilder);
 TINT_INSTANTIATE_TYPEINFO(tint::spirv::reader::ast_parser::IfStatementBuilder);
 TINT_INSTANTIATE_TYPEINFO(tint::spirv::reader::ast_parser::LoopStatementBuilder);
+
+TINT_BEGIN_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
diff --git a/src/tint/lang/spirv/reader/ast_parser/helper_test.h b/src/tint/lang/spirv/reader/ast_parser/helper_test.h
index 5ea3cf7..5fe1e86 100644
--- a/src/tint/lang/spirv/reader/ast_parser/helper_test.h
+++ b/src/tint/lang/spirv/reader/ast_parser/helper_test.h
@@ -40,7 +40,9 @@
 TINT_BEGIN_DISABLE_WARNING(OLD_STYLE_CAST);
 TINT_BEGIN_DISABLE_WARNING(SIGN_CONVERSION);
 TINT_BEGIN_DISABLE_WARNING(WEAK_VTABLES);
+TINT_BEGIN_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
 #include "source/opt/ir_context.h"
+TINT_END_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
 TINT_END_DISABLE_WARNING(WEAK_VTABLES);
 TINT_END_DISABLE_WARNING(SIGN_CONVERSION);
 TINT_END_DISABLE_WARNING(OLD_STYLE_CAST);
diff --git a/src/tint/lang/spirv/reader/parser/parser.cc b/src/tint/lang/spirv/reader/parser/parser.cc
index ea3ce72..7aaa2ee 100644
--- a/src/tint/lang/spirv/reader/parser/parser.cc
+++ b/src/tint/lang/spirv/reader/parser/parser.cc
@@ -38,7 +38,9 @@
 TINT_BEGIN_DISABLE_WARNING(OLD_STYLE_CAST);
 TINT_BEGIN_DISABLE_WARNING(SIGN_CONVERSION);
 TINT_BEGIN_DISABLE_WARNING(WEAK_VTABLES);
+TINT_BEGIN_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
 #include "source/opt/build_module.h"
+TINT_END_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
 TINT_END_DISABLE_WARNING(WEAK_VTABLES);
 TINT_END_DISABLE_WARNING(SIGN_CONVERSION);
 TINT_END_DISABLE_WARNING(OLD_STYLE_CAST);
diff --git a/src/tint/lang/spirv/writer/common/binary_writer.cc b/src/tint/lang/spirv/writer/common/binary_writer.cc
index 56bd5a7..b9a89d1 100644
--- a/src/tint/lang/spirv/writer/common/binary_writer.cc
+++ b/src/tint/lang/spirv/writer/common/binary_writer.cc
@@ -30,6 +30,8 @@
 #include <cstring>
 #include <string>
 
+TINT_BEGIN_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
+
 namespace tint::spirv::writer {
 namespace {
 
@@ -87,3 +89,5 @@
 }
 
 }  // namespace tint::spirv::writer
+
+TINT_END_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
diff --git a/src/tint/lang/spirv/writer/common/binary_writer_test.cc b/src/tint/lang/spirv/writer/common/binary_writer_test.cc
index d79e90a..0156037 100644
--- a/src/tint/lang/spirv/writer/common/binary_writer_test.cc
+++ b/src/tint/lang/spirv/writer/common/binary_writer_test.cc
@@ -28,6 +28,8 @@
 #include "src/tint/lang/spirv/writer/common/binary_writer.h"
 #include "gtest/gtest.h"
 
+TINT_BEGIN_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
+
 namespace tint::spirv::writer {
 namespace {
 
@@ -138,3 +140,5 @@
 
 }  // namespace
 }  // namespace tint::spirv::writer
+
+TINT_END_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
diff --git a/src/tint/lang/wgsl/ast/builder.h b/src/tint/lang/wgsl/ast/builder.h
index 5a22563..ceed955 100644
--- a/src/tint/lang/wgsl/ast/builder.h
+++ b/src/tint/lang/wgsl/ast/builder.h
@@ -110,6 +110,8 @@
 #error "internal tint header being #included from tint.h"
 #endif
 
+TINT_BEGIN_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
+
 // Forward declarations
 namespace tint::ast {
 class CloneContext;
@@ -3628,4 +3630,6 @@
 
 }  // namespace tint
 
+TINT_END_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
+
 #endif  // SRC_TINT_LANG_WGSL_AST_BUILDER_H_
diff --git a/src/tint/lang/wgsl/ast/transform/renamer.cc b/src/tint/lang/wgsl/ast/transform/renamer.cc
index 6b97736..0f48571 100644
--- a/src/tint/lang/wgsl/ast/transform/renamer.cc
+++ b/src/tint/lang/wgsl/ast/transform/renamer.cc
@@ -45,6 +45,8 @@
 TINT_INSTANTIATE_TYPEINFO(tint::ast::transform::Renamer);
 TINT_INSTANTIATE_TYPEINFO(tint::ast::transform::Renamer::Config);
 
+TINT_BEGIN_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
+
 namespace tint::ast::transform {
 
 namespace {
@@ -1425,3 +1427,5 @@
 }
 
 }  // namespace tint::ast::transform
+
+TINT_END_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
diff --git a/src/tint/lang/wgsl/ast/traverse_expressions_test.cc b/src/tint/lang/wgsl/ast/traverse_expressions_test.cc
index f5b553c..301c4ff 100644
--- a/src/tint/lang/wgsl/ast/traverse_expressions_test.cc
+++ b/src/tint/lang/wgsl/ast/traverse_expressions_test.cc
@@ -35,6 +35,8 @@
 using namespace tint::core::number_suffixes;  // NOLINT
 using namespace tint::core::fluent_types;     // NOLINT
 
+TINT_BEGIN_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
+
 namespace tint::ast {
 namespace {
 
@@ -284,3 +286,5 @@
 
 }  // namespace
 }  // namespace tint::ast
+
+TINT_END_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
diff --git a/src/tint/lang/wgsl/reader/parser/classify_template_args.cc b/src/tint/lang/wgsl/reader/parser/classify_template_args.cc
index d4568d1..daeb9ca 100644
--- a/src/tint/lang/wgsl/reader/parser/classify_template_args.cc
+++ b/src/tint/lang/wgsl/reader/parser/classify_template_args.cc
@@ -32,6 +32,8 @@
 #include "src/tint/utils/containers/vector.h"
 #include "src/tint/utils/ice/ice.h"
 
+TINT_BEGIN_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
+
 namespace tint::wgsl::reader {
 
 namespace {
@@ -152,3 +154,5 @@
 }
 
 }  // namespace tint::wgsl::reader
+
+TINT_END_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
diff --git a/src/tint/lang/wgsl/reader/parser/lexer.cc b/src/tint/lang/wgsl/reader/parser/lexer.cc
index 5215977..18eae20 100644
--- a/src/tint/lang/wgsl/reader/parser/lexer.cc
+++ b/src/tint/lang/wgsl/reader/parser/lexer.cc
@@ -46,6 +46,8 @@
 
 using namespace tint::core::fluent_types;  // NOLINT
 
+TINT_BEGIN_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
+
 namespace tint::wgsl::reader {
 namespace {
 
@@ -1299,3 +1301,5 @@
 }
 
 }  // namespace tint::wgsl::reader
+
+TINT_END_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
diff --git a/src/tint/lang/wgsl/writer/ir_to_program/ir_to_program.cc b/src/tint/lang/wgsl/writer/ir_to_program/ir_to_program.cc
index 56ae2c3..ba3a2e4 100644
--- a/src/tint/lang/wgsl/writer/ir_to_program/ir_to_program.cc
+++ b/src/tint/lang/wgsl/writer/ir_to_program/ir_to_program.cc
@@ -94,6 +94,8 @@
 #include "src/tint/utils/math/math.h"
 #include "src/tint/utils/rtti/switch.h"
 
+TINT_BEGIN_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
+
 // Helper for incrementing nesting_depth_ and then decrementing nesting_depth_ at the end
 // of the scope that holds the call.
 #define SCOPED_NESTING() \
@@ -1297,3 +1299,5 @@
 }
 
 }  // namespace tint::wgsl::writer
+
+TINT_END_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
diff --git a/src/tint/utils/bytes/buffer_reader.cc b/src/tint/utils/bytes/buffer_reader.cc
index 4294fef..f97276e 100644
--- a/src/tint/utils/bytes/buffer_reader.cc
+++ b/src/tint/utils/bytes/buffer_reader.cc
@@ -27,6 +27,10 @@
 
 #include "src/tint/utils/bytes/buffer_reader.h"
 
+#include "src/tint/utils/macros/compiler.h"
+
+TINT_BEGIN_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
+
 namespace tint::bytes {
 
 BufferReader::~BufferReader() = default;
@@ -44,3 +48,5 @@
 }
 
 }  // namespace tint::bytes
+
+TINT_END_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
diff --git a/src/tint/utils/bytes/swap.h b/src/tint/utils/bytes/swap.h
index da4c6e6..b4e1090 100644
--- a/src/tint/utils/bytes/swap.h
+++ b/src/tint/utils/bytes/swap.h
@@ -33,6 +33,10 @@
 #include <type_traits>
 #include <utility>
 
+#include "src/tint/utils/macros/compiler.h"
+
+TINT_BEGIN_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
+
 namespace tint::bytes {
 
 /// @return the input integer value with all bytes reversed
@@ -52,4 +56,6 @@
 
 }  // namespace tint::bytes
 
+TINT_END_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
+
 #endif  // SRC_TINT_UTILS_BYTES_SWAP_H_
diff --git a/src/tint/utils/bytes/swap_test.cc b/src/tint/utils/bytes/swap_test.cc
index 5d950c0..549d827 100644
--- a/src/tint/utils/bytes/swap_test.cc
+++ b/src/tint/utils/bytes/swap_test.cc
@@ -29,6 +29,8 @@
 
 #include "gtest/gtest.h"
 
+TINT_BEGIN_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
+
 namespace tint::bytes {
 namespace {
 
@@ -52,3 +54,5 @@
 
 }  // namespace
 }  // namespace tint::bytes
+
+TINT_END_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
diff --git a/src/tint/utils/command/command_posix.cc b/src/tint/utils/command/command_posix.cc
index e52632b..f68becd 100644
--- a/src/tint/utils/command/command_posix.cc
+++ b/src/tint/utils/command/command_posix.cc
@@ -37,10 +37,12 @@
 #include <sstream>
 #include <vector>
 
+#include "src/tint/utils/macros/compiler.h"
 #include "src/tint/utils/system/executable_path.h"
 
-namespace tint {
+TINT_BEGIN_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
 
+namespace tint {
 namespace {
 
 /// File is a simple wrapper around a POSIX file descriptor
@@ -296,3 +298,5 @@
 }
 
 }  // namespace tint
+
+TINT_BEGIN_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
diff --git a/src/tint/utils/containers/hashmap_base.h b/src/tint/utils/containers/hashmap_base.h
index 8740d93..6278490 100644
--- a/src/tint/utils/containers/hashmap_base.h
+++ b/src/tint/utils/containers/hashmap_base.h
@@ -41,6 +41,8 @@
 #include "src/tint/utils/memory/aligned_storage.h"
 #include "src/tint/utils/rtti/traits.h"
 
+TINT_BEGIN_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
+
 namespace tint {
 
 /// HashmapKey wraps the comparator type for a Hashmap and Hashset.
@@ -681,4 +683,6 @@
 
 }  // namespace tint
 
+TINT_END_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
+
 #endif  // SRC_TINT_UTILS_CONTAINERS_HASHMAP_BASE_H_
diff --git a/src/tint/utils/containers/slice.h b/src/tint/utils/containers/slice.h
index 14f0082..10e3fa0 100644
--- a/src/tint/utils/containers/slice.h
+++ b/src/tint/utils/containers/slice.h
@@ -37,6 +37,8 @@
 #include "src/tint/utils/rtti/castable.h"
 #include "src/tint/utils/rtti/traits.h"
 
+TINT_BEGIN_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
+
 namespace tint {
 
 /// A type used to indicate an empty array.
@@ -293,4 +295,6 @@
 
 }  // namespace tint
 
+TINT_END_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
+
 #endif  // SRC_TINT_UTILS_CONTAINERS_SLICE_H_
diff --git a/src/tint/utils/containers/slice_test.cc b/src/tint/utils/containers/slice_test.cc
index 5e30d4e..e5db3dc 100644
--- a/src/tint/utils/containers/slice_test.cc
+++ b/src/tint/utils/containers/slice_test.cc
@@ -29,6 +29,8 @@
 
 #include "gmock/gmock.h"
 
+TINT_BEGIN_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
+
 namespace tint {
 namespace {
 
@@ -234,3 +236,5 @@
 
 }  // namespace
 }  // namespace tint
+
+TINT_END_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
diff --git a/src/tint/utils/containers/vector.h b/src/tint/utils/containers/vector.h
index 74f7129..165f2d0 100644
--- a/src/tint/utils/containers/vector.h
+++ b/src/tint/utils/containers/vector.h
@@ -44,6 +44,8 @@
 #include "src/tint/utils/memory/aligned_storage.h"
 #include "src/tint/utils/memory/bitcast.h"
 
+TINT_BEGIN_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
+
 #ifndef TINT_VECTOR_MUTATION_CHECKS_ENABLED
 #ifdef NDEBUG
 #define TINT_VECTOR_MUTATION_CHECKS_ENABLED 0
@@ -1301,4 +1303,6 @@
 
 }  // namespace tint
 
+TINT_END_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
+
 #endif  // SRC_TINT_UTILS_CONTAINERS_VECTOR_H_
diff --git a/src/tint/utils/containers/vector_test.cc b/src/tint/utils/containers/vector_test.cc
index 3c94044..77fdd88 100644
--- a/src/tint/utils/containers/vector_test.cc
+++ b/src/tint/utils/containers/vector_test.cc
@@ -40,6 +40,7 @@
 // MSVC claims there's unreachable code in some of the EXPECT_DEATH cases, but scoping the
 // DISABLE_WARNING to the test is not sufficient to suppress the warning.
 TINT_BEGIN_DISABLE_WARNING(UNREACHABLE_CODE);
+TINT_BEGIN_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
 
 namespace tint {
 namespace {
@@ -2463,4 +2464,5 @@
 TINT_INSTANTIATE_TYPEINFO(tint::C2a);
 TINT_INSTANTIATE_TYPEINFO(tint::C2b);
 
+TINT_BEGIN_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
 TINT_END_DISABLE_WARNING(UNREACHABLE_CODE);
diff --git a/src/tint/utils/macros/compiler.h b/src/tint/utils/macros/compiler.h
index d7fe5b1..9fd940c 100644
--- a/src/tint/utils/macros/compiler.h
+++ b/src/tint/utils/macros/compiler.h
@@ -53,6 +53,7 @@
 #define TINT_DISABLE_WARNING_SIGN_CONVERSION             /* currently no-op */
 #define TINT_DISABLE_WARNING_UNDEFINED_REINTERPRET_CAST  /* currently no-op */
 #define TINT_DISABLE_WARNING_UNREACHABLE_CODE __pragma(warning(disable : 4702))
+#define TINT_DISABLE_WARNING_UNSAFE_BUFFER_USAGE /* currently no-op */
 #define TINT_DISABLE_WARNING_UNUSED_PARAMETER __pragma(warning(disable : 4100))
 #define TINT_DISABLE_WARNING_UNUSED_VALUE    /* currently no-op */
 #define TINT_DISABLE_WARNING_WEAK_VTABLES    /* currently no-op */
@@ -116,6 +117,8 @@
 #define TINT_DISABLE_WARNING_UNDEFINED_REINTERPRET_CAST \
     _Pragma("clang diagnostic ignored \"-Wundefined-reinterpret-cast\"")
 #define TINT_DISABLE_WARNING_UNREACHABLE_CODE /* currently no-op */
+#define TINT_DISABLE_WARNING_UNSAFE_BUFFER_USAGE \
+    _Pragma("clang diagnostic ignored \"-Wunsafe-buffer-usage\"")
 #define TINT_DISABLE_WARNING_UNUSED_PARAMETER \
     _Pragma("clang diagnostic ignored \"-Wunused-parameter\"")
 #define TINT_DISABLE_WARNING_UNUSED_VALUE _Pragma("clang diagnostic ignored \"-Wunused-value\"")
@@ -149,6 +152,7 @@
 #define TINT_BEGIN_DISABLE_ALL_WARNINGS() \
     _Pragma("clang diagnostic push")      \
     _Pragma("clang diagnostic ignored \"-Weverything\"")       \
+    TINT_DISABLE_WARNING_UNSAFE_BUFFER_USAGE \
     TINT_REQUIRE_SEMICOLON
 
 #define TINT_END_DISABLE_ALL_WARNINGS() \
@@ -190,6 +194,7 @@
 #define TINT_DISABLE_WARNING_SIGN_CONVERSION             /* currently no-op */
 #define TINT_DISABLE_WARNING_UNDEFINED_REINTERPRET_CAST  /* currently no-op */
 #define TINT_DISABLE_WARNING_UNREACHABLE_CODE            /* currently no-op */
+#define TINT_DISABLE_WARNING_UNSAFE_BUFFER_USAGE         /* currently no-op */
 #define TINT_DISABLE_WARNING_UNUSED_PARAMETER \
     _Pragma("GCC diagnostic ignored \"-Wunused-parameter\"")
 #define TINT_DISABLE_WARNING_UNUSED_VALUE _Pragma("GCC diagnostic ignored \"-Wunused-value\"")
@@ -223,6 +228,7 @@
     TINT_DISABLE_WARNING_EXTRA_SEMICOLON              \
     TINT_DISABLE_WARNING_ZERO_AS_NULLPTR              \
     TINT_DISABLE_WARNING_MISSING_DESTRUCTOR_OVERRIDE  \
+    TINT_DISABLE_WARNING_UNSAFE_BUFFER_USAGE          \
     TINT_REQUIRE_SEMICOLON
 // clang-format on
 
diff --git a/src/tint/utils/math/BUILD.bazel b/src/tint/utils/math/BUILD.bazel
index a31c648..c9e0006 100644
--- a/src/tint/utils/math/BUILD.bazel
+++ b/src/tint/utils/math/BUILD.bazel
@@ -47,6 +47,8 @@
     "math.h",
   ],
   deps = [
+    "//src/tint/utils/macros",
+    "//src/utils",
   ],
   copts = COPTS,
   visibility = ["//visibility:public"],
diff --git a/src/tint/utils/math/BUILD.cmake b/src/tint/utils/math/BUILD.cmake
index 08ea54a..1e8bfe6 100644
--- a/src/tint/utils/math/BUILD.cmake
+++ b/src/tint/utils/math/BUILD.cmake
@@ -45,6 +45,14 @@
   utils/math/math.h
 )
 
+tint_target_add_dependencies(tint_utils_math lib
+  tint_utils_macros
+)
+
+tint_target_add_external_dependencies(tint_utils_math lib
+  "src_utils"
+)
+
 ################################################################################
 # Target:    tint_utils_math_test
 # Kind:      test
diff --git a/src/tint/utils/math/BUILD.gn b/src/tint/utils/math/BUILD.gn
index e38fd1d..c5da13b 100644
--- a/src/tint/utils/math/BUILD.gn
+++ b/src/tint/utils/math/BUILD.gn
@@ -50,7 +50,10 @@
     "math.cc",
     "math.h",
   ]
-  deps = []
+  deps = [
+    "${dawn_root}/src/utils:utils",
+    "${tint_src_dir}/utils/macros",
+  ]
 }
 if (tint_build_unittests) {
   tint_unittests_source_set("unittests") {
diff --git a/src/tint/utils/math/crc32.h b/src/tint/utils/math/crc32.h
index 7e3f093..794cb5a 100644
--- a/src/tint/utils/math/crc32.h
+++ b/src/tint/utils/math/crc32.h
@@ -31,6 +31,10 @@
 #include <stdint.h>
 #include <cstddef>
 
+#include "src/tint/utils/macros/compiler.h"
+
+TINT_BEGIN_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
+
 namespace tint {
 
 /// CRC32 immutable lookup table data.
@@ -95,4 +99,6 @@
 
 }  // namespace tint
 
+TINT_END_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
+
 #endif  // SRC_TINT_UTILS_MATH_CRC32_H_
diff --git a/src/tint/utils/memory/block_allocator.h b/src/tint/utils/memory/block_allocator.h
index f8a59dc..02c7a19 100644
--- a/src/tint/utils/memory/block_allocator.h
+++ b/src/tint/utils/memory/block_allocator.h
@@ -32,9 +32,12 @@
 #include <cstring>
 #include <utility>
 
+#include "src/tint/utils/macros/compiler.h"
 #include "src/tint/utils/math/math.h"
 #include "src/tint/utils/memory/bitcast.h"
 
+TINT_BEGIN_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
+
 namespace tint {
 
 /// A container and allocator of objects of (or deriving from) the template type `T`.
@@ -316,4 +319,6 @@
 
 }  // namespace tint
 
+TINT_END_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
+
 #endif  // SRC_TINT_UTILS_MEMORY_BLOCK_ALLOCATOR_H_
diff --git a/src/tint/utils/memory/bump_allocator.h b/src/tint/utils/memory/bump_allocator.h
index 4ade655..e9f9a2a 100644
--- a/src/tint/utils/memory/bump_allocator.h
+++ b/src/tint/utils/memory/bump_allocator.h
@@ -39,6 +39,8 @@
 #include "src/tint/utils/math/math.h"
 #include "src/tint/utils/memory/bitcast.h"
 
+TINT_BEGIN_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
+
 namespace tint {
 
 /// A allocator for chunks of memory. The memory is owned by the BumpAllocator. When the
@@ -145,4 +147,6 @@
 
 }  // namespace tint
 
+TINT_END_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
+
 #endif  // SRC_TINT_UTILS_MEMORY_BUMP_ALLOCATOR_H_
diff --git a/src/tint/utils/socket.cc b/src/tint/utils/socket.cc
index 3e38dd5..5c76e75 100644
--- a/src/tint/utils/socket.cc
+++ b/src/tint/utils/socket.cc
@@ -56,6 +56,8 @@
 }  // anonymous namespace
 #endif
 
+TINT_BEGIN_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
+
 namespace tint::socket {
 namespace {
 constexpr SOCKET InvalidSocket = static_cast<SOCKET>(-1);
@@ -337,3 +339,5 @@
 }
 
 }  // namespace tint::socket
+
+TINT_END_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
diff --git a/src/tint/utils/strconv/parse_num.cc b/src/tint/utils/strconv/parse_num.cc
index c1cbf85..8914127 100644
--- a/src/tint/utils/strconv/parse_num.cc
+++ b/src/tint/utils/strconv/parse_num.cc
@@ -31,6 +31,8 @@
 
 #include "absl/strings/charconv.h"
 
+TINT_BEGIN_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
+
 namespace tint::strconv {
 
 namespace {
@@ -109,3 +111,5 @@
 }
 
 }  // namespace tint::strconv
+
+TINT_END_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
diff --git a/src/tint/utils/system/terminal_posix.cc b/src/tint/utils/system/terminal_posix.cc
index db66159..df61519 100644
--- a/src/tint/utils/system/terminal_posix.cc
+++ b/src/tint/utils/system/terminal_posix.cc
@@ -45,6 +45,8 @@
 #include "src/tint/utils/system/env.h"
 #include "src/tint/utils/system/terminal.h"
 
+TINT_BEGIN_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
+
 namespace tint {
 namespace {
 
@@ -93,6 +95,7 @@
         fd_set rfds{};
         FD_ZERO(&rfds);
         FD_SET(STDIN_FILENO, &rfds);
+
         timeval tv{};
         tv.tv_sec = 0;
         tv.tv_usec = 100'000;
@@ -227,3 +230,5 @@
 }
 
 }  // namespace tint
+
+TINT_END_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
diff --git a/src/tint/utils/text/unicode.cc b/src/tint/utils/text/unicode.cc
index 638165f..ccd4642 100644
--- a/src/tint/utils/text/unicode.cc
+++ b/src/tint/utils/text/unicode.cc
@@ -29,6 +29,10 @@
 
 #include <algorithm>
 
+#include "src/tint/utils/macros/compiler.h"
+
+TINT_BEGIN_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
+
 namespace tint {
 namespace {
 
@@ -528,3 +532,5 @@
 
 }  // namespace utf16
 }  // namespace tint
+
+TINT_END_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
diff --git a/src/tint/utils/text/unicode_test.cc b/src/tint/utils/text/unicode_test.cc
index 48eb9fb..1ccef32 100644
--- a/src/tint/utils/text/unicode_test.cc
+++ b/src/tint/utils/text/unicode_test.cc
@@ -36,6 +36,8 @@
 #include "gmock/gmock.h"
 #include "src/tint/utils/text/string.h"
 
+TINT_BEGIN_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
+
 /// Helper for constructing a CodePoint
 #define C(x) CodePoint(x)
 
@@ -848,3 +850,5 @@
 
 }  // namespace utf16_tests
 }  // namespace tint
+
+TINT_END_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);