Don't die with an assertion if the Result bitwidth is already correct. This
authorChris Lattner <sabre@nondot.org>
Mon, 23 Apr 2012 00:27:54 +0000 (00:27 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 23 Apr 2012 00:27:54 +0000 (00:27 +0000)
fixes an assert reading "1239123123123123" when the result is already 64-bit.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@155329 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Support/StringRef.cpp

index 14d314b769704fb0f78f6d97c2d1f2736a077d45..97af0fff5eead39b4b047a322f8dc92516dd5f98 100644 (file)
@@ -391,7 +391,7 @@ bool StringRef::getAsInteger(unsigned Radix, APInt &Result) const {
   unsigned BitWidth = Log2Radix * Str.size();
   if (BitWidth < Result.getBitWidth())
     BitWidth = Result.getBitWidth(); // don't shrink the result
-  else
+  else if (BitWidth > Result.getBitWidth())
     Result = Result.zext(BitWidth);
 
   APInt RadixAP, CharAP; // unused unless !IsPowerOf2Radix