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
|
|
|
|
|
2015-07-03 16:21:27 +08:00
|
|
|
// TRAPFUNC-LABEL: define void @{{_Z12test_builtinv|\"\\01\?test_builtin@@YAXXZ\"}}
|
2015-07-03 06:15:41 +08:00
|
|
|
// TRAPFUNC: call void @llvm.trap() [[ATTR0:#[0-9]+]]
|
|
|
|
|
2015-07-03 16:21:27 +08:00
|
|
|
// NOOPTION-LABEL: define void @{{_Z12test_builtinv|\"\\01\?test_builtin@@YAXXZ\"}}
|
2015-07-03 06:15:41 +08:00
|
|
|
// NOOPTION: call void @llvm.trap(){{$}}
|
|
|
|
|
|
|
|
void test_builtin(void) {
|
|
|
|
__builtin_trap();
|
|
|
|
}
|
|
|
|
|
2015-07-03 16:21:27 +08:00
|
|
|
// TRAPFUNC-LABEL: define {{.*}}i32 @{{_Z13test_noreturnv|\"\\01\?test_noreturn@@YAHXZ\"}}
|
2015-07-03 06:15:41 +08:00
|
|
|
// TRAPFUNC: call void @llvm.trap() [[ATTR0]]
|
|
|
|
|
2015-07-03 16:21:27 +08:00
|
|
|
// NOOPTION-LABEL: define {{.*}}i32 @{{_Z13test_noreturnv|\"\\01\?test_noreturn@@YAHXZ\"}}
|
2015-07-03 06:15:41 +08:00
|
|
|
// NOOPTION: call void @llvm.trap(){{$}}
|
|
|
|
|
|
|
|
int test_noreturn(void) {
|
|
|
|
}
|
|
|
|
|
2015-07-03 16:21:27 +08:00
|
|
|
// TRAPFUNC-LABEL: define {{.*}}i32 @{{_Z17test_add_overflowii|\"\\01\?test_add_overflow@@YAHHH@Z\"}}
|
2015-07-03 06:15:41 +08:00
|
|
|
// TRAPFUNC: call void @llvm.trap() [[ATTR1:#[0-9]+]]
|
|
|
|
|
2015-07-03 16:21:27 +08:00
|
|
|
// NOOPTION-LABEL: define {{.*}}i32 @{{_Z17test_add_overflowii|\"\\01\?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" }
|