2015-07-03 06:15:41 +08:00
|
|
|
// RUN: %clang_cc1 -O0 -emit-llvm -ftrapv -ftrap-function=mytrap %s -o - | FileCheck %s -check-prefix=TRAPFUNC
|
|
|
|
// RUN: %clang_cc1 -O0 -emit-llvm -ftrapv %s -o - | FileCheck %s -check-prefix=NOOPTION
|
|
|
|
|
2018-03-17 04:53:13 +08:00
|
|
|
// TRAPFUNC-LABEL: define {{(dso_local )?}}void @{{_Z12test_builtinv|\"\?test_builtin@@YAXXZ\"}}
|
2015-07-03 06:15:41 +08:00
|
|
|
// TRAPFUNC: call void @llvm.trap() [[ATTR0:#[0-9]+]]
|
|
|
|
|
2018-03-17 04:53:13 +08:00
|
|
|
// NOOPTION-LABEL: define {{(dso_local )?}}void @{{_Z12test_builtinv|\"\?test_builtin@@YAXXZ\"}}
|
2015-07-03 06:15:41 +08:00
|
|
|
// NOOPTION: call void @llvm.trap(){{$}}
|
|
|
|
|
|
|
|
void test_builtin(void) {
|
|
|
|
__builtin_trap();
|
|
|
|
}
|
|
|
|
|
2018-03-17 04:53:13 +08:00
|
|
|
// TRAPFUNC-LABEL: define {{.*}}i32 @{{_Z13test_noreturnv|\"\?test_noreturn@@YAHXZ\"}}
|
2015-07-03 06:15:41 +08:00
|
|
|
// TRAPFUNC: call void @llvm.trap() [[ATTR0]]
|
|
|
|
|
2018-03-17 04:53:13 +08:00
|
|
|
// NOOPTION-LABEL: define {{.*}}i32 @{{_Z13test_noreturnv|\"\?test_noreturn@@YAHXZ\"}}
|
2015-07-03 06:15:41 +08:00
|
|
|
// NOOPTION: call void @llvm.trap(){{$}}
|
|
|
|
|
|
|
|
int test_noreturn(void) {
|
|
|
|
}
|
|
|
|
|
2018-03-17 04:53:13 +08:00
|
|
|
// TRAPFUNC-LABEL: define {{.*}}i32 @{{_Z17test_add_overflowii|\"\?test_add_overflow@@YAHHH@Z\"}}
|
2015-07-03 06:15:41 +08:00
|
|
|
// TRAPFUNC: call void @llvm.trap() [[ATTR1:#[0-9]+]]
|
|
|
|
|
2018-03-17 04:53:13 +08:00
|
|
|
// NOOPTION-LABEL: define {{.*}}i32 @{{_Z17test_add_overflowii|\"\?test_add_overflow@@YAHHH@Z\"}}
|
2015-07-03 06:15:41 +08:00
|
|
|
// NOOPTION: call void @llvm.trap() [[ATTR2:#[0-9]+]]
|
|
|
|
|
|
|
|
int test_add_overflow(int a, int b) {
|
|
|
|
return a + b;
|
|
|
|
}
|
|
|
|
|
|
|
|
// TRAPFUNC: attributes [[ATTR0]] = { {{.*}}"trap-func-name"="mytrap" }
|
|
|
|
// TRAPFUNC: attributes [[ATTR1]] = { {{.*}}"trap-func-name"="mytrap" }
|
|
|
|
|
|
|
|
// NOOPTION-NOT: attributes [[ATTR2]] = { {{.*}}"trap-func-name"="mytrap" }
|