ShaderModule: Refactor ParseWGSL() to take a File*

The tint::ast::Module holds a diagnostic list (tint::diag::List) which references the source tint::Source::File.
If you try to enable any of the more pretty diagnostic printing functionality, and attempt to print these after ParseWGSL() has returned, you'll then dereference a pointer to the now stack unwound `tint::Source::File`.
Promote the file up one callstack level to fix this.

Bug: none. Only exposed when using pretty printing.
Change-Id: I9432dd9d668fd1d92efa228bb5ed31278fd3ddfc
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/37280
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Auto-Submit: Ben Clayton <bclayton@google.com>
diff --git a/src/dawn_native/ShaderModule.cpp b/src/dawn_native/ShaderModule.cpp
index 909ecbb..3e1f3d9 100644
--- a/src/dawn_native/ShaderModule.cpp
+++ b/src/dawn_native/ShaderModule.cpp
@@ -173,12 +173,11 @@
         }
 
 #ifdef DAWN_ENABLE_WGSL
-        ResultOrError<tint::ast::Module> ParseWGSL(const char* wgsl) {
+        ResultOrError<tint::ast::Module> ParseWGSL(const tint::Source::File* file) {
             std::ostringstream errorStream;
             errorStream << "Tint WGSL reader failure:" << std::endl;
 
-            tint::Source::File file("", wgsl);
-            tint::reader::wgsl::Parser parser(&file);
+            tint::reader::wgsl::Parser parser(file);
             if (!parser.Parse()) {
                 errorStream << "Parser: " << parser.error() << std::endl;
                 return DAWN_VALIDATION_ERROR(errorStream.str().c_str());
@@ -827,16 +826,18 @@
                 const auto* wgslDesc =
                     static_cast<const ShaderModuleWGSLDescriptor*>(chainedDescriptor);
 
+                tint::Source::File file("", wgslDesc->source);
+
                 if (device->IsToggleEnabled(Toggle::UseTintGenerator)) {
                     tint::ast::Module module;
-                    DAWN_TRY_ASSIGN(module, ParseWGSL(wgslDesc->source));
+                    DAWN_TRY_ASSIGN(module, ParseWGSL(&file));
                     if (device->IsValidationEnabled()) {
                         DAWN_TRY(ValidateModule(&module));
                     }
                     parseResult.tintModule = std::make_unique<tint::ast::Module>(std::move(module));
                 } else {
                     tint::ast::Module module;
-                    DAWN_TRY_ASSIGN(module, ParseWGSL(wgslDesc->source));
+                    DAWN_TRY_ASSIGN(module, ParseWGSL(&file));
 
                     {
                         tint::transform::Manager transformManager;