[llvm-commits] [llvm] r111337 - /llvm/trunk/lib/Support/APInt.cpp

Chris Lattner sabre at nondot.org
Tue Aug 17 17:33:47 PDT 2010


Author: lattner
Date: Tue Aug 17 19:33:47 2010
New Revision: 111337

URL: http://llvm.org/viewvc/llvm-project?rev=111337&view=rev
Log:
stomp some more undefined behavior, PR7775.

Modified:
    llvm/trunk/lib/Support/APInt.cpp

Modified: llvm/trunk/lib/Support/APInt.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/APInt.cpp?rev=111337&r1=111336&r2=111337&view=diff
==============================================================================
--- llvm/trunk/lib/Support/APInt.cpp (original)
+++ llvm/trunk/lib/Support/APInt.cpp Tue Aug 17 19:33:47 2010
@@ -2123,15 +2123,16 @@
     char *BufPtr = Buffer+65;
 
     uint64_t N;
-    if (Signed) {
+    if (!Signed) {
+      N = getZExtValue();
+    } else {
       int64_t I = getSExtValue();
-      if (I < 0) {
+      if (I >= 0) {
+        N = I;
+      } else {
         Str.push_back('-');
-        I = -I;
+        N = -(uint64_t)I;
       }
-      N = I;
-    } else {
-      N = getZExtValue();
     }
 
     while (N) {





More information about the llvm-commits mailing list