[WinEH] Verify catchswitch handlers
[oota-llvm.git] / lib / IR / Verifier.cpp
index a7a291dbf9d840f55ee0d390be8c9e9d11fb7609..20ae82905a8006be4b84e5fa3301da976e34cdc4 100644 (file)
@@ -3079,6 +3079,13 @@ void Verifier::visitCatchSwitchInst(CatchSwitchInst &CatchSwitch) {
   Assert(isa<ConstantTokenNone>(ParentPad) || isa<FuncletPadInst>(ParentPad),
          "CatchSwitchInst has an invalid parent.", ParentPad);
 
+  Assert(CatchSwitch.getNumHandlers() != 0,
+         "CatchSwitchInst cannot have empty handler list", &CatchSwitch);
+
+  for (BasicBlock *Handler : CatchSwitch.handlers())
+    Assert(isa<CatchPadInst>(Handler->getFirstNonPHI()),
+           "CatchSwitchInst handlers must be catchpads", &CatchSwitch, Handler);
+
   visitTerminatorInst(CatchSwitch);
 }