[tint][ir] Set the File on Disassembly's Sources

The Disassembly now owns the File, so it makes sense for the Sources to have the File set.

Change-Id: I6d95c4bef3c2d4f83013323312fa7b46a8737b78
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/186620
Reviewed-by: James Price <jrprice@google.com>
diff --git a/src/tint/lang/core/ir/disassembly.cc b/src/tint/lang/core/ir/disassembly.cc
index ddc7dba..a07033f 100644
--- a/src/tint/lang/core/ir/disassembly.cc
+++ b/src/tint/lang/core/ir/disassembly.cc
@@ -102,6 +102,19 @@
 Disassembly::Disassembly(const Module& mod, std::string_view file_name) : mod_(mod) {
     Disassemble();
     file_ = std::make_shared<Source::File>(std::string(file_name), Plain());
+
+    auto set_source_file = [&](auto& map) {
+        for (auto& it : map) {
+            it.value.file = file_.get();
+        }
+    };
+    set_source_file(block_to_src_);
+    set_source_file(block_param_to_src_);
+    set_source_file(instruction_to_src_);
+    set_source_file(operand_to_src_);
+    set_source_file(result_to_src_);
+    set_source_file(function_to_src_);
+    set_source_file(function_param_to_src_);
 }
 
 Disassembly::~Disassembly() = default;
diff --git a/src/tint/lang/core/ir/validator.cc b/src/tint/lang/core/ir/validator.cc
index 5c12eff..27f1e24 100644
--- a/src/tint/lang/core/ir/validator.cc
+++ b/src/tint/lang/core/ir/validator.cc
@@ -528,19 +528,13 @@
 
 diag::Diagnostic& Validator::AddError(Source src) {
     auto& diag = diagnostics_.AddError(tint::diag::System::IR, src);
-    if (src.range != Source::Range{{}}) {
-        diag.source.file = Disassembly().File().get();
-        diag.owned_file = Disassembly().File();
-    }
+    diag.owned_file = Disassembly().File();
     return diag;
 }
 
 diag::Diagnostic& Validator::AddNote(Source src) {
     auto& diag = diagnostics_.AddNote(tint::diag::System::IR, src);
-    if (src.range != Source::Range{{}}) {
-        diag.source.file = Disassembly().File().get();
-        diag.owned_file = Disassembly().File();
-    }
+    diag.owned_file = Disassembly().File();
     return diag;
 }