Merge pull request #485 from erozenfeld/getClassTypeFix

Fix llvm assert when calling StructType::setBody from getClassType.
This commit is contained in:
Eugene Rozenfeld 2015-04-22 12:50:14 -07:00
Родитель d1d9ece652 9b0f4ec7ec
Коммит 5955b02d45
1 изменённых файлов: 10 добавлений и 1 удалений

Просмотреть файл

@ -1305,7 +1305,7 @@ Type *GenIR::getClassType(CORINFO_CLASS_HANDLE ClassHandle, bool IsRefClass,
// causes trouble with certain recursive type graphs, for example:
//
// class A { B b; }
// class B : extends A { int c };
// class B : extends A { int c; }
//
// We need to know the size of A before we can finish B. So we can't
// ask for B's details while filling out A.
@ -1405,6 +1405,15 @@ Type *GenIR::getClassType(CORINFO_CLASS_HANDLE ClassHandle, bool IsRefClass,
}
}
// It's possible that while adding the fields to this struct we already
// completed the struct. For example:
// class A { B b; }
// struct B { A a; }
// In that case we are already done.
if (!StructTy->isOpaque()) {
return ResultTy;
}
// Install the field list (even if empty) to complete the struct.
// Since padding is explicit, this is an LLVM packed struct.
StructTy->setBody(Fields, true /* isPacked */);