Peter Collingbourne | 8dd14da | 2016-06-24 21:21:46 +0000 | [diff] [blame] | 1 | // 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 |
Peter Collingbourne | 2c7f7e3 | 2015-09-10 02:17:40 +0000 | [diff] [blame] | 3 | |
| 4 | // Tests that we assign appropriate identifiers to unprototyped functions. |
| 5 | |
Peter Collingbourne | 8dd14da | 2016-06-24 21:21:46 +0000 | [diff] [blame] | 6 | // CHECK: define void @f({{.*}} !type [[TVOID:![0-9]+]] |
Peter Collingbourne | 2c7f7e3 | 2015-09-10 02:17:40 +0000 | [diff] [blame] | 7 | void f() { |
| 8 | } |
| 9 | |
| 10 | void xf(); |
| 11 | |
Peter Collingbourne | 8dd14da | 2016-06-24 21:21:46 +0000 | [diff] [blame] | 12 | // CHECK: define void @g({{.*}} !type [[TINT:![0-9]+]] |
Peter Collingbourne | 2c7f7e3 | 2015-09-10 02:17:40 +0000 | [diff] [blame] | 13 | void g(int b) { |
| 14 | void (*fp)() = b ? f : xf; |
Peter Collingbourne | 8dd14da | 2016-06-24 21:21:46 +0000 | [diff] [blame] | 15 | // ITANIUM: call i1 @llvm.type.test(i8* {{.*}}, metadata !"_ZTSFvE") |
Peter Collingbourne | 2c7f7e3 | 2015-09-10 02:17:40 +0000 | [diff] [blame] | 16 | fp(); |
| 17 | } |
| 18 | |
Peter Collingbourne | 8dd14da | 2016-06-24 21:21:46 +0000 | [diff] [blame] | 19 | // CHECK: declare !type [[TVOID:![0-9]+]] void @xf({{.*}} |
| 20 | |
| 21 | // ITANIUM-DAG: [[TVOID]] = !{i64 0, !"_ZTSFvE"} |
| 22 | // ITANIUM-DAG: [[TINT]] = !{i64 0, !"_ZTSFviE"} |
| 23 | // MS-DAG: [[TVOID]] = !{i64 0, !"?6AX@Z"} |
| 24 | // MS-DAG: [[TINT]] = !{i64 0, !"?6AXH@Z"} |