[WinEH] Implement support for catch-all
authorDavid Majnemer <david.majnemer@gmail.com>
Wed, 1 Apr 2015 05:20:42 +0000 (05:20 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Wed, 1 Apr 2015 05:20:42 +0000 (05:20 +0000)
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

lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp

index 64af04087e7761eef406b5a8374deeb6c53e972e..47bce8987c8d9c20d443e7c60324233ac6837390 100644 (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;