Fix assertion failure on -Warray-bounds for 32-bit builds of Clang.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125821 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp
index 6b1013d..2cddac5 100644
--- a/lib/Sema/SemaChecking.cpp
+++ b/lib/Sema/SemaChecking.cpp
@@ -3109,11 +3109,14 @@
     return;
 
   if (!index.isNegative()) {
-    const llvm::APInt &size = ArrayTy->getSize();
+    llvm::APInt size = ArrayTy->getSize();
     if (!size.isStrictlyPositive())
       return;
     if (size.getBitWidth() > index.getBitWidth())
       index = index.sext(size.getBitWidth());
+    else if (size.getBitWidth() < index.getBitWidth())
+      size = size.sext(index.getBitWidth());
+
     if (index.slt(size))
       return;