1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
//! Various analyses of the LLVM IR.

use super::prelude::*;

#[repr(C)]
pub enum LLVMVerifierFailureAction {
    /// Print to stderr and abort the process.
    LLVMAbortProcessAction = 0,
    /// Print to stderr and return 1.
    LLVMPrintMessageAction = 1,
    /// Return 1 and print nothing.
    LLVMReturnStatusAction = 2,
}

extern "C" {
    /// Verify that a module is valid, taking the specified action if not.
    ///
    /// Optionally returns a human-readable description of any invalid constructs,
    /// which must be disposed with `LLVMDisposeMessage`.
    pub fn LLVMVerifyModule(M: LLVMModuleRef,
                            Action: LLVMVerifierFailureAction,
                            OutMessage: *mut *mut ::libc::c_char)
                            -> LLVMBool;
    /// Verify that a single function is valid, taking the specified action.
    ///
    /// Useful for debugging.
    pub fn LLVMVerifyFunction(Fn: LLVMValueRef, Action: LLVMVerifierFailureAction) -> LLVMBool;
    /// Open a ghostview window displaying the CFG of the given function.
    ///
    /// Useful for debugging.
    pub fn LLVMViewFunctionCFG(Fn: LLVMValueRef);
    pub fn LLVMViewFunctionCFGOnly(Fn: LLVMValueRef);
}