blob: 00c9f59700ac2351ccbae09f2081a8cc698f12d8 [file] [log] [blame]
Peter Collingbourne2c7f7e32015-09-10 02:17:40 +00001// RUN: %clang_cc1 -triple x86_64-unknown-linux -fsanitize=cfi-icall -fsanitize-trap=cfi-icall -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=ITANIUM %s
2// RUN: %clang_cc1 -triple x86_64-pc-windows-msvc -fsanitize=cfi-icall -fsanitize-trap=cfi-icall -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=MS %s
3
4// Tests that we assign unnamed metadata nodes to functions whose types have
5// internal linkage.
6
7namespace {
8
9struct S {};
10
Vlad Tsyrklevich634c6012017-10-31 22:39:44 +000011void f(S s) {
Peter Collingbourne2c7f7e32015-09-10 02:17:40 +000012}
13
14}
15
16void g() {
Vlad Tsyrklevich634c6012017-10-31 22:39:44 +000017 struct S s;
18 void (*fp)(S) = f;
19 // CHECK: call i1 @llvm.type.test(i8* {{.*}}, metadata [[VOIDS1:![0-9]+]])
20 fp(s);
Peter Collingbourne2c7f7e32015-09-10 02:17:40 +000021}
22
Vlad Tsyrklevich634c6012017-10-31 22:39:44 +000023// ITANIUM: define internal void @_ZN12_GLOBAL__N_11fENS_1SE({{.*}} !type [[TS1:![0-9]+]] !type [[TS2:![0-9]+]]
Reid Klecknerdf8dd612018-08-17 20:59:27 +000024// MS: define internal void @"?f@?A0x{{[^@]*}}@@YAXUS@?A0x{{[^@]*}}@@@Z"({{.*}} !type [[TS1:![0-9]+]] !type [[TS2:![0-9]+]]
Peter Collingbourne8dd14da2016-06-24 21:21:46 +000025
Vlad Tsyrklevich634c6012017-10-31 22:39:44 +000026// CHECK: [[VOIDS1]] = distinct !{}
27// CHECK: [[TS1]] = !{i64 0, [[VOIDS1]]}
28// CHECK: [[TS2]] = !{i64 0, [[VOIDS2:![0-9]+]]}
29// CHECK: [[VOIDS2]] = distinct !{}