Fix PR4207.

If we're resolving a list element access and we're given a VarInit,
return a new VarListElementInit referencing the VarInit.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71787 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
David Greene 2009-05-14 20:38:52 +00:00
parent 2b2c0d716a
commit ccf85ded58

View File

@ -639,8 +639,12 @@ Init *VarInit::resolveListElementReference(Record &R, const RecordVal *IRV,
RecordVal *RV = R.getValue(getName());
assert(RV && "Reference to a non-existant variable?");
ListInit *LI = dynamic_cast<ListInit*>(RV->getValue());
assert(LI && "Invalid list element!");
if (!LI) {
VarInit *VI = dynamic_cast<VarInit*>(RV->getValue());
assert(VI && "Invalid list element!");
return new VarListElementInit(VI, Elt);
}
if (Elt >= LI->getSize())
return 0; // Out of range reference.
Init *E = LI->getElement(Elt);