src/reader tests: Have parse() return a unique_ptr
The reason being that some tests called parse() twice, which will silently destruct the first parser.
Once the `Module` owns the AST nodes, the second call will end up deleting all the AST nodes. Tests would then perform use-after-free for the AST nodes belonging to the first parser / module.
There's no reason why the unique_ptr can't be returned, which is cleaner overall.
Bug: tint:335
Change-Id: I7ff2e9777a7ebeb76702f806294fe4c2c49bd7c9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33241
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
diff --git a/src/reader/wgsl/parser_impl_inclusive_or_expression_test.cc b/src/reader/wgsl/parser_impl_inclusive_or_expression_test.cc
index e010429..e1bf011 100644
--- a/src/reader/wgsl/parser_impl_inclusive_or_expression_test.cc
+++ b/src/reader/wgsl/parser_impl_inclusive_or_expression_test.cc
@@ -26,7 +26,7 @@
namespace {
TEST_F(ParserImplTest, InclusiveOrExpression_Parses) {
- auto* p = parser("a | true");
+ auto p = parser("a | true");
auto e = p->inclusive_or_expression();
EXPECT_TRUE(e.matched);
EXPECT_FALSE(e.errored);
@@ -49,7 +49,7 @@
}
TEST_F(ParserImplTest, InclusiveOrExpression_InvalidLHS) {
- auto* p = parser("if (a) {} | true");
+ auto p = parser("if (a) {} | true");
auto e = p->inclusive_or_expression();
EXPECT_FALSE(e.matched);
EXPECT_FALSE(e.errored);
@@ -58,7 +58,7 @@
}
TEST_F(ParserImplTest, InclusiveOrExpression_InvalidRHS) {
- auto* p = parser("true | if (a) {}");
+ auto p = parser("true | if (a) {}");
auto e = p->inclusive_or_expression();
EXPECT_FALSE(e.matched);
EXPECT_TRUE(e.errored);
@@ -68,7 +68,7 @@
}
TEST_F(ParserImplTest, InclusiveOrExpression_NoOr_ReturnsLHS) {
- auto* p = parser("a true");
+ auto p = parser("a true");
auto e = p->inclusive_or_expression();
EXPECT_TRUE(e.matched);
EXPECT_FALSE(e.errored);