Implement constant handling for types of imports. (#3693)

This provides support for Const, Pointer, Struct, and Tuple types. It
does not cover Class, Function, or Interface which have their own Id and
are tracked slightly differently.
This commit is contained in:
Jon Ross-Perkins
2024-02-09 00:11:37 +00:00
committed by GitHub
parent 4d0c3811c9
commit 475ecca339
17 changed files with 909 additions and 252 deletions
@@ -2,11 +2,7 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// When there are no more cases that can hit a TODO, remove this test. Until
// then, update it whenever its target is implemented.
//
// AUTOUPDATE
// CHECK:STDERR: implicit.impl.carbon: ERROR: Semantics TODO: `TODO: ResolveIfImportRefUnused for non-builtin type`.
// --- implicit.carbon
@@ -51,11 +47,12 @@ var a: i32* = a_ref;
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace {.a_orig = %import_ref.1, .a_ref = %import_ref.2, .a = %a} [template]
// CHECK:STDOUT: %import_ref.1 = import_ref ir1, inst+2, unused
// CHECK:STDOUT: %import_ref.2: ref <error> = import_ref ir1, inst+9, used
// CHECK:STDOUT: %.loc4: type = ptr_type i32 [template = constants.%.1]
// CHECK:STDOUT: %import_ref.2: ref i32* = import_ref ir1, inst+9, used
// CHECK:STDOUT: %.loc4_11: type = ptr_type i32 [template = constants.%.1]
// CHECK:STDOUT: %a.var: ref i32* = var a
// CHECK:STDOUT: %a: ref i32* = bind_name a, %a.var
// CHECK:STDOUT: %a_ref.ref: ref <error> = name_ref a_ref, %import_ref.2
// CHECK:STDOUT: assign %a.var, <error>
// CHECK:STDOUT: %a_ref.ref: ref i32* = name_ref a_ref, %import_ref.2
// CHECK:STDOUT: %.loc4_15: i32* = bind_value %a_ref.ref
// CHECK:STDOUT: assign %a.var, %.loc4_15
// CHECK:STDOUT: }
// CHECK:STDOUT: