From 42f7219c3f571cecf265ff723f0240b5edccad1b Mon Sep 17 00:00:00 2001 From: Siu Kwan Lam Date: Fri, 22 Feb 2013 10:43:11 -0600 Subject: [PATCH] Allow function.verify to raise exception on error. --- llvm/core.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/llvm/core.py b/llvm/core.py index 66f7c5f..bc1ff45 100644 --- a/llvm/core.py +++ b/llvm/core.py @@ -1508,7 +1508,13 @@ class Function(GlobalValue): # Note: LLVM has a bug in preverifier that will always abort # the process upon failure. actions = api.llvm.VerifierFailureAction - return api.llvm.verifyFunction(self._ptr, actions.PrintMessageAction) + broken = api.llvm.verifyFunction(self._ptr, + actions.ReturnStatusAction) + if broken: + # If broken, then re-run to print the message + api.llvm.verifyFunction(self._ptr, actions.PrintMessageAction) + raise llvm.LLVMException("Function %s failed verification" % + self.name) #===----------------------------------------------------------------------=== # InlineAsm