2013-01-08 06:25:52 +08:00
|
|
|
// Verify proper type emitted for compound assignments
|
Reimplement -fsanitize-recover family of flags.
Introduce the following -fsanitize-recover flags:
- -fsanitize-recover=<list>: Enable recovery for selected checks or
group of checks. It is forbidden to explicitly list unrecoverable
sanitizers here (that is, "address", "unreachable", "return").
- -fno-sanitize-recover=<list>: Disable recovery for selected checks or
group of checks.
- -f(no-)?sanitize-recover is now a synonym for
-f(no-)?sanitize-recover=undefined,integer and will soon be deprecated.
These flags are parsed left to right, and mask of "recoverable"
sanitizer is updated accordingly, much like what we do for -fsanitize= flags.
-fsanitize= and -fsanitize-recover= flag families are independent.
CodeGen change: If there is a single UBSan handler function, responsible
for implementing multiple checks, which have different recoverable setting,
then we emit two handler calls instead of one:
the first one for the set of "unrecoverable" checks, another one - for
set of "recoverable" checks. If all checks implemented by a handler have the
same recoverability setting, then the generated code will be the same.
llvm-svn: 225719
2015-01-13 06:39:12 +08:00
|
|
|
// RUN: %clang_cc1 -ffreestanding -triple x86_64-apple-darwin10 -emit-llvm -o - %s -fsanitize=signed-integer-overflow,unsigned-integer-overflow -fsanitize-recover=signed-integer-overflow,unsigned-integer-overflow | FileCheck %s
|
2013-01-08 06:25:52 +08:00
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
// CHECK: @[[INT:.*]] = private unnamed_addr constant { i16, i16, [6 x i8] } { i16 0, i16 11, [6 x i8] c"'int'\00" }
|
2013-01-09 11:39:41 +08:00
|
|
|
// CHECK: @[[LINE_100:.*]] = private unnamed_addr global {{.*}}, i32 100, i32 5 {{.*}} @[[INT]]
|
2013-01-08 06:25:52 +08:00
|
|
|
// CHECK: @[[UINT:.*]] = private unnamed_addr constant { i16, i16, [15 x i8] } { i16 0, i16 10, [15 x i8] c"'unsigned int'\00" }
|
2013-01-09 11:39:41 +08:00
|
|
|
// CHECK: @[[LINE_200:.*]] = private unnamed_addr global {{.*}}, i32 200, i32 5 {{.*}} @[[UINT]]
|
2013-11-08 09:09:22 +08:00
|
|
|
// CHECK: @[[LINE_300:.*]] = private unnamed_addr global {{.*}}, i32 300, i32 5 {{.*}} @[[INT]]
|
2013-01-08 06:25:52 +08:00
|
|
|
|
|
|
|
int32_t x;
|
|
|
|
|
|
|
|
// CHECK: @compaddsigned
|
|
|
|
void compaddsigned() {
|
|
|
|
#line 100
|
|
|
|
x += ((int32_t)1);
|
|
|
|
// CHECK: @__ubsan_handle_add_overflow(i8* bitcast ({{.*}} @[[LINE_100]] to i8*), {{.*}})
|
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK: @compaddunsigned
|
|
|
|
void compaddunsigned() {
|
|
|
|
#line 200
|
|
|
|
x += ((uint32_t)1U);
|
|
|
|
// CHECK: @__ubsan_handle_add_overflow(i8* bitcast ({{.*}} @[[LINE_200]] to i8*), {{.*}})
|
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK: @compdiv
|
|
|
|
void compdiv() {
|
|
|
|
#line 300
|
2017-02-25 08:43:36 +08:00
|
|
|
x /= x;
|
2013-01-08 06:25:52 +08:00
|
|
|
// CHECK: @__ubsan_handle_divrem_overflow(i8* bitcast ({{.*}} @[[LINE_300]] to i8*), {{.*}})
|
|
|
|
}
|