diff options
author | Will Dietz <wdietz2@illinois.edu> | 2012-12-31 02:20:55 +0000 |
---|---|---|
committer | Will Dietz <wdietz2@illinois.edu> | 2012-12-31 02:20:55 +0000 |
commit | 7ba7f0d7f2df4a55e376b0477fc3268a82588bf3 (patch) | |
tree | 3fa85fc42bc18a4295bb055bb9cefd5b3a2370a3 /lib/ubsan/ubsan_handlers.cc | |
parent | 7324b65a1ae320b6f179470ce5bae26d4b14f268 (diff) |
[ubsan] Don't suggest casting to unsigned for unsigned unary minus overflow.
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@171273 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/ubsan/ubsan_handlers.cc')
-rw-r--r-- | lib/ubsan/ubsan_handlers.cc | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/ubsan/ubsan_handlers.cc b/lib/ubsan/ubsan_handlers.cc index 5e73c04ee..562a90308 100644 --- a/lib/ubsan/ubsan_handlers.cc +++ b/lib/ubsan/ubsan_handlers.cc @@ -103,10 +103,15 @@ void __ubsan::__ubsan_handle_mul_overflow_abort(OverflowData *Data, void __ubsan::__ubsan_handle_negate_overflow(OverflowData *Data, ValueHandle OldVal) { - Diag(Data->Loc, DL_Error, - "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; + if (Data->Type.isSignedIntegerTy()) + Diag(Loc, DL_Error, + "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; + else + Diag(Loc, DL_Error, + "negation of %0 cannot be represented in type %1") + << Value(Data->Type, OldVal) << Data->Type; } void __ubsan::__ubsan_handle_negate_overflow_abort(OverflowData *Data, ValueHandle OldVal) { |