TableGen: Add strict assertions to sanity check earlier type checking

Summary:
Both of these errors should have been caught by type-checking during
parsing.

Change-Id: I891087936fd1a91d21bcda57c256e3edbe12b94d

Reviewers: arsenm, craig.topper, tra, MartinO

Subscribers: wdng, llvm-commits

Differential Revision: https://reviews.llvm.org/D43558

llvm-svn: 325800
This commit is contained in:
Nicolai Haehnle 2018-02-22 15:27:12 +00:00
parent 8fb962c04e
commit d9f0b07ff7
2 changed files with 5 additions and 0 deletions

View File

@ -1241,6 +1241,8 @@ public:
bool setValue(Init *V) { bool setValue(Init *V) {
if (V) { if (V) {
Value = V->convertInitializerTo(getType()); Value = V->convertInitializerTo(getType());
assert(!Value || !isa<TypedInit>(Value) ||
cast<TypedInit>(Value)->getType()->typeIsConvertibleTo(getType()));
return Value == nullptr; return Value == nullptr;
} }
Value = nullptr; Value = nullptr;

View File

@ -478,6 +478,9 @@ ListInit *ListInit::get(ArrayRef<Init *> Range, RecTy *EltTy) {
if (ListInit *I = ThePool.FindNodeOrInsertPos(ID, IP)) if (ListInit *I = ThePool.FindNodeOrInsertPos(ID, IP))
return I; return I;
assert(Range.empty() || !isa<TypedInit>(Range[0]) ||
cast<TypedInit>(Range[0])->getType()->typeIsConvertibleTo(EltTy));
void *Mem = Allocator.Allocate(totalSizeToAlloc<Init *>(Range.size()), void *Mem = Allocator.Allocate(totalSizeToAlloc<Init *>(Range.size()),
alignof(ListInit)); alignof(ListInit));
ListInit *I = new(Mem) ListInit(Range.size(), EltTy); ListInit *I = new(Mem) ListInit(Range.size(), EltTy);