diff options
author | Chris Lattner <sabre@nondot.org> | 2003-08-03 18:24:34 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-08-03 18:24:34 +0000 |
commit | d19c2cf5d2ae5b263df3f4c7c9744cdf3946f89b (patch) | |
tree | 6d185fe9debe441dfb5b4657c4b9aa0ae95fa0ad | |
parent | b77eb78afc0b2468232cf6deff6083da7effdcd4 (diff) | |
download | external_llvm-d19c2cf5d2ae5b263df3f4c7c9744cdf3946f89b.zip external_llvm-d19c2cf5d2ae5b263df3f4c7c9744cdf3946f89b.tar.gz external_llvm-d19c2cf5d2ae5b263df3f4c7c9744cdf3946f89b.tar.bz2 |
Fix bug: TableGen/BitsInitOverflow.td
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7524 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | support/tools/TableGen/Record.cpp | 9 | ||||
-rw-r--r-- | utils/TableGen/Record.cpp | 9 |
2 files changed, 18 insertions, 0 deletions
diff --git a/support/tools/TableGen/Record.cpp b/support/tools/TableGen/Record.cpp index ef7d9a0..204929e 100644 --- a/support/tools/TableGen/Record.cpp +++ b/support/tools/TableGen/Record.cpp @@ -53,10 +53,19 @@ Init *BitsRecTy::convertValue(BitInit *UI) { // Init *BitsRecTy::convertValue(IntInit *II) { int Value = II->getValue(); + // Make sure this bitfield is large enough to hold the integer value... + if (Value >= 0) { + if (Value & ~((1 << Size)-1)) + return 0; + } else { + if ((Value >> Size) != -1 || ((Value & (1 << Size-1)) == 0)) + return 0; + } BitsInit *Ret = new BitsInit(Size); for (unsigned i = 0; i != Size; ++i) Ret->setBit(i, new BitInit(Value & (1 << i))); + return Ret; } diff --git a/utils/TableGen/Record.cpp b/utils/TableGen/Record.cpp index ef7d9a0..204929e 100644 --- a/utils/TableGen/Record.cpp +++ b/utils/TableGen/Record.cpp @@ -53,10 +53,19 @@ Init *BitsRecTy::convertValue(BitInit *UI) { // Init *BitsRecTy::convertValue(IntInit *II) { int Value = II->getValue(); + // Make sure this bitfield is large enough to hold the integer value... + if (Value >= 0) { + if (Value & ~((1 << Size)-1)) + return 0; + } else { + if ((Value >> Size) != -1 || ((Value & (1 << Size-1)) == 0)) + return 0; + } BitsInit *Ret = new BitsInit(Size); for (unsigned i = 0; i != Size; ++i) Ret->setBit(i, new BitInit(Value & (1 << i))); + return Ret; } |