mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Implement checking observe declarations (#6709)
This adds SemIR structs and implements building `observe` lists, as well as naming, formatting, and importing `observe` declarations. --------- Co-authored-by: Dana Jansens <danakj@orodu.net>
This commit is contained in:
co-authored by
Dana Jansens
parent
918bb9364f
commit
08385adeb5
@@ -920,6 +920,8 @@ fn F() {
|
||||
// CHECK:STDOUT: %bar__carbon_thunk.call: init %empty_tuple.type = call imports.%bar__carbon_thunk.decl(%addr)
|
||||
// CHECK:STDOUT: %Destroy.Op.call: init %empty_tuple.type = call constants.%Destroy.Op.bound(constants.%.597)
|
||||
// CHECK:STDOUT: return
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !observes:
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: fn @bar(%a.param: %i16);
|
||||
@@ -931,6 +933,8 @@ fn F() {
|
||||
// CHECK:STDOUT: fn @Destroy.Op.loc7_13.2(%self.param: ref %i16) {
|
||||
// CHECK:STDOUT: !entry:
|
||||
// CHECK:STDOUT: return
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !observes:
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: --- import_overloaded_functions.carbon
|
||||
@@ -1027,6 +1031,8 @@ fn F() {
|
||||
// CHECK:STDOUT: %.loc7_13.2: %i32 = converted %int_1, %.loc7_13.1 [concrete = constants.%int_1.0c6]
|
||||
// CHECK:STDOUT: %foo.call: init %empty_tuple.type = call imports.%foo.decl(%.loc7_13.2)
|
||||
// CHECK:STDOUT: return
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !observes:
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: fn @foo(%a.param: %i32);
|
||||
@@ -1203,6 +1209,8 @@ fn F() {
|
||||
// CHECK:STDOUT: %foo__carbon_thunk.call: init %empty_tuple.type = call imports.%foo__carbon_thunk.decl(%addr)
|
||||
// CHECK:STDOUT: %Destroy.Op.call: init %empty_tuple.type = call constants.%Destroy.Op.bound(constants.%.597)
|
||||
// CHECK:STDOUT: return
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !observes:
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: fn @foo.1(%a.param: %i32);
|
||||
@@ -1216,6 +1224,8 @@ fn F() {
|
||||
// CHECK:STDOUT: fn @Destroy.Op.loc8_13.2(%self.param: ref %i16) {
|
||||
// CHECK:STDOUT: !entry:
|
||||
// CHECK:STDOUT: return
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !observes:
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: --- import_multiple_overloaded_sets.carbon
|
||||
@@ -1342,6 +1352,8 @@ fn F() {
|
||||
// CHECK:STDOUT: %.loc8_13.2: %i32 = converted %int_1.loc8, %.loc8_13.1 [concrete = constants.%int_1.0c6]
|
||||
// CHECK:STDOUT: %bar.call: init %empty_tuple.type = call imports.%bar.decl(%.loc8_13.2)
|
||||
// CHECK:STDOUT: return
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !observes:
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: fn @foo(%a.param: %i32);
|
||||
@@ -1807,6 +1819,8 @@ fn F() {
|
||||
// CHECK:STDOUT: %Destroy.Op.call.loc22_51: init %empty_tuple.type = call %Destroy.Op.bound.loc22(%.loc22_51.3)
|
||||
// CHECK:STDOUT: %Destroy.Op.call.loc22_32: init %empty_tuple.type = call constants.%Destroy.Op.bound.eaa(constants.%.e05)
|
||||
// CHECK:STDOUT: return
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !observes:
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: fn @foo.1(%a.param: %i32) -> out %return.param: %i32;
|
||||
@@ -1822,6 +1836,8 @@ fn F() {
|
||||
// CHECK:STDOUT: fn @Destroy.Op.loc31_71.2(%self.param: ref %i128) {
|
||||
// CHECK:STDOUT: !entry:
|
||||
// CHECK:STDOUT: return
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !observes:
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: --- fail_import_large_int_literal.carbon
|
||||
@@ -1878,6 +1894,8 @@ fn F() {
|
||||
// CHECK:STDOUT: %h.patt: %pattern_type.97f = value_binding_pattern h [concrete = constants.%h.patt]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: return
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !observes:
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: --- import_negative_int_literal.carbon
|
||||
@@ -1992,6 +2010,8 @@ fn F() {
|
||||
// CHECK:STDOUT: %.loc8_11.4: %i32 = converted %Core.IntLiteral.as.Negate.impl.Op.call, %.loc8_11.3 [concrete = constants.%int_-1.4ef]
|
||||
// CHECK:STDOUT: %foo.call: init %empty_tuple.type = call imports.%foo.decl(%.loc8_11.4)
|
||||
// CHECK:STDOUT: return
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !observes:
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: fn @foo(%a.param: %i32);
|
||||
@@ -2108,6 +2128,8 @@ fn F() {
|
||||
// CHECK:STDOUT: %.loc15_11.4: %u32 = converted %Core.IntLiteral.as.Negate.impl.Op.call, %.loc15_11.3 [concrete = constants.%int_-1.002]
|
||||
// CHECK:STDOUT: %foo.call: init %empty_tuple.type = call imports.%foo.decl(%.loc15_11.4)
|
||||
// CHECK:STDOUT: return
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !observes:
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: fn @foo(%a.param: %u32);
|
||||
@@ -2266,6 +2288,8 @@ fn F() {
|
||||
// CHECK:STDOUT: %Destroy.Op.call.loc7_34: init %empty_tuple.type = call %Destroy.Op.bound(%.loc7_34.3)
|
||||
// CHECK:STDOUT: %Destroy.Op.call.loc7_31: init %empty_tuple.type = call constants.%Destroy.Op.bound(constants.%.011)
|
||||
// CHECK:STDOUT: return
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !observes:
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: fn @foo(%a.param: %f64.dc1) -> out %return.param: %f64.dc1;
|
||||
@@ -2277,6 +2301,8 @@ fn F() {
|
||||
// CHECK:STDOUT: fn @Destroy.Op.loc7_34.2(%self.param: ref %f64.dc1) {
|
||||
// CHECK:STDOUT: !entry:
|
||||
// CHECK:STDOUT: return
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !observes:
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: --- fail_import_large_floating_point_literal.carbon
|
||||
@@ -2418,6 +2444,8 @@ fn F() {
|
||||
// CHECK:STDOUT: %Destroy.Op.bound: <bound method> = bound_method %.loc15_19.3, constants.%Destroy.Op.1a2547.2
|
||||
// CHECK:STDOUT: %Destroy.Op.call: init %empty_tuple.type = call %Destroy.Op.bound(%.loc15_19.3)
|
||||
// CHECK:STDOUT: return
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !observes:
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: fn @foo(%a.param: %f64.dc1) -> out %return.param: %f64.dc1;
|
||||
@@ -2429,6 +2457,8 @@ fn F() {
|
||||
// CHECK:STDOUT: fn @Destroy.Op.loc15_19.2(%self.param: ref %f64.dc1) {
|
||||
// CHECK:STDOUT: !entry:
|
||||
// CHECK:STDOUT: return
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !observes:
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: --- struct_init.carbon
|
||||
@@ -2592,6 +2622,8 @@ fn F() {
|
||||
// CHECK:STDOUT: %Destroy.Op.bound: <bound method> = bound_method %.loc15_30.2, constants.%Destroy.Op
|
||||
// CHECK:STDOUT: %Destroy.Op.call: init %empty_tuple.type = call %Destroy.Op.bound(%.loc15_30.2)
|
||||
// CHECK:STDOUT: return
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !observes:
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: fn @PassNoFields(%s.param: %NoFields);
|
||||
@@ -2781,6 +2813,8 @@ fn F() {
|
||||
// CHECK:STDOUT: %addr.loc72: %ptr.6c3 = addr_of <error> [concrete = <error>]
|
||||
// CHECK:STDOUT: %PassThreeFields__carbon_thunk.call.loc72: init %empty_tuple.type = call imports.%PassThreeFields__carbon_thunk.decl(%addr.loc72)
|
||||
// CHECK:STDOUT: return
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !observes:
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: fn @PassThreeFields(%t.param: %ThreeFields.1b4);
|
||||
@@ -2845,6 +2879,8 @@ fn F() {
|
||||
// CHECK:STDOUT: %int_3.loc25: Core.IntLiteral = int_value 3 [concrete = constants.%int_3]
|
||||
// CHECK:STDOUT: %.loc25: %struct_type.a.x.c = struct_literal (%int_1.loc25, %int_2.loc25, %int_3.loc25) [concrete = constants.%struct.11a]
|
||||
// CHECK:STDOUT: return
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !observes:
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: --- fail_struct_init_unsupported_field_name.carbon
|
||||
@@ -2891,6 +2927,8 @@ fn F() {
|
||||
// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1]
|
||||
// CHECK:STDOUT: %.loc11: %struct_type.base = struct_literal (%int_1) [concrete = constants.%struct]
|
||||
// CHECK:STDOUT: return
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !observes:
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: --- fail_struct_init_from_tuple.carbon
|
||||
@@ -3135,6 +3173,8 @@ fn F() {
|
||||
// CHECK:STDOUT: %addr.loc62: %ptr.027 = addr_of <error> [concrete = <error>]
|
||||
// CHECK:STDOUT: %PassNoFields__carbon_thunk.call.loc62: init %empty_tuple.type = call imports.%PassNoFields__carbon_thunk.decl(%addr.loc62)
|
||||
// CHECK:STDOUT: return
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !observes:
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: fn @PassNoFields(%s.param: %NoFields);
|
||||
@@ -3175,6 +3215,8 @@ fn F() {
|
||||
// CHECK:STDOUT: %addr.loc118: %ptr.6c3 = addr_of <error> [concrete = <error>]
|
||||
// CHECK:STDOUT: %PassThreeFields__carbon_thunk.call.loc118: init %empty_tuple.type = call imports.%PassThreeFields__carbon_thunk.decl(%addr.loc118)
|
||||
// CHECK:STDOUT: return
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !observes:
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: fn @PassThreeFields(%t.param: %ThreeFields.1b4);
|
||||
@@ -3259,6 +3301,8 @@ fn F() {
|
||||
// CHECK:STDOUT: %.loc33_16.2: %i32 = converted %.loc33_16.1, <error> [concrete = <error>]
|
||||
// CHECK:STDOUT: %PassInt.call.loc33: init %empty_tuple.type = call imports.%PassInt.decl(<error>)
|
||||
// CHECK:STDOUT: return
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !observes:
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: fn @PassInt(%n.param: %i32);
|
||||
@@ -3341,6 +3385,8 @@ fn F() {
|
||||
// CHECK:STDOUT: %.loc34_23.2: %i32 = converted %.loc34_23.1, <error> [concrete = <error>]
|
||||
// CHECK:STDOUT: %PassOverloaded.call.loc34: init %empty_tuple.type = call imports.%PassOverloaded.decl(<error>)
|
||||
// CHECK:STDOUT: return
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !observes:
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: fn @PassOverloaded(%n.param: %i32);
|
||||
@@ -3396,6 +3442,8 @@ fn F() {
|
||||
// CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [concrete = constants.%int_3]
|
||||
// CHECK:STDOUT: %.loc15_43: %struct_type.a.n = struct_literal (%.loc15_34, %int_3) [concrete = constants.%struct.7ea]
|
||||
// CHECK:STDOUT: return
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !observes:
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: --- fail_todo_pass_nested_structs.carbon
|
||||
@@ -3516,6 +3564,8 @@ fn F() {
|
||||
// CHECK:STDOUT: %addr: %ptr.dc0 = addr_of <error> [concrete = <error>]
|
||||
// CHECK:STDOUT: %TakeB__carbon_thunk.call: init %empty_tuple.type = call imports.%TakeB__carbon_thunk.decl(%addr)
|
||||
// CHECK:STDOUT: return
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !observes:
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: fn @TakeB(%_.param: %B);
|
||||
@@ -3623,6 +3673,8 @@ fn F() {
|
||||
// CHECK:STDOUT: %.loc18_13.3: %i32 = converted %.loc18_13.2, <error> [concrete = <error>]
|
||||
// CHECK:STDOUT: %foo.call: init %empty_tuple.type = call imports.%foo.decl(<error>)
|
||||
// CHECK:STDOUT: return
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !observes:
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: fn @foo(%a.param: %i32);
|
||||
@@ -3730,6 +3782,8 @@ fn F() {
|
||||
// CHECK:STDOUT: %addr: %ptr = addr_of <error> [concrete = <error>]
|
||||
// CHECK:STDOUT: %foo__carbon_thunk.call: init %empty_tuple.type = call imports.%foo__carbon_thunk.decl(%addr)
|
||||
// CHECK:STDOUT: return
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !observes:
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: fn @foo(%a.param: %i16);
|
||||
@@ -3811,6 +3865,8 @@ fn F() {
|
||||
// CHECK:STDOUT: %.loc15_13.1: %i64 = value_of_initializer %Core.IntLiteral.as.As.impl.Convert.call [concrete = constants.%int_1.d98]
|
||||
// CHECK:STDOUT: %.loc15_13.2: %i64 = converted %int_1, %.loc15_13.1 [concrete = constants.%int_1.d98]
|
||||
// CHECK:STDOUT: return
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !observes:
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: --- fail_import_ambiguous_overload.carbon
|
||||
@@ -3888,6 +3944,8 @@ fn F() {
|
||||
// CHECK:STDOUT: %.loc19_13.1: %i64 = value_of_initializer %Core.IntLiteral.as.As.impl.Convert.call [concrete = constants.%int_1.d98]
|
||||
// CHECK:STDOUT: %.loc19_13.2: %i64 = converted %int_1, %.loc19_13.1 [concrete = constants.%int_1.d98]
|
||||
// CHECK:STDOUT: return
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !observes:
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: --- fail_import_deleted_function.carbon
|
||||
@@ -3965,6 +4023,8 @@ fn F() {
|
||||
// CHECK:STDOUT: %.loc19_13.1: %i32 = value_of_initializer %Core.IntLiteral.as.As.impl.Convert.call [concrete = constants.%int_1.0c6]
|
||||
// CHECK:STDOUT: %.loc19_13.2: %i32 = converted %int_1, %.loc19_13.1 [concrete = constants.%int_1.0c6]
|
||||
// CHECK:STDOUT: return
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !observes:
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: --- fail_missing_impl.carbon
|
||||
@@ -4043,6 +4103,8 @@ fn F() {
|
||||
// CHECK:STDOUT: witness = ()
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !requires:
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !observes:
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: generic fn @EchoValue(%ValueT.loc10_20.2: %I.type, %value.loc10_38.2: @EchoValue.%ValueT.as_type.loc10_41.1 (%ValueT.as_type)) {
|
||||
@@ -4058,6 +4120,8 @@ fn F() {
|
||||
// CHECK:STDOUT: fn() {
|
||||
// CHECK:STDOUT: !entry:
|
||||
// CHECK:STDOUT: return
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !observes:
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
@@ -4067,6 +4131,8 @@ fn F() {
|
||||
// CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
||||
// CHECK:STDOUT: %foo.ref: %foo.cpp_overload_set.type = name_ref foo, imports.%foo.cpp_overload_set.value [concrete = constants.%foo.cpp_overload_set.value]
|
||||
// CHECK:STDOUT: return
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !observes:
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: specific @I.WithSelf(constants.%Self) {
|
||||
|
||||
Reference in New Issue
Block a user