xref: /llvm-project/clang/test/CodeGenCXX/ubsan-function-noexcept.cpp (revision 46f366494f3ca8cc98daa6fb4f29c7c446c176b6)
1 // RUN: %clang_cc1 -std=c++17 -fsanitize=function -emit-llvm -triple x86_64-linux-gnu %s -o - | FileCheck %s
2 
3 /// Check the following two functions have the same func_sanitize metadata, i.e.
4 /// they have the same type hash despite the exception specifier.
5 // CHECK: define{{.*}} void @_Z1fv() #[[#]] !func_sanitize ![[FUNCSAN:.*]] {
6 // CHECK: define{{.*}} void @_Z10f_noexceptv() #[[#]] !func_sanitize
7 // CHECK-SAME: ![[FUNCSAN]] {
f()8 void f() {}
f_noexcept()9 void f_noexcept() noexcept {}
10 
11 // CHECK: define{{.*}} void @_Z1gPDoFvvE
g(void (* p)()noexcept)12 void g(void (*p)() noexcept) {
13   // CHECK: icmp eq i32 %{{.*}}, -1056584962, !nosanitize
14   // CHECK: icmp eq i32 %{{.*}}, [[Hash:[-0-9]+]], !nosanitize
15   p();
16 }
17 
18 // CHECK: ![[FUNCSAN]] = !{i32 -1056584962, i32 [[Hash]]}
19