|
| 1 | +// Verifies that type metadata identifiers for functions are emitted correctly |
| 2 | +// for paths. |
| 3 | +// |
| 4 | +//@ needs-sanitizer-cfi |
| 5 | +//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static |
| 6 | + |
| 7 | +#![crate_type="lib"] |
| 8 | +#![feature(inline_const, type_alias_impl_trait)] |
| 9 | + |
| 10 | +extern crate core; |
| 11 | + |
| 12 | +pub type Type1 = impl Send; |
| 13 | +pub type Type2 = impl Send; |
| 14 | +pub type Type3 = impl Send; |
| 15 | +pub type Type4 = impl Send; |
| 16 | + |
| 17 | +pub fn foo() where |
| 18 | + Type1: 'static, |
| 19 | + Type2: 'static, |
| 20 | + Type3: 'static, |
| 21 | + Type4: 'static, |
| 22 | +{ |
| 23 | + // Type in extern path |
| 24 | + extern { |
| 25 | + fn bar(); |
| 26 | + } |
| 27 | + let _: Type1 = bar; |
| 28 | + |
| 29 | + // Type in closure path |
| 30 | + || { |
| 31 | + pub struct Foo; |
| 32 | + let _: Type2 = Foo; |
| 33 | + }; |
| 34 | + |
| 35 | + // Type in const path |
| 36 | + const { |
| 37 | + pub struct Foo; |
| 38 | + fn bar() -> Type3 { Foo } |
| 39 | + }; |
| 40 | + |
| 41 | + |
| 42 | + // Type in impl path |
| 43 | + struct Foo; |
| 44 | + impl Foo { |
| 45 | + fn bar(&self) { } |
| 46 | + } |
| 47 | + let _: Type4 = <Foo>::bar; |
| 48 | +} |
| 49 | + |
| 50 | +pub fn foo1(_: Type1) { } |
| 51 | +// CHECK: define{{.*}}4foo1{{.*}}!type ![[TYPE1:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} |
| 52 | +pub fn foo2(_: Type1, _: Type1) { } |
| 53 | +// CHECK: define{{.*}}4foo2{{.*}}!type ![[TYPE2:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} |
| 54 | +pub fn foo3(_: Type1, _: Type1, _: Type1) { } |
| 55 | +// CHECK: define{{.*}}4foo3{{.*}}!type ![[TYPE3:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} |
| 56 | +pub fn foo4(_: Type2) { } |
| 57 | +// CHECK: define{{.*}}4foo4{{.*}}!type ![[TYPE4:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} |
| 58 | +pub fn foo5(_: Type2, _: Type2) { } |
| 59 | +// CHECK: define{{.*}}4foo5{{.*}}!type ![[TYPE5:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} |
| 60 | +pub fn foo6(_: Type2, _: Type2, _: Type2) { } |
| 61 | +// CHECK: define{{.*}}4foo6{{.*}}!type ![[TYPE6:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} |
| 62 | +pub fn foo7(_: Type3) { } |
| 63 | +// CHECK: define{{.*}}4foo7{{.*}}!type ![[TYPE7:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} |
| 64 | +pub fn foo8(_: Type3, _: Type3) { } |
| 65 | +// CHECK: define{{.*}}4foo8{{.*}}!type ![[TYPE8:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} |
| 66 | +pub fn foo9(_: Type3, _: Type3, _: Type3) { } |
| 67 | +// CHECK: define{{.*}}4foo9{{.*}}!type ![[TYPE9:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} |
| 68 | +pub fn foo10(_: Type4) { } |
| 69 | +// CHECK: define{{.*}}5foo10{{.*}}!type ![[TYPE10:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} |
| 70 | +pub fn foo11(_: Type4, _: Type4) { } |
| 71 | +// CHECK: define{{.*}}5foo11{{.*}}!type ![[TYPE11:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} |
| 72 | +pub fn foo12(_: Type4, _: Type4, _: Type4) { } |
| 73 | +// CHECK: define{{.*}}5foo12{{.*}}!type ![[TYPE12:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} |
| 74 | + |
| 75 | +// CHECK: ![[TYPE1]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNFNvC{{[[:print:]]+}}_{{[[:print:]]+}}3foo10{{[{}][{}]}}extern{{[}][}]}}3barE"} |
| 76 | +// CHECK: ![[TYPE2]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNFNvC{{[[:print:]]+}}_{{[[:print:]]+}}3foo10{{[{}][{}]}}extern{{[}][}]}}3barS_E"} |
| 77 | +// CHECK: ![[TYPE3]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNFNvC{{[[:print:]]+}}_{{[[:print:]]+}}3foo10{{[{}][{}]}}extern{{[}][}]}}3barS_S_E"} |
| 78 | +// CHECK: ![[TYPE4]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtNCNvC{{[[:print:]]+}}_{{[[:print:]]+}}3foo11{{[{}][{}]}}closure{{[}][}]}}3FooE"} |
| 79 | +// CHECK: ![[TYPE5]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtNCNvC{{[[:print:]]+}}_{{[[:print:]]+}}3foo11{{[{}][{}]}}closure{{[}][}]}}3FooS_E"} |
| 80 | +// CHECK: ![[TYPE6]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtNCNvC{{[[:print:]]+}}_{{[[:print:]]+}}3foo11{{[{}][{}]}}closure{{[}][}]}}3FooS_S_E"} |
| 81 | +// CHECK: ![[TYPE7]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtNkNvC{{[[:print:]]+}}_{{[[:print:]]+}}3foo12{{[{}][{}]}}constant{{[}][}]}}3FooE"} |
| 82 | +// CHECK: ![[TYPE8]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtNkNvC{{[[:print:]]+}}_{{[[:print:]]+}}3foo12{{[{}][{}]}}constant{{[}][}]}}3FooS_E"} |
| 83 | +// CHECK: ![[TYPE9]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtNkNvC{{[[:print:]]+}}_{{[[:print:]]+}}3foo12{{[{}][{}]}}constant{{[}][}]}}3FooS_S_E"} |
| 84 | +// CHECK: ![[TYPE10]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNINvC{{[[:print:]]+}}_{{[[:print:]]+}}3foo8{{[{}][{}]}}impl{{[}][}]}}3barE"} |
| 85 | +// CHECK: ![[TYPE11]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNINvC{{[[:print:]]+}}_{{[[:print:]]+}}3foo8{{[{}][{}]}}impl{{[}][}]}}3barS_E"} |
| 86 | +// CHECK: ![[TYPE12]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNINvC{{[[:print:]]+}}_{{[[:print:]]+}}3foo8{{[{}][{}]}}impl{{[}][}]}}3barS_S_E"} |
0 commit comments