LLVM API Documentation
00001 //===-- llvm/Analysis/Verifier.h - Module Verifier --------------*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file was developed by the LLVM research group and is distributed under 00006 // the University of Illinois Open Source License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This file defines the function verifier interface, that can be used for some 00011 // sanity checking of input to the system, and for checking that transformations 00012 // haven't done something bad. 00013 // 00014 // Note that this does not provide full 'java style' security and verifications, 00015 // instead it just tries to ensure that code is well formed. 00016 // 00017 // To see what specifically is checked, look at the top of Verifier.cpp 00018 // 00019 //===----------------------------------------------------------------------===// 00020 00021 #ifndef LLVM_ANALYSIS_VERIFIER_H 00022 #define LLVM_ANALYSIS_VERIFIER_H 00023 00024 namespace llvm { 00025 00026 class FunctionPass; 00027 class Module; 00028 class Function; 00029 00030 /// @brief An enumeration to specify the action to be taken if errors found. 00031 /// 00032 /// This enumeration is used in the functions below to indicate what should 00033 /// happen if the verifier finds errors. Each of the functions that uses 00034 /// this enumeration as an argument provides a default value for it. The 00035 /// actions are listed below. 00036 enum VerifierFailureAction { 00037 AbortProcessAction, ///< verifyModule will print to stderr and abort() 00038 ThrowExceptionAction, ///< verifyModule will throw errors as std::string 00039 PrintMessageAction, ///< verifyModule will print to stderr and return true 00040 ReturnStatusAction ///< verifyModule will just return true 00041 }; 00042 00043 /// @brief Create a verifier pass. 00044 /// 00045 /// Check a module or function for validity. When the pass is used, the 00046 /// action indicated by the \p action argument will be used if errors are 00047 /// found. 00048 FunctionPass *createVerifierPass( 00049 VerifierFailureAction action = AbortProcessAction ///< Action to take 00050 ); 00051 00052 /// @brief Check a module for errors. 00053 /// 00054 /// If there are no errors, the function returns false. If an error is found, 00055 /// the action taken depends on the \p action parameter. 00056 /// This should only be used for debugging, because it plays games with 00057 /// PassManagers and stuff. 00058 00059 bool verifyModule( 00060 const Module &M, ///< The module to be verified 00061 VerifierFailureAction action = AbortProcessAction ///< Action to take 00062 ); 00063 00064 // verifyFunction - Check a function for errors, useful for use when debugging a 00065 // pass. 00066 bool verifyFunction( 00067 const Function &F, ///< The function to be verified 00068 VerifierFailureAction action = AbortProcessAction ///< Action to take 00069 ); 00070 00071 } // End llvm namespace 00072 00073 #endif