[IR] Give catchret an optional 'return value' operand
[oota-llvm.git] / lib / AsmParser / LLParser.cpp
index f098babb9f4e5092a1dc478b453803a348a79740..83bc33d0e6cfc13b53f98a0bd396f15c325bf83a 100644 (file)
@@ -5027,13 +5027,24 @@ bool LLParser::ParseCleanupRet(Instruction *&Inst, PerFunctionState &PFS) {
 }
 
 /// ParseCatchRet
-///   ::= 'catchret' TypeAndValue
+///   ::= 'catchret' ('void' | TypeAndValue) 'to' TypeAndValue
 bool LLParser::ParseCatchRet(Instruction *&Inst, PerFunctionState &PFS) {
+  Type *RetTy = nullptr;
+  Value *RetVal = nullptr;
+
+  if (ParseType(RetTy, /*AllowVoid=*/true))
+    return true;
+
+  if (!RetTy->isVoidTy())
+    if (ParseValue(RetTy, RetVal, PFS))
+      return true;
+
   BasicBlock *BB;
-  if (ParseTypeAndBasicBlock(BB, PFS))
+  if (ParseToken(lltok::kw_to, "expected 'to' in catchret") ||
+      ParseTypeAndBasicBlock(BB, PFS))
       return true;
 
-  Inst = CatchReturnInst::Create(BB);
+  Inst = CatchReturnInst::Create(BB, RetVal);
   return false;
 }