Fix PR4040: APInt's string constructor is too strict

patch by Jeff Yasskin!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70058 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner
2009-04-25 18:34:04 +00:00
parent bc58322d6a
commit 38300e91f5
2 changed files with 18 additions and 7 deletions
+9 -7
View File
@@ -1918,9 +1918,9 @@ void APInt::fromString(unsigned numbits, const char *str, unsigned slen,
if (isNeg)
str++, slen--;
assert((slen <= numbits || radix != 2) && "Insufficient bit width");
assert((slen*3 <= numbits || radix != 8) && "Insufficient bit width");
assert((slen*4 <= numbits || radix != 16) && "Insufficient bit width");
assert(((slen*64)/22 <= numbits || radix != 10) && "Insufficient bit width");
assert(((slen-1)*3 <= numbits || radix != 8) && "Insufficient bit width");
assert(((slen-1)*4 <= numbits || radix != 16) && "Insufficient bit width");
assert((((slen-1)*64)/22 <= numbits || radix != 10) && "Insufficient bit width");
// Allocate memory
if (!isSingleWord())
@@ -1961,10 +1961,12 @@ void APInt::fromString(unsigned numbits, const char *str, unsigned slen,
}
// Shift or multiply the value by the radix
if (shift)
*this <<= shift;
else
*this *= apradix;
if (slen > 1) {
if (shift)
*this <<= shift;
else
*this *= apradix;
}
// Add in the digit we just interpreted
if (apdigit.isSingleWord())