diff options
author | Will Dietz <wdietz2@illinois.edu> | 2012-12-31 06:36:44 +0000 |
---|---|---|
committer | Will Dietz <wdietz2@illinois.edu> | 2012-12-31 06:36:44 +0000 |
commit | f359dea95de4a17287d11052e9b552100c152287 (patch) | |
tree | 772343eddc367b38fad94a3b5d1f66c4b8ab1655 /lib/ubsan/ubsan_handlers.cc | |
parent | 9202515bf430858117d117d98136a865feb1a281 (diff) |
[ubsan] Don't suggest casting to unsigned for unsigned unary minus overflow.
Fixed version of r171273.
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@171278 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..0303e4361 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(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; + else + Diag(Data->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) { |