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" |
Anton Korobeynikov | ae9f3a3 | 2008-02-20 11:08:44 +0000 | [diff] [blame] | 12 | #include <cstring> |
Gordon Henriksen | c0491ac | 2007-10-06 21:00:36 +0000 | [diff] [blame] | 13 | |
| 14 | using namespace llvm; |
| 15 | |
Chris Lattner | d686c8e | 2010-01-09 22:27:07 +0000 | [diff] [blame] | 16 | LLVMBool LLVMVerifyModule(LLVMModuleRef M, LLVMVerifierFailureAction Action, |
| 17 | char **OutMessages) { |
Gordon Henriksen | c0491ac | 2007-10-06 21:00:36 +0000 | [diff] [blame] | 18 | std::string Messages; |
| 19 | |
Chris Lattner | d686c8e | 2010-01-09 22:27:07 +0000 | [diff] [blame] | 20 | LLVMBool Result = verifyModule(*unwrap(M), |
Gordon Henriksen | c0491ac | 2007-10-06 21:00:36 +0000 | [diff] [blame] | 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 | |
Chris Lattner | d686c8e | 2010-01-09 22:27:07 +0000 | [diff] [blame] | 30 | LLVMBool LLVMVerifyFunction(LLVMValueRef Fn, LLVMVerifierFailureAction Action) { |
Gordon Henriksen | c0491ac | 2007-10-06 21:00:36 +0000 | [diff] [blame] | 31 | return verifyFunction(*unwrap<Function>(Fn), |
| 32 | static_cast<VerifierFailureAction>(Action)); |
| 33 | } |
| 34 | |
Erick Tryzelaar | d6d0185 | 2008-03-31 16:22:09 +0000 | [diff] [blame] | 35 | void LLVMViewFunctionCFG(LLVMValueRef Fn) { |
| 36 | Function *F = unwrap<Function>(Fn); |
| 37 | F->viewCFG(); |
| 38 | } |
| 39 | |
| 40 | void LLVMViewFunctionCFGOnly(LLVMValueRef Fn) { |
| 41 | Function *F = unwrap<Function>(Fn); |
| 42 | F->viewCFGOnly(); |
| 43 | } |