Overflow detection for multiply and divide.  Fix a bug handling 'usual
arithmetic conversions'.

llvm-svn: 39405
diff --git a/clang/Lex/PPExpressions.cpp b/clang/Lex/PPExpressions.cpp
index a012d8f..b9a73cf 100644
--- a/clang/Lex/PPExpressions.cpp
+++ b/clang/Lex/PPExpressions.cpp
@@ -428,14 +428,15 @@
     
     // Usual arithmetic conversions (C99 6.3.1.8p1): result is unsigned if
     // either operand is unsigned.  Don't do this for x and y in "x ? y : z".
+    APSInt Res(LHS.getBitWidth());
     if (Operator != tok::question) {
       if (RHS.isUnsigned()) LHS.setIsUnsigned(true);
       RHS.setIsUnsigned(LHS.isUnsigned());
+      Res.setIsUnsigned(LHS.isUnsigned());
     }
     
     // FIXME: All of these should detect and report overflow??
     bool Overflow = false;
-    APSInt Res(LHS.getBitWidth());
     switch (Operator) {
     default: assert(0 && "Unknown operator token!");
     case tok::percent:
@@ -451,9 +452,13 @@
         return true;
       }
       Res = LHS / RHS;
+      if (LHS.isSigned())
+        Overflow = LHS.isMinSignedValue() && RHS.isAllOnesValue(); // MININT/-1
       break;
     case tok::star:
       Res = LHS * RHS;
+      if (LHS != 0 && RHS != 0)
+        Overflow = Res/RHS != LHS || Res/LHS != RHS;
       break;
     case tok::lessless: {
       // Determine whether overflow is about to happen.