[tint] Restrict suppression in buffer_reader.cc
This class is a wrapper around accessing a pointer to raw memory so
internally causes UBU warnings that need to be suppressed. This will
likely be fixable with C++20.
Bug: 394825124
Change-Id: I5de2ebad29506c28b634028bb7c93165fd5640cc
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/235914
Auto-Submit: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
diff --git a/src/tint/utils/bytes/buffer_reader.cc b/src/tint/utils/bytes/buffer_reader.cc
index a1c3541..5c790dd 100644
--- a/src/tint/utils/bytes/buffer_reader.cc
+++ b/src/tint/utils/bytes/buffer_reader.cc
@@ -31,12 +31,12 @@
#include "src/tint/utils/macros/compiler.h"
-TINT_BEGIN_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
-
namespace tint::bytes {
BufferReader::~BufferReader() = default;
+// TODO(408010433): Rewrite internals using span to avoid UBU during read
+TINT_BEGIN_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
size_t BufferReader::Read(std::byte* out, size_t count) {
size_t n = std::min(count, bytes_remaining_);
memcpy(out, data_, n);
@@ -44,11 +44,10 @@
bytes_remaining_ -= n;
return n;
}
+TINT_END_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);
bool BufferReader::IsEOF() const {
return bytes_remaining_ == 0;
}
} // namespace tint::bytes
-
-TINT_END_DISABLE_WARNING(UNSAFE_BUFFER_USAGE);