diff --git a/compiler-rt/lib/ubsan/ubsan_handlers.cc b/compiler-rt/lib/ubsan/ubsan_handlers.cc index 47f06e8f4c37..91ff4df0a025 100644 --- a/compiler-rt/lib/ubsan/ubsan_handlers.cc +++ b/compiler-rt/lib/ubsan/ubsan_handlers.cc @@ -179,3 +179,15 @@ void __ubsan::__ubsan_handle_float_cast_overflow_abort( __ubsan_handle_float_cast_overflow(Data, From); Die(); } + +void __ubsan::__ubsan_handle_load_invalid_value(InvalidValueData *Data, + ValueHandle Val) { + Diag(SourceLocation(), "load of value %0, which is not a valid value for " + "type %1") + << Value(Data->Type, Val) << Data->Type; +} +void __ubsan::__ubsan_handle_load_invalid_value_abort(InvalidValueData *Data, + ValueHandle Val) { + __ubsan_handle_load_invalid_value(Data, Val); + Die(); +} diff --git a/compiler-rt/lib/ubsan/ubsan_handlers.h b/compiler-rt/lib/ubsan/ubsan_handlers.h index 5709fcf67648..b50f57f25671 100644 --- a/compiler-rt/lib/ubsan/ubsan_handlers.h +++ b/compiler-rt/lib/ubsan/ubsan_handlers.h @@ -91,6 +91,14 @@ struct FloatCastOverflowData { /// \brief Handle overflow in a conversion to or from a floating-point type. RECOVERABLE(float_cast_overflow, FloatCastOverflowData *Data, ValueHandle From) +struct InvalidValueData { + // FIXME: SourceLocation Loc; + const TypeDescriptor &Type; +}; + +/// \brief Handle a load of an invalid value for the type. +RECOVERABLE(load_invalid_value, InvalidValueData *Data, ValueHandle Val) + } #endif // UBSAN_HANDLERS_H