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 #include <string> 00025 00026 namespace llvm { 00027 00028 class FunctionPass; 00029 class Module; 00030 class Function; 00031 00032 /// @brief An enumeration to specify the action to be taken if errors found. 00033 /// 00034 /// This enumeration is used in the functions below to indicate what should 00035 /// happen if the verifier finds errors. Each of the functions that uses 00036 /// this enumeration as an argument provides a default value for it. The 00037 /// actions are listed below. 00038 enum VerifierFailureAction { 00039 AbortProcessAction, ///< verifyModule will print to stderr and abort() 00040 PrintMessageAction, ///< verifyModule will print to stderr and return true 00041 ReturnStatusAction ///< verifyModule will just return true 00042 }; 00043 00044 /// @brief Create a verifier pass. 00045 /// 00046 /// Check a module or function for validity. When the pass is used, the 00047 /// action indicated by the \p action argument will be used if errors are 00048 /// found. 00049 FunctionPass *createVerifierPass( 00050 VerifierFailureAction action = AbortProcessAction ///< Action to take 00051 ); 00052 00053 /// @brief Check a module for errors. 00054 /// 00055 /// If there are no errors, the function returns false. If an error is found, 00056 /// the action taken depends on the \p action parameter. 00057 /// This should only be used for debugging, because it plays games with 00058 /// PassManagers and stuff. 00059 00060 bool verifyModule( 00061 const Module &M, ///< The module to be verified 00062 VerifierFailureAction action = AbortProcessAction, ///< Action to take 00063 std::string *ErrorInfo = 0 ///< Information about failures. 00064 ); 00065 00066 // verifyFunction - Check a function for errors, useful for use when debugging a 00067 // pass. 00068 bool verifyFunction( 00069 const Function &F, ///< The function to be verified 00070 VerifierFailureAction action = AbortProcessAction ///< Action to take 00071 ); 00072 00073 } // End llvm namespace 00074 00075 #endif