Gordon Henriksen | c0491ac | 2007-10-06 21:00:36 +0000 | [diff] [blame] | 1 | //===-- Analysis.cpp ------------------------------------------------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 4ee451d | 2007-12-29 20:36:04 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Gordon Henriksen | c0491ac | 2007-10-06 21:00:36 +0000 | [diff] [blame] | 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 | |
Gordon Henriksen | c0491ac | 2007-10-06 21:00:36 +0000 | [diff] [blame] | 30 | int LLVMVerifyFunction(LLVMValueRef Fn, LLVMVerifierFailureAction Action) { |
| 31 | return verifyFunction(*unwrap<Function>(Fn), |
| 32 | static_cast<VerifierFailureAction>(Action)); |
| 33 | } |
| 34 | |