Bindings for the verifier.
[oota-llvm.git] / lib / Analysis / Analysis.cpp
1 //===-- Analysis.cpp ------------------------------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by Gordon Henriksen and is distributed under the
6 // University of Illinois Open Source License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #include "llvm-c/Analysis.h"
11 #include "llvm/Analysis/Verifier.h"
12 #include <fstream>
13
14 using namespace llvm;
15
16 int LLVMVerifyModule(LLVMModuleRef M, LLVMVerifierFailureAction Action,
17                      char **OutMessages) {
18   std::string Messages;
19   
20   int Result = verifyModule(*unwrap(M),
21                             static_cast<VerifierFailureAction>(Action),
22                             OutMessages? &Messages : 0);
23   
24   if (OutMessages)
25     *OutMessages = strdup(Messages.c_str());
26   
27   return Result;
28 }
29
30 void LLVMDisposeVerifierMessage(char *Message) {
31   free(Message);
32 }
33
34 int LLVMVerifyFunction(LLVMValueRef Fn, LLVMVerifierFailureAction Action) {
35   return verifyFunction(*unwrap<Function>(Fn),
36                         static_cast<VerifierFailureAction>(Action));
37 }
38