mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-24 13:02:41 +00:00
This is accomplished by tracking an extra bit on the ID we store in the constant values table, and propagating that from subexpressions to the enclosing expression. This extra bit is not yet computed correctly for types; that will be addressed in later PRs. --------- Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
73 lines
2.5 KiB
Plaintext
73 lines
2.5 KiB
Plaintext
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
|
// Exceptions. See /LICENSE for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
// AUTOUPDATE
|
|
|
|
class Outer {
|
|
class Inner {
|
|
var n: i32;
|
|
}
|
|
}
|
|
|
|
fn F(oi: Outer.Inner) -> i32 {
|
|
return oi.n;
|
|
}
|
|
|
|
fn G(o: Outer) {
|
|
var i: o.Inner;
|
|
}
|
|
|
|
// CHECK:STDOUT: --- nested_name.carbon
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: constants {
|
|
// CHECK:STDOUT: %.loc10: type = struct_type {.n: i32} [template]
|
|
// CHECK:STDOUT: %.loc11_1.1: type = struct_type {} [template]
|
|
// CHECK:STDOUT: %.loc8: type = ptr_type {.n: i32} [template]
|
|
// CHECK:STDOUT: %.loc11_1.2: type = tuple_type () [template]
|
|
// CHECK:STDOUT: %.loc7: type = ptr_type {} [template]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: file {
|
|
// CHECK:STDOUT: package: <namespace> = namespace package, {.Outer = %Outer.decl, .F = %F, .G = %G}
|
|
// CHECK:STDOUT: %Outer.decl = class_decl @Outer, ()
|
|
// CHECK:STDOUT: %Outer: type = class_type @Outer [template]
|
|
// CHECK:STDOUT: %F: <function> = fn_decl @F [template]
|
|
// CHECK:STDOUT: %G: <function> = fn_decl @G [template]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: class @Outer {
|
|
// CHECK:STDOUT: %Inner.decl = class_decl @Inner, ()
|
|
// CHECK:STDOUT: %Inner: type = class_type @Inner [template]
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: !members:
|
|
// CHECK:STDOUT: .Inner = %Inner.decl
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: class @Inner {
|
|
// CHECK:STDOUT: %.loc9_10.1: type = unbound_element_type Inner, i32 [template]
|
|
// CHECK:STDOUT: %.loc9_10.2: <unbound element of class Inner> = field_decl n, element0 [template]
|
|
// CHECK:STDOUT: %n: <unbound element of class Inner> = bind_name n, %.loc9_10.2 [template = %.loc9_10.2]
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: !members:
|
|
// CHECK:STDOUT: .n = %n
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @F(%oi: Inner) -> i32 {
|
|
// CHECK:STDOUT: !entry:
|
|
// CHECK:STDOUT: %oi.ref: Inner = name_ref oi, %oi
|
|
// CHECK:STDOUT: %.loc14_12.1: ref i32 = class_element_access %oi.ref, element0
|
|
// CHECK:STDOUT: %.loc14_12.2: i32 = bind_value %.loc14_12.1
|
|
// CHECK:STDOUT: return %.loc14_12.2
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @G(%o: Outer) {
|
|
// CHECK:STDOUT: !entry:
|
|
// CHECK:STDOUT: %o.ref: Outer = name_ref o, %o
|
|
// CHECK:STDOUT: %Inner.ref: type = name_ref Inner, @Outer.%Inner [template = @Outer.%Inner]
|
|
// CHECK:STDOUT: %i.var: ref Inner = var i
|
|
// CHECK:STDOUT: %i: ref Inner = bind_name i, %i.var
|
|
// CHECK:STDOUT: return
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|