From cd5e4a80833c9822610bb60d8e05d0983ce44bb5 Mon Sep 17 00:00:00 2001 From: Ben Clayton Date: Mon, 2 Nov 2020 17:55:18 +0000 Subject: [PATCH] Remove Parser constructors that take a string ... for the content. Everything should be using a `Source::File*` now. Bug: tint:282 Change-Id: I9bebb94995a946a5919ba6503f2b0ee2058f0fb1 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31482 Reviewed-by: dan sinclair Commit-Queue: Ben Clayton --- src/reader/wgsl/parser.cc | 8 +------- src/reader/wgsl/parser.h | 8 -------- src/reader/wgsl/parser_impl.cc | 13 +++---------- src/reader/wgsl/parser_impl.h | 9 +-------- 4 files changed, 5 insertions(+), 33 deletions(-) diff --git a/src/reader/wgsl/parser.cc b/src/reader/wgsl/parser.cc index e24066a4b0..323caeae81 100644 --- a/src/reader/wgsl/parser.cc +++ b/src/reader/wgsl/parser.cc @@ -21,13 +21,7 @@ namespace reader { namespace wgsl { Parser::Parser(Context* ctx, Source::File const* file) - : Reader(ctx), impl_(std::make_unique(ctx, file, false)) {} - -Parser::Parser(Context* ctx, const std::string& content) - : Reader(ctx), - impl_(std::make_unique(ctx, - new Source::File("", content), - true)) {} + : Reader(ctx), impl_(std::make_unique(ctx, file)) {} Parser::~Parser() = default; diff --git a/src/reader/wgsl/parser.h b/src/reader/wgsl/parser.h index ff835b8160..ddff63fc3f 100644 --- a/src/reader/wgsl/parser.h +++ b/src/reader/wgsl/parser.h @@ -34,14 +34,6 @@ class Parser : public Reader { /// @param ctx the non-null context object /// @param file the input source file to parse Parser(Context* ctx, Source::File const* file); - - /// Creates a new parser from the given file content. - /// @param ctx the non-null context object - /// @param content the input string to parse - /// TODO(bclayton): Remove this constructor. - /// It purely exists to break up changes into bite sized pieces. - Parser(Context* ctx, const std::string& content); - ~Parser() override; /// Run the parser diff --git a/src/reader/wgsl/parser_impl.cc b/src/reader/wgsl/parser_impl.cc index 174bada62f..eb4322194a 100644 --- a/src/reader/wgsl/parser_impl.cc +++ b/src/reader/wgsl/parser_impl.cc @@ -119,17 +119,10 @@ bool IsFunctionDecoration(Token t) { } // namespace -ParserImpl::ParserImpl(Context* ctx, Source::File const* file, bool owns_file) - : ctx_(*ctx), - lexer_(std::make_unique(file)), - file_(file), - owns_file_(owns_file) {} +ParserImpl::ParserImpl(Context* ctx, Source::File const* file) + : ctx_(*ctx), lexer_(std::make_unique(file)) {} -ParserImpl::~ParserImpl() { - if (owns_file_) { - delete file_; - } -} +ParserImpl::~ParserImpl() = default; void ParserImpl::set_error(const Token& t, const std::string& err) { diag::Diagnostic diagnostic; diff --git a/src/reader/wgsl/parser_impl.h b/src/reader/wgsl/parser_impl.h index 882093aa96..8ea3e6cdd3 100644 --- a/src/reader/wgsl/parser_impl.h +++ b/src/reader/wgsl/parser_impl.h @@ -89,11 +89,7 @@ class ParserImpl { /// Creates a new parser using the given file /// @param ctx the non-null context object /// @param file the input source file to parse - /// @param owns_file if true, the file will be deleted on parser destruction. - /// TODO(bclayton): Remove owns_file. - /// It purely exists to break up changes into bite sized pieces. - ParserImpl(Context* ctx, Source::File const* file, bool owns_file = false); - + ParserImpl(Context* ctx, Source::File const* file); ~ParserImpl(); /// Run the parser @@ -431,9 +427,6 @@ class ParserImpl { std::deque token_queue_; std::unordered_map registered_constructs_; ast::Module module_; - - Source::File const* file_; - bool owns_file_; }; } // namespace wgsl