Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ static void format_msg(const char *kind, uintptr_t caller, char *buf,
*buf = '\0';
}

static void report_error(const char *kind, uintptr_t caller) {
SANITIZER_INTERFACE_WEAK_DEF(void, __ubsan_report_error, const char *kind,
uintptr_t caller) {
if (caller == 0)
return;
while (true) {
Expand Down Expand Up @@ -114,13 +115,13 @@ void NORETURN CheckFailed(const char *file, int, const char *cond, u64, u64) {

#define HANDLER_RECOVER(name, kind) \
INTERFACE void __ubsan_handle_##name##_minimal() { \
report_error(kind, GET_CALLER_PC()); \
__ubsan_report_error(kind, GET_CALLER_PC()); \
}

#define HANDLER_NORECOVER(name, kind) \
INTERFACE void __ubsan_handle_##name##_minimal_abort() { \
uintptr_t caller = GET_CALLER_PC(); \
report_error(kind, caller); \
__ubsan_report_error(kind, caller); \
abort_with_message(kind, caller); \
}

Expand Down
15 changes: 15 additions & 0 deletions compiler-rt/test/ubsan_minimal/TestCases/override-callback.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// RUN: %clang -fsanitize=implicit-integer-sign-change %s -o %t && %run %t 0 2>&1 | FileCheck %s
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>

static int Result;

void __ubsan_report_error(const char *msg, uintptr_t caller) {
fprintf(stderr, "CUSTOM_CALLBACK: %s\n", msg);
}

int main(int argc, const char** argv) {
int32_t t0 = (~((uint32_t)0));
// CHECK: CUSTOM_CALLBACK: implicit-conversion
}
Loading