From 295c8eb97fbf00a0b5008f4da54d55c24157ec48 Mon Sep 17 00:00:00 2001 From: Jon Ross-Perkins Date: Thu, 14 Mar 2024 14:12:26 -0700 Subject: [PATCH] Change Namespace formatting to use the scope's name. (#3782) This change only affects the generated IR, but I think it's cleaning up an existing issue with namespace name printing. --- .../alias/fail_local_in_namespace.carbon | 6 +-- .../check/testdata/alias/in_namespace.carbon | 8 +-- .../testdata/index/fail_invalid_base.carbon | 6 +-- .../testdata/namespace/add_to_import.carbon | 10 ++-- .../check/testdata/namespace/alias.carbon | 12 ++--- .../fail_conflict_after_merge.carbon | 10 ++-- ...l_conflict_imported_namespace_first.carbon | 8 +-- ...conflict_in_imports_namespace_first.carbon | 8 +-- ...onflict_in_imports_namespace_second.carbon | 8 +-- .../namespace/fail_decl_in_alias.carbon | 8 +-- .../testdata/namespace/fail_duplicate.carbon | 4 +- .../testdata/namespace/fail_modifiers.carbon | 12 ++--- .../check/testdata/namespace/function.carbon | 6 +-- .../check/testdata/namespace/imported.carbon | 28 +++++----- .../namespace/imported_indirect.carbon | 54 +++++++++---------- .../check/testdata/namespace/merging.carbon | 22 ++++---- .../check/testdata/namespace/nested.carbon | 12 ++--- .../check/testdata/namespace/shadow.carbon | 8 +-- .../namespace/unqualified_lookup.carbon | 8 +-- .../check/testdata/package_expr/syntax.carbon | 6 +-- .../pointer/fail_deref_namespace.carbon | 6 +-- .../var/fail_namespace_conflict.carbon | 4 +- toolchain/check/testdata/var/shadowing.carbon | 4 +- toolchain/sem_ir/formatter.cpp | 7 +++ 24 files changed, 136 insertions(+), 129 deletions(-) diff --git a/toolchain/check/testdata/alias/fail_local_in_namespace.carbon b/toolchain/check/testdata/alias/fail_local_in_namespace.carbon index 3cccf15a86e4..daccc86e9dfe 100644 --- a/toolchain/check/testdata/alias/fail_local_in_namespace.carbon +++ b/toolchain/check/testdata/alias/fail_local_in_namespace.carbon @@ -28,10 +28,10 @@ fn F() -> bool { // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .NS = %.loc7 +// CHECK:STDOUT: .NS = %NS // CHECK:STDOUT: .F = %F // CHECK:STDOUT: } -// CHECK:STDOUT: %.loc7: = namespace [template] {} +// CHECK:STDOUT: %NS: = namespace [template] {} // CHECK:STDOUT: %F: = fn_decl @F [template] { // CHECK:STDOUT: %return.var: ref bool = var // CHECK:STDOUT: } @@ -41,7 +41,7 @@ fn F() -> bool { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc16_16: bool = bool_literal false [template = constants.%.1] // CHECK:STDOUT: %.loc16_9: = bind_alias , [template = ] -// CHECK:STDOUT: %NS.ref: = name_ref NS, file.%.loc7 [template = file.%.loc7] +// CHECK:STDOUT: %NS.ref: = name_ref NS, file.%NS [template = file.%NS] // CHECK:STDOUT: %a.ref: = name_ref a, [template = ] // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/alias/in_namespace.carbon b/toolchain/check/testdata/alias/in_namespace.carbon index b180eed56bb0..24d30ccfc88b 100644 --- a/toolchain/check/testdata/alias/in_namespace.carbon +++ b/toolchain/check/testdata/alias/in_namespace.carbon @@ -21,19 +21,19 @@ fn F() -> NS.a { // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .NS = %.loc7 +// CHECK:STDOUT: .NS = %NS // CHECK:STDOUT: .F = %F // CHECK:STDOUT: } -// CHECK:STDOUT: %.loc7: = namespace [template] { +// CHECK:STDOUT: %NS: = namespace [template] { // CHECK:STDOUT: .a = %a // CHECK:STDOUT: } // CHECK:STDOUT: %a: type = bind_alias a, bool [template = bool] -// CHECK:STDOUT: %NS.ref.loc10: = name_ref NS, %.loc7 [template = %.loc7] +// CHECK:STDOUT: %NS.ref.loc10: = name_ref NS, %NS [template = %NS] // CHECK:STDOUT: %a.ref.loc10: type = name_ref a, %a [template = bool] // CHECK:STDOUT: %.loc10: bool = bool_literal false [template = constants.%.1] // CHECK:STDOUT: %b: bool = bind_name b, %.loc10 // CHECK:STDOUT: %F: = fn_decl @F [template] { -// CHECK:STDOUT: %NS.ref.loc12: = name_ref NS, %.loc7 [template = %.loc7] +// CHECK:STDOUT: %NS.ref.loc12: = name_ref NS, %NS [template = %NS] // CHECK:STDOUT: %a.ref.loc12: type = name_ref a, %a [template = bool] // CHECK:STDOUT: %return.var: ref bool = var // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/index/fail_invalid_base.carbon b/toolchain/check/testdata/index/fail_invalid_base.carbon index 1179ca12615d..3ba3b5cf9ce8 100644 --- a/toolchain/check/testdata/index/fail_invalid_base.carbon +++ b/toolchain/check/testdata/index/fail_invalid_base.carbon @@ -43,14 +43,14 @@ var d: i32 = {.a: i32, .b: i32}[0]; // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .N = %.loc11 +// CHECK:STDOUT: .N = %N // CHECK:STDOUT: .a = %a // CHECK:STDOUT: .F = %F // CHECK:STDOUT: .b = %b // CHECK:STDOUT: .c = %c // CHECK:STDOUT: .d = %d // CHECK:STDOUT: } -// CHECK:STDOUT: %.loc11: = namespace [template] {} +// CHECK:STDOUT: %N: = namespace [template] {} // CHECK:STDOUT: %a.var: ref i32 = var a // CHECK:STDOUT: %a: ref i32 = bind_name a, %a.var // CHECK:STDOUT: %F: = fn_decl @F [template] {} @@ -66,7 +66,7 @@ var d: i32 = {.a: i32, .b: i32}[0]; // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %N.ref: = name_ref N, file.%.loc11 [template = file.%.loc11] +// CHECK:STDOUT: %N.ref: = name_ref N, file.%N [template = file.%N] // CHECK:STDOUT: %.loc15: i32 = int_literal 0 [template = constants.%.1] // CHECK:STDOUT: assign file.%a.var, // CHECK:STDOUT: %F.ref: = name_ref F, file.%F [template = file.%F] diff --git a/toolchain/check/testdata/namespace/add_to_import.carbon b/toolchain/check/testdata/namespace/add_to_import.carbon index 681b5c03c9fc..aba0dcc3a7a6 100644 --- a/toolchain/check/testdata/namespace/add_to_import.carbon +++ b/toolchain/check/testdata/namespace/add_to_import.carbon @@ -22,9 +22,9 @@ var a: i32 = NS.A(); // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .NS = %.loc4 +// CHECK:STDOUT: .NS = %NS // CHECK:STDOUT: } -// CHECK:STDOUT: %.loc4: = namespace [template] {} +// CHECK:STDOUT: %NS: = namespace [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- implicit.impl.carbon @@ -35,11 +35,11 @@ var a: i32 = NS.A(); // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .NS = %.2 +// CHECK:STDOUT: .NS = %NS // CHECK:STDOUT: .a = %a // CHECK:STDOUT: } // CHECK:STDOUT: %import_ref: = import_ref ir1, inst+1, used -// CHECK:STDOUT: %.2: = namespace %import_ref, [template] { +// CHECK:STDOUT: %NS: = namespace %import_ref, [template] { // CHECK:STDOUT: .A = %A // CHECK:STDOUT: } // CHECK:STDOUT: %A: = fn_decl @A [template] { @@ -57,7 +57,7 @@ var a: i32 = NS.A(); // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %NS.ref: = name_ref NS, file.%.2 [template = file.%.2] +// CHECK:STDOUT: %NS.ref: = name_ref NS, file.%NS [template = file.%NS] // CHECK:STDOUT: %A.ref: = name_ref A, file.%A [template = file.%A] // CHECK:STDOUT: %.loc6: init i32 = call %A.ref() // CHECK:STDOUT: assign file.%a.var, %.loc6 diff --git a/toolchain/check/testdata/namespace/alias.carbon b/toolchain/check/testdata/namespace/alias.carbon index 42de948ff1d6..95ed04319f2d 100644 --- a/toolchain/check/testdata/namespace/alias.carbon +++ b/toolchain/check/testdata/namespace/alias.carbon @@ -24,24 +24,24 @@ fn D() -> i32 { return C(); } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .NS = %.loc7 +// CHECK:STDOUT: .NS = %NS // CHECK:STDOUT: .ns = %ns // CHECK:STDOUT: .B = %B // CHECK:STDOUT: .C = %C // CHECK:STDOUT: .D = %D // CHECK:STDOUT: } -// CHECK:STDOUT: %.loc7: = namespace [template] { +// CHECK:STDOUT: %NS: = namespace [template] { // CHECK:STDOUT: .A = %A // CHECK:STDOUT: } -// CHECK:STDOUT: %NS.ref.loc9: = name_ref NS, %.loc7 [template = %.loc7] -// CHECK:STDOUT: %ns: = bind_alias ns, %.loc7 [template = %.loc7] +// CHECK:STDOUT: %NS.ref.loc9: = name_ref NS, %NS [template = %NS] +// CHECK:STDOUT: %ns: = bind_alias ns, %NS [template = %NS] // CHECK:STDOUT: %A: = fn_decl @A [template] { // CHECK:STDOUT: %return.var.loc11: ref i32 = var // CHECK:STDOUT: } // CHECK:STDOUT: %B: = fn_decl @B [template] { // CHECK:STDOUT: %return.var.loc13: ref i32 = var // CHECK:STDOUT: } -// CHECK:STDOUT: %NS.ref.loc15: = name_ref NS, %.loc7 [template = %.loc7] +// CHECK:STDOUT: %NS.ref.loc15: = name_ref NS, %NS [template = %NS] // CHECK:STDOUT: %A.ref: = name_ref A, %A [template = %A] // CHECK:STDOUT: %C: = bind_alias C, %A [template = %A] // CHECK:STDOUT: %D: = fn_decl @D [template] { @@ -57,7 +57,7 @@ fn D() -> i32 { return C(); } // CHECK:STDOUT: // CHECK:STDOUT: fn @B() -> i32 { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %ns.ref: = name_ref ns, file.%ns [template = file.%.loc7] +// CHECK:STDOUT: %ns.ref: = name_ref ns, file.%ns [template = file.%NS] // CHECK:STDOUT: %A.ref: = name_ref A, file.%A [template = file.%A] // CHECK:STDOUT: %.loc13_28.1: init i32 = call %A.ref() // CHECK:STDOUT: %.loc13_30: i32 = value_of_initializer %.loc13_28.1 diff --git a/toolchain/check/testdata/namespace/fail_conflict_after_merge.carbon b/toolchain/check/testdata/namespace/fail_conflict_after_merge.carbon index b9dcf6c3420f..24ed99b1c4c5 100644 --- a/toolchain/check/testdata/namespace/fail_conflict_after_merge.carbon +++ b/toolchain/check/testdata/namespace/fail_conflict_after_merge.carbon @@ -44,20 +44,20 @@ fn NS(); // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .NS = %.loc4 +// CHECK:STDOUT: .NS = %NS // CHECK:STDOUT: } -// CHECK:STDOUT: %.loc4: = namespace [template] {} +// CHECK:STDOUT: %NS: = namespace [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- fail_conflict.carbon // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .NS = %.loc8_13.1 +// CHECK:STDOUT: .NS = %NS // CHECK:STDOUT: } // CHECK:STDOUT: %import_ref: = import_ref ir1, inst+1, used -// CHECK:STDOUT: %.loc8_13.1: = namespace %import_ref, [template] {} -// CHECK:STDOUT: %.loc8_13.2: = namespace [template] {} +// CHECK:STDOUT: %NS: = namespace %import_ref, [template] {} +// CHECK:STDOUT: %.loc8: = namespace [template] {} // CHECK:STDOUT: %.loc16: = fn_decl @.1 [template] {} // CHECK:STDOUT: %.loc20: = namespace [template] {} // CHECK:STDOUT: %.loc28: = fn_decl @.2 [template] {} diff --git a/toolchain/check/testdata/namespace/fail_conflict_imported_namespace_first.carbon b/toolchain/check/testdata/namespace/fail_conflict_imported_namespace_first.carbon index b034510aa9ed..9b91dd6ebbdf 100644 --- a/toolchain/check/testdata/namespace/fail_conflict_imported_namespace_first.carbon +++ b/toolchain/check/testdata/namespace/fail_conflict_imported_namespace_first.carbon @@ -30,19 +30,19 @@ fn NS.Foo(); // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .NS = %.loc4 +// CHECK:STDOUT: .NS = %NS // CHECK:STDOUT: } -// CHECK:STDOUT: %.loc4: = namespace [template] {} +// CHECK:STDOUT: %NS: = namespace [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- fail_conflict.carbon // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .NS = %.2 +// CHECK:STDOUT: .NS = %NS // CHECK:STDOUT: } // CHECK:STDOUT: %import_ref: = import_ref ir1, inst+1, used -// CHECK:STDOUT: %.2: = namespace %import_ref, [template] { +// CHECK:STDOUT: %NS: = namespace %import_ref, [template] { // CHECK:STDOUT: .Foo = %Foo // CHECK:STDOUT: } // CHECK:STDOUT: %.loc12: = fn_decl @.1 [template] {} diff --git a/toolchain/check/testdata/namespace/fail_conflict_in_imports_namespace_first.carbon b/toolchain/check/testdata/namespace/fail_conflict_in_imports_namespace_first.carbon index b702cf94807a..d520e5be005d 100644 --- a/toolchain/check/testdata/namespace/fail_conflict_in_imports_namespace_first.carbon +++ b/toolchain/check/testdata/namespace/fail_conflict_in_imports_namespace_first.carbon @@ -36,9 +36,9 @@ fn NS.Bar() {} // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .NS = %.loc4 +// CHECK:STDOUT: .NS = %NS // CHECK:STDOUT: } -// CHECK:STDOUT: %.loc4: = namespace [template] { +// CHECK:STDOUT: %NS: = namespace [template] { // CHECK:STDOUT: .Foo = %Foo // CHECK:STDOUT: } // CHECK:STDOUT: %Foo: = fn_decl @Foo [template] {} @@ -67,10 +67,10 @@ fn NS.Bar() {} // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .NS = %.2 +// CHECK:STDOUT: .NS = %NS // CHECK:STDOUT: } // CHECK:STDOUT: %import_ref.1: = import_ref ir1, inst+1, used -// CHECK:STDOUT: %.2: = namespace %import_ref.1, [template] { +// CHECK:STDOUT: %NS: = namespace %import_ref.1, [template] { // CHECK:STDOUT: .Foo = %import_ref.2 // CHECK:STDOUT: .Bar = %Bar // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/namespace/fail_conflict_in_imports_namespace_second.carbon b/toolchain/check/testdata/namespace/fail_conflict_in_imports_namespace_second.carbon index bd4c5f7d9ae6..c43c641f1cef 100644 --- a/toolchain/check/testdata/namespace/fail_conflict_in_imports_namespace_second.carbon +++ b/toolchain/check/testdata/namespace/fail_conflict_in_imports_namespace_second.carbon @@ -50,9 +50,9 @@ fn NS.Bar() {} // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .NS = %.loc10 +// CHECK:STDOUT: .NS = %NS // CHECK:STDOUT: } -// CHECK:STDOUT: %.loc10: = namespace [template] { +// CHECK:STDOUT: %NS: = namespace [template] { // CHECK:STDOUT: .Foo = %Foo // CHECK:STDOUT: } // CHECK:STDOUT: %Foo: = fn_decl @Foo [template] {} @@ -67,11 +67,11 @@ fn NS.Bar() {} // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .NS = %.2 +// CHECK:STDOUT: .NS = %NS // CHECK:STDOUT: } // CHECK:STDOUT: %import_ref.1 = import_ref ir1, inst+1, unused // CHECK:STDOUT: %import_ref.2: = import_ref ir2, inst+1, used -// CHECK:STDOUT: %.2: = namespace %import_ref.2, [template] { +// CHECK:STDOUT: %NS: = namespace %import_ref.2, [template] { // CHECK:STDOUT: .Foo = %import_ref.3 // CHECK:STDOUT: .Bar = %Bar // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/namespace/fail_decl_in_alias.carbon b/toolchain/check/testdata/namespace/fail_decl_in_alias.carbon index 81ad1a0cb0d7..27fd55055e3d 100644 --- a/toolchain/check/testdata/namespace/fail_decl_in_alias.carbon +++ b/toolchain/check/testdata/namespace/fail_decl_in_alias.carbon @@ -25,12 +25,12 @@ fn ns.A() -> i32 { return 0; } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .NS = %.loc7 +// CHECK:STDOUT: .NS = %NS // CHECK:STDOUT: .ns = %ns // CHECK:STDOUT: } -// CHECK:STDOUT: %.loc7: = namespace [template] {} -// CHECK:STDOUT: %NS.ref: = name_ref NS, %.loc7 [template = %.loc7] -// CHECK:STDOUT: %ns: = bind_alias ns, %.loc7 [template = %.loc7] +// CHECK:STDOUT: %NS: = namespace [template] {} +// CHECK:STDOUT: %NS.ref: = name_ref NS, %NS [template = %NS] +// CHECK:STDOUT: %ns: = bind_alias ns, %NS [template = %NS] // CHECK:STDOUT: %.loc18: = fn_decl @.1 [template] { // CHECK:STDOUT: %return.var: ref i32 = var // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/namespace/fail_duplicate.carbon b/toolchain/check/testdata/namespace/fail_duplicate.carbon index ba878b5333c7..d2380eadfc4e 100644 --- a/toolchain/check/testdata/namespace/fail_duplicate.carbon +++ b/toolchain/check/testdata/namespace/fail_duplicate.carbon @@ -22,9 +22,9 @@ fn Foo.Baz() { // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Foo = %.loc7 +// CHECK:STDOUT: .Foo = %Foo // CHECK:STDOUT: } -// CHECK:STDOUT: %.loc7: = namespace [template] { +// CHECK:STDOUT: %Foo: = namespace [template] { // CHECK:STDOUT: .Baz = %Baz.loc9 // CHECK:STDOUT: } // CHECK:STDOUT: %Baz.loc9: = fn_decl @Baz [template] {} diff --git a/toolchain/check/testdata/namespace/fail_modifiers.carbon b/toolchain/check/testdata/namespace/fail_modifiers.carbon index a02740072118..0c643e8cc508 100644 --- a/toolchain/check/testdata/namespace/fail_modifiers.carbon +++ b/toolchain/check/testdata/namespace/fail_modifiers.carbon @@ -47,12 +47,12 @@ extern namespace C; // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .A = %.loc34 -// CHECK:STDOUT: .B = %.loc39 -// CHECK:STDOUT: .C = %.loc44 +// CHECK:STDOUT: .A = %A +// CHECK:STDOUT: .B = %B +// CHECK:STDOUT: .C = %C // CHECK:STDOUT: } -// CHECK:STDOUT: %.loc34: = namespace [template] {} -// CHECK:STDOUT: %.loc39: = namespace [template] {} -// CHECK:STDOUT: %.loc44: = namespace [template] {} +// CHECK:STDOUT: %A: = namespace [template] {} +// CHECK:STDOUT: %B: = namespace [template] {} +// CHECK:STDOUT: %C: = namespace [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/namespace/function.carbon b/toolchain/check/testdata/namespace/function.carbon index 8f3e2897b1c4..644456c312b4 100644 --- a/toolchain/check/testdata/namespace/function.carbon +++ b/toolchain/check/testdata/namespace/function.carbon @@ -25,11 +25,11 @@ fn Bar() { // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Foo = %.loc7 +// CHECK:STDOUT: .Foo = %Foo // CHECK:STDOUT: .Baz = %Baz.loc10 // CHECK:STDOUT: .Bar = %Bar // CHECK:STDOUT: } -// CHECK:STDOUT: %.loc7: = namespace [template] { +// CHECK:STDOUT: %Foo: = namespace [template] { // CHECK:STDOUT: .Baz = %Baz.loc13 // CHECK:STDOUT: } // CHECK:STDOUT: %Baz.loc10: = fn_decl @Baz.1 [template] {} @@ -49,7 +49,7 @@ fn Bar() { // CHECK:STDOUT: // CHECK:STDOUT: fn @Bar() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %Foo.ref: = name_ref Foo, file.%.loc7 [template = file.%.loc7] +// CHECK:STDOUT: %Foo.ref: = name_ref Foo, file.%Foo [template = file.%Foo] // CHECK:STDOUT: %Baz.ref: = name_ref Baz, file.%Baz.loc13 [template = file.%Baz.loc13] // CHECK:STDOUT: %.loc17: init () = call %Baz.ref() // CHECK:STDOUT: return diff --git a/toolchain/check/testdata/namespace/imported.carbon b/toolchain/check/testdata/namespace/imported.carbon index 3ce963f388c5..78c98c8841bc 100644 --- a/toolchain/check/testdata/namespace/imported.carbon +++ b/toolchain/check/testdata/namespace/imported.carbon @@ -28,13 +28,13 @@ var package_b: () = package.NS.ChildNS.B(); // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .NS = %.loc4 +// CHECK:STDOUT: .NS = %NS // CHECK:STDOUT: } -// CHECK:STDOUT: %.loc4: = namespace [template] { -// CHECK:STDOUT: .ChildNS = %.loc5 +// CHECK:STDOUT: %NS: = namespace [template] { +// CHECK:STDOUT: .ChildNS = %ChildNS // CHECK:STDOUT: .A = %A // CHECK:STDOUT: } -// CHECK:STDOUT: %.loc5: = namespace [template] { +// CHECK:STDOUT: %ChildNS: = namespace [template] { // CHECK:STDOUT: .B = %B // CHECK:STDOUT: } // CHECK:STDOUT: %A: = fn_decl @A [template] {} @@ -53,19 +53,19 @@ var package_b: () = package.NS.ChildNS.B(); // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .NS = %.2 +// CHECK:STDOUT: .NS = %NS // CHECK:STDOUT: .a = %a // CHECK:STDOUT: .b = %b // CHECK:STDOUT: .package_a = %package_a // CHECK:STDOUT: .package_b = %package_b // CHECK:STDOUT: } // CHECK:STDOUT: %import_ref.1: = import_ref ir1, inst+1, used -// CHECK:STDOUT: %.2: = namespace %import_ref.1, [template] { -// CHECK:STDOUT: .ChildNS = %.3 +// CHECK:STDOUT: %NS: = namespace %import_ref.1, [template] { +// CHECK:STDOUT: .ChildNS = %ChildNS // CHECK:STDOUT: .A = %import_ref.3 // CHECK:STDOUT: } // CHECK:STDOUT: %import_ref.2: = import_ref ir1, inst+2, used -// CHECK:STDOUT: %.3: = namespace %import_ref.2, [template] { +// CHECK:STDOUT: %ChildNS: = namespace %import_ref.2, [template] { // CHECK:STDOUT: .B = %import_ref.4 // CHECK:STDOUT: } // CHECK:STDOUT: %import_ref.3: = import_ref ir1, inst+3, used [template = imports.%A] @@ -94,23 +94,23 @@ var package_b: () = package.NS.ChildNS.B(); // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %NS.ref.loc4: = name_ref NS, file.%.2 [template = file.%.2] +// CHECK:STDOUT: %NS.ref.loc4: = name_ref NS, file.%NS [template = file.%NS] // CHECK:STDOUT: %A.ref.loc4: = name_ref A, file.%import_ref.3 [template = imports.%A] // CHECK:STDOUT: %.loc4: init () = call %A.ref.loc4() // CHECK:STDOUT: assign file.%a.var, %.loc4 -// CHECK:STDOUT: %NS.ref.loc5: = name_ref NS, file.%.2 [template = file.%.2] -// CHECK:STDOUT: %ChildNS.ref.loc5: = name_ref ChildNS, file.%.3 [template = file.%.3] +// CHECK:STDOUT: %NS.ref.loc5: = name_ref NS, file.%NS [template = file.%NS] +// CHECK:STDOUT: %ChildNS.ref.loc5: = name_ref ChildNS, file.%ChildNS [template = file.%ChildNS] // CHECK:STDOUT: %B.ref.loc5: = name_ref B, file.%import_ref.4 [template = imports.%B] // CHECK:STDOUT: %.loc5: init () = call %B.ref.loc5() // CHECK:STDOUT: assign file.%b.var, %.loc5 // CHECK:STDOUT: %package.ref.loc7: = name_ref package, package [template = package] -// CHECK:STDOUT: %NS.ref.loc7: = name_ref NS, file.%.2 [template = file.%.2] +// CHECK:STDOUT: %NS.ref.loc7: = name_ref NS, file.%NS [template = file.%NS] // CHECK:STDOUT: %A.ref.loc7: = name_ref A, file.%import_ref.3 [template = imports.%A] // CHECK:STDOUT: %.loc7: init () = call %A.ref.loc7() // CHECK:STDOUT: assign file.%package_a.var, %.loc7 // CHECK:STDOUT: %package.ref.loc8: = name_ref package, package [template = package] -// CHECK:STDOUT: %NS.ref.loc8: = name_ref NS, file.%.2 [template = file.%.2] -// CHECK:STDOUT: %ChildNS.ref.loc8: = name_ref ChildNS, file.%.3 [template = file.%.3] +// CHECK:STDOUT: %NS.ref.loc8: = name_ref NS, file.%NS [template = file.%NS] +// CHECK:STDOUT: %ChildNS.ref.loc8: = name_ref ChildNS, file.%ChildNS [template = file.%ChildNS] // CHECK:STDOUT: %B.ref.loc8: = name_ref B, file.%import_ref.4 [template = imports.%B] // CHECK:STDOUT: %.loc8: init () = call %B.ref.loc8() // CHECK:STDOUT: assign file.%package_b.var, %.loc8 diff --git a/toolchain/check/testdata/namespace/imported_indirect.carbon b/toolchain/check/testdata/namespace/imported_indirect.carbon index 04546d6ba01c..0c3ea352ff1e 100644 --- a/toolchain/check/testdata/namespace/imported_indirect.carbon +++ b/toolchain/check/testdata/namespace/imported_indirect.carbon @@ -42,57 +42,57 @@ var e: () = A.B.C.D(); // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .A = %.loc4 +// CHECK:STDOUT: .A = %A // CHECK:STDOUT: } -// CHECK:STDOUT: %.loc4: = namespace [template] {} +// CHECK:STDOUT: %A: = namespace [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- b.carbon // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .A = %.2 +// CHECK:STDOUT: .A = %A // CHECK:STDOUT: } // CHECK:STDOUT: %import_ref: = import_ref ir1, inst+1, used -// CHECK:STDOUT: %.2: = namespace %import_ref, [template] { -// CHECK:STDOUT: .B = %.loc5 +// CHECK:STDOUT: %A: = namespace %import_ref, [template] { +// CHECK:STDOUT: .B = %B // CHECK:STDOUT: } -// CHECK:STDOUT: %.loc5: = namespace [template] {} +// CHECK:STDOUT: %B: = namespace [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- c.carbon // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .A = %.2 +// CHECK:STDOUT: .A = %A // CHECK:STDOUT: } // CHECK:STDOUT: %import_ref.1: = import_ref ir1, inst+2, used -// CHECK:STDOUT: %.2: = namespace %import_ref.1, [template] { -// CHECK:STDOUT: .B = %.3 +// CHECK:STDOUT: %A: = namespace %import_ref.1, [template] { +// CHECK:STDOUT: .B = %B // CHECK:STDOUT: } // CHECK:STDOUT: %import_ref.2: = import_ref ir1, inst+3, used -// CHECK:STDOUT: %.3: = namespace %import_ref.2, [template] { -// CHECK:STDOUT: .C = %.loc5 +// CHECK:STDOUT: %B: = namespace %import_ref.2, [template] { +// CHECK:STDOUT: .C = %C // CHECK:STDOUT: } -// CHECK:STDOUT: %.loc5: = namespace [template] {} +// CHECK:STDOUT: %C: = namespace [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- d.carbon // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .A = %.2 +// CHECK:STDOUT: .A = %A // CHECK:STDOUT: } // CHECK:STDOUT: %import_ref.1: = import_ref ir1, inst+2, used -// CHECK:STDOUT: %.2: = namespace %import_ref.1, [template] { -// CHECK:STDOUT: .B = %.3 +// CHECK:STDOUT: %A: = namespace %import_ref.1, [template] { +// CHECK:STDOUT: .B = %B // CHECK:STDOUT: } // CHECK:STDOUT: %import_ref.2: = import_ref ir1, inst+4, used -// CHECK:STDOUT: %.3: = namespace %import_ref.2, [template] { -// CHECK:STDOUT: .C = %.4 +// CHECK:STDOUT: %B: = namespace %import_ref.2, [template] { +// CHECK:STDOUT: .C = %C // CHECK:STDOUT: } // CHECK:STDOUT: %import_ref.3: = import_ref ir1, inst+5, used -// CHECK:STDOUT: %.4: = namespace %import_ref.3, [template] { +// CHECK:STDOUT: %C: = namespace %import_ref.3, [template] { // CHECK:STDOUT: .D = %D // CHECK:STDOUT: } // CHECK:STDOUT: %D: = fn_decl @D [template] {} @@ -111,19 +111,19 @@ var e: () = A.B.C.D(); // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .A = %.2 +// CHECK:STDOUT: .A = %A // CHECK:STDOUT: .e = %e // CHECK:STDOUT: } // CHECK:STDOUT: %import_ref.1: = import_ref ir1, inst+2, used -// CHECK:STDOUT: %.2: = namespace %import_ref.1, [template] { -// CHECK:STDOUT: .B = %.3 +// CHECK:STDOUT: %A: = namespace %import_ref.1, [template] { +// CHECK:STDOUT: .B = %B // CHECK:STDOUT: } // CHECK:STDOUT: %import_ref.2: = import_ref ir1, inst+4, used -// CHECK:STDOUT: %.3: = namespace %import_ref.2, [template] { -// CHECK:STDOUT: .C = %.4 +// CHECK:STDOUT: %B: = namespace %import_ref.2, [template] { +// CHECK:STDOUT: .C = %C // CHECK:STDOUT: } // CHECK:STDOUT: %import_ref.3: = import_ref ir1, inst+6, used -// CHECK:STDOUT: %.4: = namespace %import_ref.3, [template] { +// CHECK:STDOUT: %C: = namespace %import_ref.3, [template] { // CHECK:STDOUT: .D = %import_ref.4 // CHECK:STDOUT: } // CHECK:STDOUT: %import_ref.4: = import_ref ir1, inst+7, used [template = imports.%D] @@ -137,9 +137,9 @@ var e: () = A.B.C.D(); // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %A.ref: = name_ref A, file.%.2 [template = file.%.2] -// CHECK:STDOUT: %B.ref: = name_ref B, file.%.3 [template = file.%.3] -// CHECK:STDOUT: %C.ref: = name_ref C, file.%.4 [template = file.%.4] +// CHECK:STDOUT: %A.ref: = name_ref A, file.%A [template = file.%A] +// CHECK:STDOUT: %B.ref: = name_ref B, file.%B [template = file.%B] +// CHECK:STDOUT: %C.ref: = name_ref C, file.%C [template = file.%C] // CHECK:STDOUT: %D.ref: = name_ref D, file.%import_ref.4 [template = imports.%D] // CHECK:STDOUT: %.loc5: init () = call %D.ref() // CHECK:STDOUT: assign file.%e.var, %.loc5 diff --git a/toolchain/check/testdata/namespace/merging.carbon b/toolchain/check/testdata/namespace/merging.carbon index feaedb128b28..d0c29d414dca 100644 --- a/toolchain/check/testdata/namespace/merging.carbon +++ b/toolchain/check/testdata/namespace/merging.carbon @@ -46,9 +46,9 @@ fn Run() { // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .NS = %.loc4 +// CHECK:STDOUT: .NS = %NS // CHECK:STDOUT: } -// CHECK:STDOUT: %.loc4: = namespace [template] { +// CHECK:STDOUT: %NS: = namespace [template] { // CHECK:STDOUT: .A = %A // CHECK:STDOUT: } // CHECK:STDOUT: %A: = fn_decl @A [template] {} @@ -63,9 +63,9 @@ fn Run() { // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .NS = %.loc4 +// CHECK:STDOUT: .NS = %NS // CHECK:STDOUT: } -// CHECK:STDOUT: %.loc4: = namespace [template] { +// CHECK:STDOUT: %NS: = namespace [template] { // CHECK:STDOUT: .B1 = %B1 // CHECK:STDOUT: .B2 = %B2 // CHECK:STDOUT: } @@ -92,11 +92,11 @@ fn Run() { // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .NS = %.loc7_13.1 +// CHECK:STDOUT: .NS = %NS // CHECK:STDOUT: .Run = %Run // CHECK:STDOUT: } // CHECK:STDOUT: %import_ref.1: = import_ref ir1, inst+1, used -// CHECK:STDOUT: %.loc7_13.1: = namespace %import_ref.1, [template] { +// CHECK:STDOUT: %NS: = namespace %import_ref.1, [template] { // CHECK:STDOUT: .A = %import_ref.2 // CHECK:STDOUT: .B1 = %import_ref.3 // CHECK:STDOUT: .B2 = %import_ref.4 @@ -105,7 +105,7 @@ fn Run() { // CHECK:STDOUT: %import_ref.2: = import_ref ir1, inst+2, used [template = imports.%A] // CHECK:STDOUT: %import_ref.3: = import_ref ir2, inst+2, used [template = imports.%B1] // CHECK:STDOUT: %import_ref.4: = import_ref ir2, inst+5, used [template = imports.%B2] -// CHECK:STDOUT: %.loc7_13.2: = namespace [template] {} +// CHECK:STDOUT: %.loc7: = namespace [template] {} // CHECK:STDOUT: %C: = fn_decl @C [template] {} // CHECK:STDOUT: %Run: = fn_decl @Run [template] {} // CHECK:STDOUT: } @@ -117,16 +117,16 @@ fn Run() { // CHECK:STDOUT: // CHECK:STDOUT: fn @Run() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %NS.ref.loc12: = name_ref NS, file.%.loc7_13.1 [template = file.%.loc7_13.1] +// CHECK:STDOUT: %NS.ref.loc12: = name_ref NS, file.%NS [template = file.%NS] // CHECK:STDOUT: %A.ref: = name_ref A, file.%import_ref.2 [template = imports.%A] // CHECK:STDOUT: %.loc12: init () = call %A.ref() -// CHECK:STDOUT: %NS.ref.loc13: = name_ref NS, file.%.loc7_13.1 [template = file.%.loc7_13.1] +// CHECK:STDOUT: %NS.ref.loc13: = name_ref NS, file.%NS [template = file.%NS] // CHECK:STDOUT: %B1.ref: = name_ref B1, file.%import_ref.3 [template = imports.%B1] // CHECK:STDOUT: %.loc13: init () = call %B1.ref() -// CHECK:STDOUT: %NS.ref.loc14: = name_ref NS, file.%.loc7_13.1 [template = file.%.loc7_13.1] +// CHECK:STDOUT: %NS.ref.loc14: = name_ref NS, file.%NS [template = file.%NS] // CHECK:STDOUT: %B2.ref: = name_ref B2, file.%import_ref.4 [template = imports.%B2] // CHECK:STDOUT: %.loc14: init () = call %B2.ref() -// CHECK:STDOUT: %NS.ref.loc15: = name_ref NS, file.%.loc7_13.1 [template = file.%.loc7_13.1] +// CHECK:STDOUT: %NS.ref.loc15: = name_ref NS, file.%NS [template = file.%NS] // CHECK:STDOUT: %C.ref: = name_ref C, file.%C [template = file.%C] // CHECK:STDOUT: %.loc15: init () = call %C.ref() // CHECK:STDOUT: return diff --git a/toolchain/check/testdata/namespace/nested.carbon b/toolchain/check/testdata/namespace/nested.carbon index 88e4cbb51dde..f958aab4092e 100644 --- a/toolchain/check/testdata/namespace/nested.carbon +++ b/toolchain/check/testdata/namespace/nested.carbon @@ -22,12 +22,12 @@ fn Foo.Bar.Baz() { // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Foo = %.loc7 +// CHECK:STDOUT: .Foo = %Foo // CHECK:STDOUT: } -// CHECK:STDOUT: %.loc7: = namespace [template] { -// CHECK:STDOUT: .Bar = %.loc8 +// CHECK:STDOUT: %Foo: = namespace [template] { +// CHECK:STDOUT: .Bar = %Bar // CHECK:STDOUT: } -// CHECK:STDOUT: %.loc8: = namespace [template] { +// CHECK:STDOUT: %Bar: = namespace [template] { // CHECK:STDOUT: .Wiz = %Wiz // CHECK:STDOUT: .Baz = %Baz // CHECK:STDOUT: } @@ -42,8 +42,8 @@ fn Foo.Bar.Baz() { // CHECK:STDOUT: // CHECK:STDOUT: fn @Baz() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %Foo.ref: = name_ref Foo, file.%.loc7 [template = file.%.loc7] -// CHECK:STDOUT: %Bar.ref: = name_ref Bar, file.%.loc8 [template = file.%.loc8] +// CHECK:STDOUT: %Foo.ref: = name_ref Foo, file.%Foo [template = file.%Foo] +// CHECK:STDOUT: %Bar.ref: = name_ref Bar, file.%Bar [template = file.%Bar] // CHECK:STDOUT: %Wiz.ref: = name_ref Wiz, file.%Wiz [template = file.%Wiz] // CHECK:STDOUT: %.loc14: init () = call %Wiz.ref() // CHECK:STDOUT: return diff --git a/toolchain/check/testdata/namespace/shadow.carbon b/toolchain/check/testdata/namespace/shadow.carbon index 127299148910..49057f8728b2 100644 --- a/toolchain/check/testdata/namespace/shadow.carbon +++ b/toolchain/check/testdata/namespace/shadow.carbon @@ -34,15 +34,15 @@ fn N.M.B() -> i32 { // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .A = %A.loc7 -// CHECK:STDOUT: .N = %.loc9 +// CHECK:STDOUT: .N = %N // CHECK:STDOUT: } // CHECK:STDOUT: %A.loc7: = fn_decl @A.1 [template] {} -// CHECK:STDOUT: %.loc9: = namespace [template] { +// CHECK:STDOUT: %N: = namespace [template] { // CHECK:STDOUT: .A = %A.loc10 -// CHECK:STDOUT: .M = %.loc12 +// CHECK:STDOUT: .M = %M // CHECK:STDOUT: } // CHECK:STDOUT: %A.loc10: = fn_decl @A.2 [template] {} -// CHECK:STDOUT: %.loc12: = namespace [template] { +// CHECK:STDOUT: %M: = namespace [template] { // CHECK:STDOUT: .B = %B // CHECK:STDOUT: } // CHECK:STDOUT: %B: = fn_decl @B [template] { diff --git a/toolchain/check/testdata/namespace/unqualified_lookup.carbon b/toolchain/check/testdata/namespace/unqualified_lookup.carbon index e47203bf87bb..c7fc935fd722 100644 --- a/toolchain/check/testdata/namespace/unqualified_lookup.carbon +++ b/toolchain/check/testdata/namespace/unqualified_lookup.carbon @@ -34,16 +34,16 @@ fn OuterN.InnerN.CallABC() { // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .OuterN = %.loc7 +// CHECK:STDOUT: .OuterN = %OuterN // CHECK:STDOUT: .A = %A // CHECK:STDOUT: .CallA = %CallA // CHECK:STDOUT: } -// CHECK:STDOUT: %.loc7: = namespace [template] { -// CHECK:STDOUT: .InnerN = %.loc8 +// CHECK:STDOUT: %OuterN: = namespace [template] { +// CHECK:STDOUT: .InnerN = %InnerN // CHECK:STDOUT: .B = %B // CHECK:STDOUT: .CallAB = %CallAB // CHECK:STDOUT: } -// CHECK:STDOUT: %.loc8: = namespace [template] { +// CHECK:STDOUT: %InnerN: = namespace [template] { // CHECK:STDOUT: .C = %C // CHECK:STDOUT: .CallABC = %CallABC // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/package_expr/syntax.carbon b/toolchain/check/testdata/package_expr/syntax.carbon index 6791bed512fd..86e37a4cbd5e 100644 --- a/toolchain/check/testdata/package_expr/syntax.carbon +++ b/toolchain/check/testdata/package_expr/syntax.carbon @@ -130,10 +130,10 @@ fn Main() { // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .NS = %.loc4 +// CHECK:STDOUT: .NS = %NS // CHECK:STDOUT: .Main = %Main // CHECK:STDOUT: } -// CHECK:STDOUT: %.loc4: = namespace [template] { +// CHECK:STDOUT: %NS: = namespace [template] { // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: } // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} @@ -156,7 +156,7 @@ fn Main() { // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %package.ref: = name_ref package, package [template = package] -// CHECK:STDOUT: %NS.ref: = name_ref NS, file.%.loc4 [template = file.%.loc4] +// CHECK:STDOUT: %NS.ref: = name_ref NS, file.%NS [template = file.%NS] // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C] // CHECK:STDOUT: %Foo.ref: = name_ref Foo, @C.%Foo [template = @C.%Foo] // CHECK:STDOUT: %.loc11: init () = call %Foo.ref() diff --git a/toolchain/check/testdata/pointer/fail_deref_namespace.carbon b/toolchain/check/testdata/pointer/fail_deref_namespace.carbon index bb7f5222307f..00a413480a03 100644 --- a/toolchain/check/testdata/pointer/fail_deref_namespace.carbon +++ b/toolchain/check/testdata/pointer/fail_deref_namespace.carbon @@ -17,16 +17,16 @@ fn F() { // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .A = %.loc7 +// CHECK:STDOUT: .A = %A // CHECK:STDOUT: .F = %F // CHECK:STDOUT: } -// CHECK:STDOUT: %.loc7: = namespace [template] {} +// CHECK:STDOUT: %A: = namespace [template] {} // CHECK:STDOUT: %F: = fn_decl @F [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @F() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %A.ref: = name_ref A, file.%.loc7 [template = file.%.loc7] +// CHECK:STDOUT: %A.ref: = name_ref A, file.%A [template = file.%A] // CHECK:STDOUT: %.loc13: ref = deref // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/var/fail_namespace_conflict.carbon b/toolchain/check/testdata/var/fail_namespace_conflict.carbon index b9e39fe0e680..4e050c200c46 100644 --- a/toolchain/check/testdata/var/fail_namespace_conflict.carbon +++ b/toolchain/check/testdata/var/fail_namespace_conflict.carbon @@ -30,9 +30,9 @@ var A: i32 = 1; // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .A = %.loc7 +// CHECK:STDOUT: .A = %A.loc7 // CHECK:STDOUT: } -// CHECK:STDOUT: %.loc7: = namespace [template] {} +// CHECK:STDOUT: %A.loc7: = namespace [template] {} // CHECK:STDOUT: %A.var.loc15: ref i32 = var A // CHECK:STDOUT: %A.loc15: ref i32 = bind_name A, %A.var.loc15 // CHECK:STDOUT: %A.var.loc23: ref i32 = var A diff --git a/toolchain/check/testdata/var/shadowing.carbon b/toolchain/check/testdata/var/shadowing.carbon index 862e60c5a391..71fb3d35a3a8 100644 --- a/toolchain/check/testdata/var/shadowing.carbon +++ b/toolchain/check/testdata/var/shadowing.carbon @@ -29,10 +29,10 @@ fn Main() { // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .NS = %.loc7 +// CHECK:STDOUT: .NS = %NS // CHECK:STDOUT: .Main = %Main // CHECK:STDOUT: } -// CHECK:STDOUT: %.loc7: = namespace [template] {} +// CHECK:STDOUT: %NS: = namespace [template] {} // CHECK:STDOUT: %Main: = fn_decl @Main [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/sem_ir/formatter.cpp b/toolchain/sem_ir/formatter.cpp index df5ccb8e1e14..659e3917b0c0 100644 --- a/toolchain/sem_ir/formatter.cpp +++ b/toolchain/sem_ir/formatter.cpp @@ -531,6 +531,13 @@ class InstNamer { add_inst_name_id(inst.As().name_id, ".ref"); continue; } + // The namespace is specified here due to the name conflict. + case SemIR::Namespace::Kind: { + add_inst_name_id(sem_ir_.name_scopes() + .Get(inst.As().name_scope_id) + .name_id); + continue; + } case Param::Kind: { add_inst_name_id(inst.As().name_id); continue;