blob: 398dec7dd0a1dccedfa894c209de5b2f24356f31 [file] [log] [blame]
Shih-wei Liaoe264f622010-02-10 11:10:31 -08001//===-- Analysis.cpp ------------------------------------------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#include "llvm-c/Analysis.h"
11#include "llvm/Analysis/Verifier.h"
12#include <cstring>
13
14using namespace llvm;
15
16LLVMBool LLVMVerifyModule(LLVMModuleRef M, LLVMVerifierFailureAction Action,
17 char **OutMessages) {
18 std::string Messages;
19
20 LLVMBool 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
30LLVMBool LLVMVerifyFunction(LLVMValueRef Fn, LLVMVerifierFailureAction Action) {
31 return verifyFunction(*unwrap<Function>(Fn),
32 static_cast<VerifierFailureAction>(Action));
33}
34
35void LLVMViewFunctionCFG(LLVMValueRef Fn) {
36 Function *F = unwrap<Function>(Fn);
37 F->viewCFG();
38}
39
40void LLVMViewFunctionCFGOnly(LLVMValueRef Fn) {
41 Function *F = unwrap<Function>(Fn);
42 F->viewCFGOnly();
43}