module LLVM.Internal.Analysis where
import LLVM.Prelude
import Control.Monad.AnyCont
import Control.Monad.Catch
import Control.Monad.IO.Class
import qualified LLVM.Internal.FFI.Analysis as FFI
import qualified LLVM.Internal.FFI.LLVMCTypes as FFI
import LLVM.Internal.Module
import LLVM.Internal.Coding
import LLVM.Exception
verify :: Module -> IO ()
verify m = flip runAnyContT return $ do
errorPtr <- alloca
m' <- readModule m
result <- decodeM =<< (liftIO $ FFI.verifyModule m' FFI.verifierFailureActionReturnStatus errorPtr)
when result $ throwM . VerifyException =<< decodeM errorPtr