[Reland][Runtimes] Merge 'compile_commands.json' files from runtimes build (#116303)
[llvm-project.git] / clang / test / CodeGenCXX / trap-fnattr.cpp
blob21422bc94f6fbef6c9ab3152089842edb0b857e9
1 // RUN: %clang_cc1 -O0 -emit-llvm -ftrapv -ftrap-function=mytrap %s -o - | FileCheck %s -check-prefix=TRAPFUNC
2 // RUN: %clang_cc1 -O0 -emit-llvm -ftrapv %s -o - | FileCheck %s -check-prefix=NOOPTION
4 // TRAPFUNC-LABEL: define {{(dso_local )?}}void @{{_Z12test_builtinv|\"\?test_builtin@@YAXXZ\"}}
5 // TRAPFUNC: call void @llvm.trap() [[ATTR0:#[0-9]+]]
7 // NOOPTION-LABEL: define {{(dso_local )?}}void @{{_Z12test_builtinv|\"\?test_builtin@@YAXXZ\"}}
8 // NOOPTION: call void @llvm.trap(){{$}}
10 void test_builtin(void) {
11 __builtin_trap();
14 // TRAPFUNC-LABEL: define {{.*}}i32 @{{_Z13test_noreturnv|\"\?test_noreturn@@YAHXZ\"}}
15 // TRAPFUNC: call void @llvm.trap() [[ATTR0]]
17 // NOOPTION-LABEL: define {{.*}}i32 @{{_Z13test_noreturnv|\"\?test_noreturn@@YAHXZ\"}}
18 // NOOPTION: call void @llvm.trap(){{$}}
20 int test_noreturn(void) {
23 // TRAPFUNC-LABEL: define {{.*}}i32 @{{_Z17test_add_overflowii|\"\?test_add_overflow@@YAHHH@Z\"}}
24 // TRAPFUNC: call void @llvm.ubsantrap({{.*}}) [[ATTR1:#[0-9]+]]
26 // NOOPTION-LABEL: define {{.*}}i32 @{{_Z17test_add_overflowii|\"\?test_add_overflow@@YAHHH@Z\"}}
27 // NOOPTION: call void @llvm.ubsantrap({{.*}}) [[ATTR2:#[0-9]+]]
29 int test_add_overflow(int a, int b) {
30 return a + b;
33 // TRAPFUNC: attributes [[ATTR0]] = { {{.*}}"trap-func-name"="mytrap" }
34 // TRAPFUNC: attributes [[ATTR1]] = { {{.*}}"trap-func-name"="mytrap" }
36 // NOOPTION-NOT: attributes [[ATTR2]] = { {{.*}}"trap-func-name"="mytrap" }