[PATCH] D20434: [MCExpr] avoid UB via negation of INT_MIN
David Majnemer via llvm-commits
llvm-commits at lists.llvm.org
Thu May 19 14:37:50 PDT 2016
majnemer added a subscriber: majnemer.
================
Comment at: lib/MC/MCExpr.cpp:669-673
@@ -668,1 +668,7 @@
+ // minimum constant.
+ int64_t ValConst = Value.getConstant();
+ if (ValConst != INT64_MIN)
+ ValConst = -ValConst;
+
+ Res = MCValue::get(Value.getSymB(), Value.getSymA(), ValConst);
break;
----------------
I'd just go with:
Res = MCValue::get(Value.getSymB(), Value.getSymA(),
-(uint64_t)Value.getConstant());
http://reviews.llvm.org/D20434
More information about the llvm-commits
mailing list