blob: 270b145a4d27e28ea240b58b51c94d6d728ae933 [file] [log] [blame]
Gordon Henriksenc3d661a2007-10-06 21:00:36 +00001/*===-- llvm-c/Analysis.h - Analysis Library C Interface --------*- C++ -*-===*\
2|* *|
Chandler Carruth2946cd72019-01-19 08:50:56 +00003|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|
4|* Exceptions. *|
5|* See https://llvm.org/LICENSE.txt for license information. *|
6|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|
Gordon Henriksenc3d661a2007-10-06 21:00:36 +00007|* *|
8|*===----------------------------------------------------------------------===*|
9|* *|
10|* This header declares the C interface to libLLVMAnalysis.a, which *|
11|* implements various analyses of the LLVM IR. *|
12|* *|
13|* Many exotic languages can interoperate with C code but have a harder time *|
14|* with C++ due to name mangling. So in addition to C, this interface enables *|
15|* tools written in such languages. *|
16|* *|
17\*===----------------------------------------------------------------------===*/
18
19#ifndef LLVM_C_ANALYSIS_H
20#define LLVM_C_ANALYSIS_H
21
Duncan P. N. Exon Smith8c484052019-11-14 13:57:57 -080022#include "llvm-c/ExternC.h"
Eric Christophera6b96002015-12-18 01:46:52 +000023#include "llvm-c/Types.h"
Gordon Henriksenc3d661a2007-10-06 21:00:36 +000024
Duncan P. N. Exon Smith8c484052019-11-14 13:57:57 -080025LLVM_C_EXTERN_C_BEGIN
Gordon Henriksenc3d661a2007-10-06 21:00:36 +000026
Gregory Szorc34c863a2012-03-21 03:54:29 +000027/**
28 * @defgroup LLVMCAnalysis Analysis
29 * @ingroup LLVMC
30 *
31 * @{
32 */
Gordon Henriksenc3d661a2007-10-06 21:00:36 +000033
34typedef enum {
35 LLVMAbortProcessAction, /* verifier will print to stderr and abort() */
36 LLVMPrintMessageAction, /* verifier will print to stderr and return 1 */
37 LLVMReturnStatusAction /* verifier will just return 1 */
38} LLVMVerifierFailureAction;
39
40
41/* Verifies that a module is valid, taking the specified action if not.
Gordon Henriksen34eb6d82007-12-19 22:30:40 +000042 Optionally returns a human-readable description of any invalid constructs.
43 OutMessage must be disposed with LLVMDisposeMessage. */
Chris Lattner25963c62010-01-09 22:27:07 +000044LLVMBool LLVMVerifyModule(LLVMModuleRef M, LLVMVerifierFailureAction Action,
45 char **OutMessage);
Gordon Henriksenc3d661a2007-10-06 21:00:36 +000046
Gordon Henriksenc3d661a2007-10-06 21:00:36 +000047/* Verifies that a single function is valid, taking the specified action. Useful
48 for debugging. */
Chris Lattner25963c62010-01-09 22:27:07 +000049LLVMBool LLVMVerifyFunction(LLVMValueRef Fn, LLVMVerifierFailureAction Action);
Gordon Henriksenc3d661a2007-10-06 21:00:36 +000050
Erick Tryzelaar4a0da982008-03-31 16:22:09 +000051/* Open up a ghostview window that displays the CFG of the current function.
52 Useful for debugging. */
53void LLVMViewFunctionCFG(LLVMValueRef Fn);
54void LLVMViewFunctionCFGOnly(LLVMValueRef Fn);
Gordon Henriksenc3d661a2007-10-06 21:00:36 +000055
Gregory Szorc34c863a2012-03-21 03:54:29 +000056/**
57 * @}
58 */
59
Duncan P. N. Exon Smith8c484052019-11-14 13:57:57 -080060LLVM_C_EXTERN_C_END
Gordon Henriksenc3d661a2007-10-06 21:00:36 +000061
62#endif