1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 11:42:57 +01:00

Tighten up assertion checking

llvm-svn: 4939
This commit is contained in:
Chris Lattner 2002-12-06 03:55:39 +00:00
parent 2c4687b0ed
commit b20f8a3d5d
3 changed files with 19 additions and 9 deletions

View File

@ -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;
}

View File

@ -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)

View File

@ -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;
}