[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / CodeGen / ubsan-function.cpp
blob3f69b44b9f5d117c1f070a651ac34d3d39c4799a
1 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - %s -fsanitize=function -fno-sanitize-recover=all | FileCheck %s
3 // CHECK: @[[PROXY:.*]] = private unnamed_addr constant ptr @_ZTIFvvE
4 // CHECK: define{{.*}} void @_Z3funv() #0 !func_sanitize ![[FUNCSAN:.*]] {
5 void fun() {}
7 // CHECK-LABEL: define{{.*}} void @_Z6callerPFvvE(ptr noundef %f)
8 // CHECK: getelementptr <{ i32, i32 }>, ptr {{.*}}, i32 0, i32 0, !nosanitize
9 // CHECK: load i32, ptr {{.*}}, align {{.*}}, !nosanitize
10 // CHECK: icmp eq i32 {{.*}}, 846595819, !nosanitize
11 // CHECK: br i1 {{.*}}, label %[[LABEL1:.*]], label %[[LABEL4:.*]], !nosanitize
12 // CHECK: [[LABEL1]]:
13 // CHECK: getelementptr <{ i32, i32 }>, ptr {{.*}}, i32 0, i32 1, !nosanitize
14 // CHECK: load i32, ptr {{.*}}, align {{.*}}, !nosanitize
15 // CHECK: icmp eq ptr {{.*}}, @_ZTIFvvE, !nosanitize
16 // CHECK: br i1 {{.*}}, label %[[LABEL3:.*]], label %[[LABEL2:[^,]*]], {{.*}}!nosanitize
17 // CHECK: [[LABEL2]]:
18 // CHECK: call void @__ubsan_handle_function_type_mismatch_v1_abort(ptr {{.*}}, i64 {{.*}}, i64 {{.*}}, i64 {{.*}}) #{{.*}}, !nosanitize
19 // CHECK-NOT: unreachable
20 // CHECK: br label %[[LABEL3]], !nosanitize
21 // CHECK: [[LABEL3]]:
22 // CHECK: br label %[[LABEL4]], !nosanitize
23 void caller(void (*f)()) { f(); }
25 // CHECK: ![[FUNCSAN]] = !{i32 846595819, ptr @[[PROXY]]}