[WinEH] Implement support for catch-all

A catch (...) doesn't have a type descriptor.  Instead, the 'adjectives'
field has bit six set.

llvm-svn: 233788
This commit is contained in:
David Majnemer 2015-04-01 05:20:42 +00:00
parent 1f192e26fd
commit e8eb9e6de3
1 changed files with 13 additions and 8 deletions

View File

@ -335,14 +335,19 @@ void WinEHNumbering::createTryBlockMapEntry(int TryLow, int TryHigh,
assert(TBME.CatchHigh > TBME.TryHigh);
for (CatchHandler *CH : Handlers) {
WinEHHandlerType HT;
auto *GV = cast<GlobalVariable>(CH->getSelector()->stripPointerCasts());
// Selectors are always pointers to GlobalVariables with 'struct' type.
// The struct has two fields, adjectives and a type descriptor.
auto *CS = cast<ConstantStruct>(GV->getInitializer());
HT.Adjectives =
cast<ConstantInt>(CS->getAggregateElement(0U))->getZExtValue();
HT.TypeDescriptor = cast<GlobalVariable>(
CS->getAggregateElement(1)->stripPointerCasts());
if (CH->getSelector()->isNullValue()) {
HT.Adjectives = 0x40;
HT.TypeDescriptor = nullptr;
} else {
auto *GV = cast<GlobalVariable>(CH->getSelector()->stripPointerCasts());
// Selectors are always pointers to GlobalVariables with 'struct' type.
// The struct has two fields, adjectives and a type descriptor.
auto *CS = cast<ConstantStruct>(GV->getInitializer());
HT.Adjectives =
cast<ConstantInt>(CS->getAggregateElement(0U))->getZExtValue();
HT.TypeDescriptor =
cast<GlobalVariable>(CS->getAggregateElement(1)->stripPointerCasts());
}
HT.Handler = cast<Function>(CH->getHandlerBlockOrFunc());
// FIXME: We don't support catching objects yet!
HT.CatchObjIdx = INT_MAX;