Convert WGSL reader to utils::StringStream.
This CL updates the WGSL reader to use utils::StringStream internally.
Bug: tint:1686
Change-Id: I203c764bbb86e99da323fde2be2af555f158b7bf
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122001
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
diff --git a/src/tint/reader/wgsl/parser_impl.cc b/src/tint/reader/wgsl/parser_impl.cc
index 1d81821..e4eab291a 100644
--- a/src/tint/reader/wgsl/parser_impl.cc
+++ b/src/tint/reader/wgsl/parser_impl.cc
@@ -214,7 +214,7 @@
ParserImpl::Failure::Errored ParserImpl::add_error(const Source& source,
std::string_view err,
std::string_view use) {
- std::stringstream msg;
+ utils::StringStream msg;
msg << err;
if (!use.empty()) {
msg << " for " << use;
@@ -3165,7 +3165,7 @@
return false;
}
- std::stringstream err;
+ utils::StringStream err;
if (tok == Token::Type::kTemplateArgsLeft && t.type() == Token::Type::kLessThan) {
err << "missing closing '>'";
} else {
diff --git a/src/tint/reader/wgsl/parser_impl_error_msg_test.cc b/src/tint/reader/wgsl/parser_impl_error_msg_test.cc
index 85e55cb..af50894 100644
--- a/src/tint/reader/wgsl/parser_impl_error_msg_test.cc
+++ b/src/tint/reader/wgsl/parser_impl_error_msg_test.cc
@@ -14,6 +14,8 @@
#include "src/tint/reader/wgsl/parser_impl_test_helper.h"
+#include "src/tint/utils/string_stream.h"
+
namespace tint::reader::wgsl {
namespace {
@@ -513,8 +515,8 @@
TEST_F(ParserImplErrorTest, GlobalDeclConstExprMaxDepth) {
uint32_t kMaxDepth = 128;
- std::stringstream src;
- std::stringstream mkr;
+ utils::StringStream src;
+ utils::StringStream mkr;
src << "const i : i32 = ";
mkr << " ";
for (size_t i = 0; i < kMaxDepth + 8; i++) {
@@ -530,7 +532,7 @@
src << ")";
}
src << ";";
- std::stringstream err;
+ utils::StringStream err;
err << "test.wgsl:1:529 error: maximum parser recursive depth reached\n"
<< src.str() << "\n"
<< mkr.str() << "\n";
diff --git a/src/tint/reader/wgsl/parser_impl_expression_test.cc b/src/tint/reader/wgsl/parser_impl_expression_test.cc
index 0de3dea..9a6c917 100644
--- a/src/tint/reader/wgsl/parser_impl_expression_test.cc
+++ b/src/tint/reader/wgsl/parser_impl_expression_test.cc
@@ -14,6 +14,8 @@
#include "src/tint/reader/wgsl/parser_impl_test_helper.h"
+#include "src/tint/utils/string_stream.h"
+
namespace tint::reader::wgsl {
namespace {
@@ -486,7 +488,7 @@
using ParserImplMixedBinaryOpTest = ParserImplTestWithParam<Case>;
TEST_P(ParserImplMixedBinaryOpTest, Test) {
- std::stringstream wgsl;
+ utils::StringStream wgsl;
wgsl << GetParam();
auto p = parser(wgsl.str());
auto e = p->expression();
@@ -498,7 +500,7 @@
EXPECT_TRUE(e.errored);
EXPECT_EQ(e.value, nullptr);
EXPECT_TRUE(p->has_error());
- std::stringstream expected;
+ utils::StringStream expected;
expected << "1:3: mixing '" << GetParam().lhs_op.symbol << "' and '"
<< GetParam().rhs_op.symbol << "' requires parenthesis";
EXPECT_EQ(p->error(), expected.str());