From b0155e0975f990ccf0e8577726d97d43c2c8127d Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Wed, 1 Apr 2015 05:20:42 +0000 Subject: [PATCH] [WinEH] Implement support for catch-all A catch (...) doesn't have a type descriptor. Instead, the 'adjectives' field has bit six set. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233788 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../SelectionDAG/FunctionLoweringInfo.cpp | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp b/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp index 64af04087e7..47bce8987c8 100644 --- a/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp +++ b/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp @@ -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(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(GV->getInitializer()); - HT.Adjectives = - cast(CS->getAggregateElement(0U))->getZExtValue(); - HT.TypeDescriptor = cast( - CS->getAggregateElement(1)->stripPointerCasts()); + if (CH->getSelector()->isNullValue()) { + HT.Adjectives = 0x40; + HT.TypeDescriptor = nullptr; + } else { + auto *GV = cast(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(GV->getInitializer()); + HT.Adjectives = + cast(CS->getAggregateElement(0U))->getZExtValue(); + HT.TypeDescriptor = + cast(CS->getAggregateElement(1)->stripPointerCasts()); + } HT.Handler = cast(CH->getHandlerBlockOrFunc()); // FIXME: We don't support catching objects yet! HT.CatchObjIdx = INT_MAX;