2016-06-25 05:21:46 +08:00
|
|
|
// 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
|
|
|
|
// 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
|
2015-09-10 10:17:40 +08:00
|
|
|
|
|
|
|
// Tests that we assign appropriate identifiers to unprototyped functions.
|
|
|
|
|
2018-02-24 03:30:48 +08:00
|
|
|
// CHECK: define {{(dso_local )?}}void @f({{.*}} !type [[TVOID:![0-9]+]] !type [[TVOID_GENERALIZED:![0-9]+]]
|
2015-09-10 10:17:40 +08:00
|
|
|
void f() {
|
|
|
|
}
|
|
|
|
|
|
|
|
void xf();
|
|
|
|
|
2018-02-24 03:30:48 +08:00
|
|
|
// CHECK: define {{(dso_local )?}}void @g({{.*}} !type [[TINT:![0-9]+]] !type [[TINT_GENERALIZED:![0-9]+]]
|
2015-09-10 10:17:40 +08:00
|
|
|
void g(int b) {
|
|
|
|
void (*fp)() = b ? f : xf;
|
2016-06-25 05:21:46 +08:00
|
|
|
// ITANIUM: call i1 @llvm.type.test(i8* {{.*}}, metadata !"_ZTSFvE")
|
2015-09-10 10:17:40 +08:00
|
|
|
fp();
|
|
|
|
}
|
|
|
|
|
2018-02-24 03:30:48 +08:00
|
|
|
// CHECK: declare !type [[TVOID]] !type [[TVOID_GENERALIZED]] {{(dso_local )?}}void @xf({{.*}}
|
2016-06-25 05:21:46 +08:00
|
|
|
|
|
|
|
// ITANIUM-DAG: [[TVOID]] = !{i64 0, !"_ZTSFvE"}
|
2017-11-01 06:39:44 +08:00
|
|
|
// ITANIUM-DAG: [[TVOID_GENERALIZED]] = !{i64 0, !"_ZTSFvE.generalized"}
|
2016-06-25 05:21:46 +08:00
|
|
|
// ITANIUM-DAG: [[TINT]] = !{i64 0, !"_ZTSFviE"}
|
2017-11-01 06:39:44 +08:00
|
|
|
// ITANIUM-DAG: [[TINT_GENERALIZED]] = !{i64 0, !"_ZTSFviE.generalized"}
|
2016-06-25 05:21:46 +08:00
|
|
|
// MS-DAG: [[TVOID]] = !{i64 0, !"?6AX@Z"}
|
2017-11-01 06:39:44 +08:00
|
|
|
// MS-DAG: [[TVOID_GENERALIZED]] = !{i64 0, !"?6AX@Z.generalized"}
|
2016-06-25 05:21:46 +08:00
|
|
|
// MS-DAG: [[TINT]] = !{i64 0, !"?6AXH@Z"}
|
2017-11-01 06:39:44 +08:00
|
|
|
// MS-DAG: [[TINT_GENERALIZED]] = !{i64 0, !"?6AXH@Z.generalized"}
|