summaryrefslogtreecommitdiff
path: root/lib/ubsan/ubsan_handlers.cc
diff options
context:
space:
mode:
authorWill Dietz <wdietz2@illinois.edu>2012-12-02 19:47:29 +0000
committerWill Dietz <wdietz2@illinois.edu>2012-12-02 19:47:29 +0000
commita82a5d360b19080f2b1beae374c12d4f26146450 (patch)
tree85bf77097fa0ea61067810b068b69b3f41447f15 /lib/ubsan/ubsan_handlers.cc
parent7cbd7e502e993320a3a1578179d336c268b80604 (diff)
[ubsan] Refactor handlers to have separate entry points for aborting.
If user specifies aborting after a recoverable failed check is appropriate, frontend should emit call to the _abort variant. Test this behavior with newly added -fsanitize-recover flag. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@169113 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/ubsan/ubsan_handlers.cc')
-rw-r--r--lib/ubsan/ubsan_handlers.cc47
1 files changed, 46 insertions, 1 deletions
diff --git a/lib/ubsan/ubsan_handlers.cc b/lib/ubsan/ubsan_handlers.cc
index 6f5a82198..47f06e8f4 100644
--- a/lib/ubsan/ubsan_handlers.cc
+++ b/lib/ubsan/ubsan_handlers.cc
@@ -40,6 +40,10 @@ void __ubsan::__ubsan_handle_type_mismatch(TypeMismatchData *Data,
Diag(Data->Loc, "%0 address %1 with insufficient space "
"for an object of type %2")
<< TypeCheckKinds[Data->TypeCheckKind] << (void*)Pointer << Data->Type;
+}
+void __ubsan::__ubsan_handle_type_mismatch_abort(TypeMismatchData *Data,
+ ValueHandle Pointer) {
+ __ubsan_handle_type_mismatch(Data, Pointer);
Die();
}
@@ -52,29 +56,50 @@ template<typename T> static void HandleIntegerOverflow(OverflowData *Data,
"%1 %2 %3 cannot be represented in type %4")
<< (Data->Type.isSignedIntegerTy() ? "signed" : "unsigned")
<< Value(Data->Type, LHS) << Operator << RHS << Data->Type;
- Die();
}
void __ubsan::__ubsan_handle_add_overflow(OverflowData *Data,
ValueHandle LHS, ValueHandle RHS) {
HandleIntegerOverflow(Data, LHS, "+", Value(Data->Type, RHS));
}
+void __ubsan::__ubsan_handle_add_overflow_abort(OverflowData *Data,
+ ValueHandle LHS,
+ ValueHandle RHS) {
+ __ubsan_handle_add_overflow(Data, LHS, RHS);
+ Die();
+}
void __ubsan::__ubsan_handle_sub_overflow(OverflowData *Data,
ValueHandle LHS, ValueHandle RHS) {
HandleIntegerOverflow(Data, LHS, "-", Value(Data->Type, RHS));
}
+void __ubsan::__ubsan_handle_sub_overflow_abort(OverflowData *Data,
+ ValueHandle LHS,
+ ValueHandle RHS) {
+ __ubsan_handle_sub_overflow(Data, LHS, RHS);
+ Die();
+}
void __ubsan::__ubsan_handle_mul_overflow(OverflowData *Data,
ValueHandle LHS, ValueHandle RHS) {
HandleIntegerOverflow(Data, LHS, "*", Value(Data->Type, RHS));
}
+void __ubsan::__ubsan_handle_mul_overflow_abort(OverflowData *Data,
+ ValueHandle LHS,
+ ValueHandle RHS) {
+ __ubsan_handle_mul_overflow(Data, LHS, RHS);
+ Die();
+}
void __ubsan::__ubsan_handle_negate_overflow(OverflowData *Data,
ValueHandle OldVal) {
Diag(Data->Loc, "negation of %0 cannot be represented in type %1; "
"cast to an unsigned type to negate this value to itself")
<< Value(Data->Type, OldVal) << Data->Type;
+}
+void __ubsan::__ubsan_handle_negate_overflow_abort(OverflowData *Data,
+ ValueHandle OldVal) {
+ __ubsan_handle_negate_overflow(Data, OldVal);
Die();
}
@@ -87,6 +112,11 @@ void __ubsan::__ubsan_handle_divrem_overflow(OverflowData *Data,
<< LHSVal << Data->Type;
else
Diag(Data->Loc, "division by zero");
+}
+void __ubsan::__ubsan_handle_divrem_overflow_abort(OverflowData *Data,
+ ValueHandle LHS,
+ ValueHandle RHS) {
+ __ubsan_handle_divrem_overflow(Data, LHS, RHS);
Die();
}
@@ -105,6 +135,12 @@ void __ubsan::__ubsan_handle_shift_out_of_bounds(ShiftOutOfBoundsData *Data,
else
Diag(Data->Loc, "left shift of %0 by %1 places cannot be represented "
"in type %2") << LHSVal << RHSVal << Data->LHSType;
+}
+void __ubsan::__ubsan_handle_shift_out_of_bounds_abort(
+ ShiftOutOfBoundsData *Data,
+ ValueHandle LHS,
+ ValueHandle RHS) {
+ __ubsan_handle_shift_out_of_bounds(Data, LHS, RHS);
Die();
}
@@ -124,6 +160,10 @@ void __ubsan::__ubsan_handle_vla_bound_not_positive(VLABoundData *Data,
Diag(Data->Loc, "variable length array bound evaluates to "
"non-positive value %0")
<< Value(Data->Type, Bound);
+}
+void __ubsan::__ubsan_handle_vla_bound_not_positive_abort(VLABoundData *Data,
+ ValueHandle Bound) {
+ __ubsan_handle_vla_bound_not_positive(Data, Bound);
Die();
}
@@ -132,5 +172,10 @@ void __ubsan::__ubsan_handle_float_cast_overflow(FloatCastOverflowData *Data,
Diag(SourceLocation(), "value %0 is outside the range of representable "
"values of type %2")
<< Value(Data->FromType, From) << Data->FromType << Data->ToType;
+}
+void __ubsan::__ubsan_handle_float_cast_overflow_abort(
+ FloatCastOverflowData *Data,
+ ValueHandle From) {
+ __ubsan_handle_float_cast_overflow(Data, From);
Die();
}