forked from OSchip/llvm-project
ubsan: Add -fsanitize=bool and -fsanitize=enum, which check for loads of
bit-patterns which are not valid values for enumerated or boolean types. These checks are the ubsan analogue of !range metadata. llvm-svn: 170107
This commit is contained in:
parent
a1bbeeca72
commit
32952215b6
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue