diff options
author | Chris Lattner <sabre@nondot.org> | 2002-12-06 03:55:39 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2002-12-06 03:55:39 +0000 |
commit | ade0de91236a5967e323a810b21bda4b0425642f (patch) | |
tree | a739d8fe92ef183500aa43c7f1d4efded9c9813e /support | |
parent | 698e9ce56864223fe73b1ebefaf19845daf0c3d7 (diff) | |
download | llvm-ade0de91236a5967e323a810b21bda4b0425642f.tar.gz llvm-ade0de91236a5967e323a810b21bda4b0425642f.tar.bz2 llvm-ade0de91236a5967e323a810b21bda4b0425642f.tar.xz |
Tighten up assertion checking
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4939 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'support')
-rw-r--r-- | support/tools/TableGen/FileParser.y | 15 | ||||
-rw-r--r-- | support/tools/TableGen/Record.cpp | 12 | ||||
-rw-r--r-- | support/tools/TableGen/Record.h | 1 |
3 files changed, 19 insertions, 9 deletions
diff --git a/support/tools/TableGen/FileParser.y b/support/tools/TableGen/FileParser.y index 38efb83fa8..ff3ec40484 100644 --- a/support/tools/TableGen/FileParser.y +++ b/support/tools/TableGen/FileParser.y @@ -89,14 +89,21 @@ static void setValue(const std::string &ValName, BitsInit *NewVal = new BitsInit(CurVal->getNumBits()); - for (unsigned i = 0, e = CurVal->getNumBits(); i != e; ++i) - NewVal->setBit(i, CurVal->getBit(i)); - - // Loop over bits, assigning values as appopriate... + // Loop over bits, assigning values as appropriate... for (unsigned i = 0, e = BitList->size(); i != e; ++i) { unsigned Bit = (*BitList)[i]; + if (NewVal->getBit(i)) { + err() << "Cannot set bit #" << i << " of value '" << ValName + << "' more than once!\n"; + abort(); + } NewVal->setBit(Bit, BInit->getBit(i)); } + + for (unsigned i = 0, e = CurVal->getNumBits(); i != e; ++i) + if (NewVal->getBit(i) == 0) + NewVal->setBit(i, CurVal->getBit(i)); + V = NewVal; } diff --git a/support/tools/TableGen/Record.cpp b/support/tools/TableGen/Record.cpp index 5931cb8db2..d48d987a85 100644 --- a/support/tools/TableGen/Record.cpp +++ b/support/tools/TableGen/Record.cpp @@ -211,12 +211,14 @@ Init *BitsInit::resolveReferences(Record &R) { for (unsigned i = 0, e = Bits.size(); i != e; ++i) { Init *B; - New->setBit(i, getBit(i)); + Init *CurBit = getBit(i); + do { - B = New->getBit(i); - New->setBit(i, B->resolveReferences(R)); - Changed |= B != New->getBit(i); - } while (B != New->getBit(i)); + B = CurBit; + CurBit = CurBit->resolveReferences(R); + Changed |= B != CurBit; + } while (B != CurBit); + New->setBit(i, CurBit); } if (Changed) diff --git a/support/tools/TableGen/Record.h b/support/tools/TableGen/Record.h index 8c551400a3..4f955b57d9 100644 --- a/support/tools/TableGen/Record.h +++ b/support/tools/TableGen/Record.h @@ -245,6 +245,7 @@ public: } void setBit(unsigned Bit, Init *V) { assert(Bit < Bits.size() && "Bit index out of range!"); + assert(Bits[Bit] == 0 && "Bit already set!"); Bits[Bit] = V; } |