forked from OSchip/llvm-project
[ubsan-minimal] Make the interface more compatible with RTUBSan
This eliminates a few inconsistencies between the symbol sets exported by RTUBSan and RTUBSan_minimal: * Handlers for nonnull_return were missing from the minimal RT, and are now added in. * The minimal runtime exported recoverable handlers for builtin_unreachable and missing_return. These are not supposed to exist, and are now removed. llvm-svn: 313614
This commit is contained in:
parent
6f8fbf4b86
commit
c539795bc3
|
@ -57,17 +57,22 @@ static void abort_with_message(const char *) { abort(); }
|
|||
|
||||
// FIXME: add caller pc to the error message (possibly as "ubsan: error-type
|
||||
// @1234ABCD").
|
||||
#define HANDLER(name, msg) \
|
||||
#define HANDLER_RECOVER(name, msg) \
|
||||
INTERFACE void __ubsan_handle_##name##_minimal() { \
|
||||
if (!report_this_error(__builtin_return_address(0))) return; \
|
||||
message("ubsan: " msg "\n"); \
|
||||
} \
|
||||
\
|
||||
}
|
||||
|
||||
#define HANDLER_NORECOVER(name, msg) \
|
||||
INTERFACE void __ubsan_handle_##name##_minimal_abort() { \
|
||||
message("ubsan: " msg "\n"); \
|
||||
abort_with_message("ubsan: " msg); \
|
||||
}
|
||||
|
||||
#define HANDLER(name, msg) \
|
||||
HANDLER_RECOVER(name, msg) \
|
||||
HANDLER_NORECOVER(name, msg)
|
||||
|
||||
HANDLER(type_mismatch, "type-mismatch")
|
||||
HANDLER(add_overflow, "add-overflow")
|
||||
HANDLER(sub_overflow, "sub-overflow")
|
||||
|
@ -76,14 +81,16 @@ HANDLER(negate_overflow, "negate-overflow")
|
|||
HANDLER(divrem_overflow, "divrem-overflow")
|
||||
HANDLER(shift_out_of_bounds, "shift-out-of-bounds")
|
||||
HANDLER(out_of_bounds, "out-of-bounds")
|
||||
HANDLER(builtin_unreachable, "builtin-unreachable")
|
||||
HANDLER(missing_return, "missing-return")
|
||||
HANDLER_RECOVER(builtin_unreachable, "builtin-unreachable")
|
||||
HANDLER_RECOVER(missing_return, "missing-return")
|
||||
HANDLER(vla_bound_not_positive, "vla-bound-not-positive")
|
||||
HANDLER(float_cast_overflow, "float-cast-overflow")
|
||||
HANDLER(load_invalid_value, "load-invalid-value")
|
||||
HANDLER(invalid_builtin, "invalid-builtin")
|
||||
HANDLER(function_type_mismatch, "function-type-mismatch")
|
||||
HANDLER(nonnull_arg, "nonnull-arg")
|
||||
HANDLER(nonnull_return, "nonnull-return")
|
||||
HANDLER(nullability_arg, "nullability-arg")
|
||||
HANDLER(nullability_return, "nullability-return")
|
||||
HANDLER(pointer_overflow, "pointer-overflow")
|
||||
HANDLER(cfi_check_fail, "cfi-check-fail")
|
||||
|
|
|
@ -1,6 +1,18 @@
|
|||
// RUN: %clangxx -fsanitize=signed-integer-overflow -fsanitize-recover=all %s -o %t && %run %t 2>&1 | FileCheck %s
|
||||
// RUN: %clangxx -w -fsanitize=signed-integer-overflow,nullability-return,returns-nonnull-attribute -fsanitize-recover=all %s -o %t && %run %t 2>&1 | FileCheck %s
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int *_Nonnull h() {
|
||||
// CHECK: nullability-return
|
||||
return NULL;
|
||||
}
|
||||
|
||||
__attribute__((returns_nonnull))
|
||||
int *i() {
|
||||
// CHECK: nonnull-return
|
||||
return NULL;
|
||||
}
|
||||
|
||||
__attribute__((noinline))
|
||||
int f(int x, int y) {
|
||||
|
@ -15,6 +27,8 @@ int g(int x, int y) {
|
|||
}
|
||||
|
||||
int main() {
|
||||
h();
|
||||
i();
|
||||
int x = 2;
|
||||
for (int i = 0; i < 10; ++i)
|
||||
x = f(x, x);
|
||||
|
|
Loading…
Reference in New Issue