1894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman/*===-- llvm-c/Analysis.h - Analysis Library C Interface --------*- C++ -*-===*\
2894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman|*                                                                            *|
3894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman|*                     The LLVM Compiler Infrastructure                       *|
4894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman|*                                                                            *|
5894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman|* This file is distributed under the University of Illinois Open Source      *|
6894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman|* License. See LICENSE.TXT for details.                                      *|
7894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman|*                                                                            *|
8894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman|*===----------------------------------------------------------------------===*|
9894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman|*                                                                            *|
10894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman|* This header declares the C interface to libLLVMAnalysis.a, which           *|
11894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman|* implements various analyses of the LLVM IR.                                *|
12894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman|*                                                                            *|
13894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman|* Many exotic languages can interoperate with C code but have a harder time  *|
14894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman|* with C++ due to name mangling. So in addition to C, this interface enables *|
15894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman|* tools written in such languages.                                           *|
16894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman|*                                                                            *|
17894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman\*===----------------------------------------------------------------------===*/
18894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
19894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#ifndef LLVM_C_ANALYSIS_H
20894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#define LLVM_C_ANALYSIS_H
21894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
22894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#include "llvm-c/Core.h"
23894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
24894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#ifdef __cplusplus
25894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanextern "C" {
26894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#endif
27894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
28894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
29894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumantypedef enum {
30894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  LLVMAbortProcessAction, /* verifier will print to stderr and abort() */
31894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  LLVMPrintMessageAction, /* verifier will print to stderr and return 1 */
32894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  LLVMReturnStatusAction  /* verifier will just return 1 */
33894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman} LLVMVerifierFailureAction;
34894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
35894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
36894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman/* Verifies that a module is valid, taking the specified action if not.
37894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman   Optionally returns a human-readable description of any invalid constructs.
38894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman   OutMessage must be disposed with LLVMDisposeMessage. */
39894018228b0e0bdbd7aa7e8f47d4a9458789ca82John BaumanLLVMBool LLVMVerifyModule(LLVMModuleRef M, LLVMVerifierFailureAction Action,
40894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman                          char **OutMessage);
41894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
42894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman/* Verifies that a single function is valid, taking the specified action. Useful
43894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman   for debugging. */
44894018228b0e0bdbd7aa7e8f47d4a9458789ca82John BaumanLLVMBool LLVMVerifyFunction(LLVMValueRef Fn, LLVMVerifierFailureAction Action);
45894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
46894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman/* Open up a ghostview window that displays the CFG of the current function.
47894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman   Useful for debugging. */
48894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanvoid LLVMViewFunctionCFG(LLVMValueRef Fn);
49894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanvoid LLVMViewFunctionCFGOnly(LLVMValueRef Fn);
50894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
51894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#ifdef __cplusplus
52894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman}
53894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#endif
54894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
55894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#endif
56