mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Start including the prelude for testing. (#3861)
- Adds an empty prelude.carbon file - Imports that file in any non-Core package file - Adds --disable-prelude-import to avoid that - Adds --exclude-dump-file-prefix to be able to hide files from dumping - Used to hide core files (we can't do this by package name due to lex dumps, for example) - Restructures some tests to not rely on `i32`, particularly `alias` tests (which rely on a name ref) and tests with no prelude. I'm adding the framework for switching i32 to calling Int32 in the prelude, but I'm running into a separate error actually switching over. So that *mostly* works, but isn't quite ready for prime time. However, maybe the current state of this PR is still useful to review since it does a lot of the infrastructure work and adds the %Core everywhere?
This commit is contained in:
@@ -18,8 +18,10 @@ fn F() -> i32 {
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file {
|
||||
// CHECK:STDOUT: package: <namespace> = namespace [template] {
|
||||
// CHECK:STDOUT: .Core = %Core
|
||||
// CHECK:STDOUT: .F = %F
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
|
||||
// CHECK:STDOUT: %F: <function> = fn_decl @F [template] {
|
||||
// CHECK:STDOUT: %return.var: ref i32 = var <return slot>
|
||||
// CHECK:STDOUT: }
|
||||
|
||||
@@ -34,8 +34,10 @@ fn F() {
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file {
|
||||
// CHECK:STDOUT: package: <namespace> = namespace [template] {
|
||||
// CHECK:STDOUT: .Core = %Core
|
||||
// CHECK:STDOUT: .F = %F
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
|
||||
// CHECK:STDOUT: %F: <function> = fn_decl @F [template] {}
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
|
||||
@@ -32,9 +32,11 @@ fn Foo(ptr: C*) {
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file {
|
||||
// CHECK:STDOUT: package: <namespace> = namespace [template] {
|
||||
// CHECK:STDOUT: .Core = %Core
|
||||
// CHECK:STDOUT: .C = %C.decl
|
||||
// CHECK:STDOUT: .Foo = %Foo
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
|
||||
// CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {}
|
||||
// CHECK:STDOUT: %Foo: <function> = fn_decl @Foo [template] {
|
||||
// CHECK:STDOUT: %C.ref: type = name_ref C, %C.decl [template = constants.%C]
|
||||
|
||||
@@ -20,8 +20,10 @@ fn F() -> i32 {
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file {
|
||||
// CHECK:STDOUT: package: <namespace> = namespace [template] {
|
||||
// CHECK:STDOUT: .Core = %Core
|
||||
// CHECK:STDOUT: .F = %F
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
|
||||
// CHECK:STDOUT: %F: <function> = fn_decl @F [template] {
|
||||
// CHECK:STDOUT: %return.var: ref i32 = var <return slot>
|
||||
// CHECK:STDOUT: }
|
||||
|
||||
@@ -24,8 +24,10 @@ fn Test() {
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file {
|
||||
// CHECK:STDOUT: package: <namespace> = namespace [template] {
|
||||
// CHECK:STDOUT: .Core = %Core
|
||||
// CHECK:STDOUT: .Test = %Test
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
|
||||
// CHECK:STDOUT: %Test: <function> = fn_decl @Test [template] {}
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
|
||||
@@ -122,6 +122,7 @@ fn AddressOfParam(param: i32) {
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file {
|
||||
// CHECK:STDOUT: package: <namespace> = namespace [template] {
|
||||
// CHECK:STDOUT: .Core = %Core
|
||||
// CHECK:STDOUT: .G = %G
|
||||
// CHECK:STDOUT: .H = %H
|
||||
// CHECK:STDOUT: .AddressOfLiteral = %AddressOfLiteral
|
||||
@@ -131,6 +132,7 @@ fn AddressOfParam(param: i32) {
|
||||
// CHECK:STDOUT: .AddressOfTupleElementValue = %AddressOfTupleElementValue
|
||||
// CHECK:STDOUT: .AddressOfParam = %AddressOfParam
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
|
||||
// CHECK:STDOUT: %G: <function> = fn_decl @G [template] {
|
||||
// CHECK:STDOUT: %return.var.loc7: ref i32 = var <return slot>
|
||||
// CHECK:STDOUT: }
|
||||
|
||||
@@ -17,7 +17,10 @@ let n2: i32 = undeclared->foo;
|
||||
// CHECK:STDOUT: --- fail_deref_error.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file {
|
||||
// CHECK:STDOUT: package: <namespace> = namespace [template] {}
|
||||
// CHECK:STDOUT: package: <namespace> = namespace [template] {
|
||||
// CHECK:STDOUT: .Core = %Core
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
|
||||
// CHECK:STDOUT: %undeclared.ref.loc11: <error> = name_ref undeclared, <error> [template = <error>]
|
||||
// CHECK:STDOUT: %.loc11: ref <error> = deref <error>
|
||||
// CHECK:STDOUT: %n: i32 = bind_name n, <error>
|
||||
|
||||
@@ -20,8 +20,10 @@ fn A() {
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file {
|
||||
// CHECK:STDOUT: package: <namespace> = namespace [template] {
|
||||
// CHECK:STDOUT: .Core = %Core
|
||||
// CHECK:STDOUT: .A = %A
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
|
||||
// CHECK:STDOUT: %A: <function> = fn_decl @A [template] {}
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
|
||||
@@ -22,9 +22,11 @@ fn F() {
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file {
|
||||
// CHECK:STDOUT: package: <namespace> = namespace [template] {
|
||||
// CHECK:STDOUT: .Core = %Core
|
||||
// CHECK:STDOUT: .A = %A
|
||||
// CHECK:STDOUT: .F = %F
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
|
||||
// CHECK:STDOUT: %A: <namespace> = namespace [template] {}
|
||||
// CHECK:STDOUT: %F: <function> = fn_decl @F [template] {}
|
||||
// CHECK:STDOUT: }
|
||||
|
||||
@@ -47,8 +47,10 @@ fn Deref(n: i32) {
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file {
|
||||
// CHECK:STDOUT: package: <namespace> = namespace [template] {
|
||||
// CHECK:STDOUT: .Core = %Core
|
||||
// CHECK:STDOUT: .Deref = %Deref
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
|
||||
// CHECK:STDOUT: %Deref: <function> = fn_decl @Deref [template] {
|
||||
// CHECK:STDOUT: %n.loc7_10.1: i32 = param n
|
||||
// CHECK:STDOUT: @Deref.%n: i32 = bind_name n, %n.loc7_10.1
|
||||
|
||||
@@ -21,9 +21,11 @@ var p2: i32->foo;
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file {
|
||||
// CHECK:STDOUT: package: <namespace> = namespace [template] {
|
||||
// CHECK:STDOUT: .Core = %Core
|
||||
// CHECK:STDOUT: .p = %p
|
||||
// CHECK:STDOUT: .p2 = %p2
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
|
||||
// CHECK:STDOUT: %.loc14: ref <error> = deref i32
|
||||
// CHECK:STDOUT: %p.var: ref <error> = var p
|
||||
// CHECK:STDOUT: %p: ref <error> = bind_name p, %p.var
|
||||
|
||||
@@ -23,8 +23,10 @@ fn ConstMismatch(p: const {}*) -> const ({}*) {
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file {
|
||||
// CHECK:STDOUT: package: <namespace> = namespace [template] {
|
||||
// CHECK:STDOUT: .Core = %Core
|
||||
// CHECK:STDOUT: .ConstMismatch = %ConstMismatch
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
|
||||
// CHECK:STDOUT: %ConstMismatch: <function> = fn_decl @ConstMismatch [template] {
|
||||
// CHECK:STDOUT: %.loc7_28.1: {} = struct_literal ()
|
||||
// CHECK:STDOUT: %.loc7_28.2: type = converted %.loc7_28.1, constants.%.1 [template = constants.%.1]
|
||||
|
||||
+6
-2
@@ -26,9 +26,11 @@ var a: i32* = a_ref;
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file {
|
||||
// CHECK:STDOUT: package: <namespace> = namespace [template] {
|
||||
// CHECK:STDOUT: .Core = %Core
|
||||
// CHECK:STDOUT: .a_orig = %a_orig
|
||||
// CHECK:STDOUT: .a_ref = %a_ref
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
|
||||
// CHECK:STDOUT: %a_orig.var: ref i32 = var a_orig
|
||||
// CHECK:STDOUT: %a_orig: ref i32 = bind_name a_orig, %a_orig.var
|
||||
// CHECK:STDOUT: %.loc5: type = ptr_type i32 [template = constants.%.2]
|
||||
@@ -56,10 +58,12 @@ var a: i32* = a_ref;
|
||||
// CHECK:STDOUT: package: <namespace> = namespace [template] {
|
||||
// CHECK:STDOUT: .a_orig = %import_ref.1
|
||||
// CHECK:STDOUT: .a_ref = %import_ref.2
|
||||
// CHECK:STDOUT: .Core = %Core
|
||||
// CHECK:STDOUT: .a = %a
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %import_ref.1 = import_ref ir1, inst+2, unloaded
|
||||
// CHECK:STDOUT: %import_ref.2: ref i32* = import_ref ir1, inst+9, loc_11
|
||||
// CHECK:STDOUT: %import_ref.1 = import_ref ir1, inst+3, unloaded
|
||||
// CHECK:STDOUT: %import_ref.2: ref i32* = import_ref ir1, inst+10, loc_11
|
||||
// CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
|
||||
// CHECK:STDOUT: %.loc4: 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
|
||||
|
||||
@@ -21,8 +21,10 @@ fn F(p: const (const (const i32*)*)) -> const i32 {
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file {
|
||||
// CHECK:STDOUT: package: <namespace> = namespace [template] {
|
||||
// CHECK:STDOUT: .Core = %Core
|
||||
// CHECK:STDOUT: .F = %F
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
|
||||
// CHECK:STDOUT: %F: <function> = fn_decl @F [template] {
|
||||
// CHECK:STDOUT: %.loc8_23: type = const_type i32 [template = constants.%.1]
|
||||
// CHECK:STDOUT: %.loc8_32: type = ptr_type const i32 [template = constants.%.2]
|
||||
|
||||
@@ -22,9 +22,11 @@ fn ConstPtr(p: const i32*) -> (const i32)* {
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file {
|
||||
// CHECK:STDOUT: package: <namespace> = namespace [template] {
|
||||
// CHECK:STDOUT: .Core = %Core
|
||||
// CHECK:STDOUT: .Ptr = %Ptr
|
||||
// CHECK:STDOUT: .ConstPtr = %ConstPtr
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
|
||||
// CHECK:STDOUT: %Ptr: <function> = fn_decl @Ptr [template] {
|
||||
// CHECK:STDOUT: %.loc7_14: type = ptr_type i32 [template = constants.%.1]
|
||||
// CHECK:STDOUT: %p.loc7_8.1: i32* = param p
|
||||
|
||||
Reference in New Issue
Block a user