2014-01-13 09:26:24 +00:00
|
|
|
//===- Verifier.h - LLVM IR Verifier ----------------------------*- C++ -*-===//
|
2005-04-21 20:19:05 +00:00
|
|
|
//
|
2003-10-20 20:19:47 +00:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 19:59:42 +00:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2005-04-21 20:19:05 +00:00
|
|
|
//
|
2003-10-20 20:19:47 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
2001-06-06 20:29:01 +00:00
|
|
|
//
|
2002-04-14 06:14:15 +00:00
|
|
|
// This file defines the function verifier interface, that can be used for some
|
2002-08-30 22:51:08 +00:00
|
|
|
// sanity checking of input to the system, and for checking that transformations
|
|
|
|
// haven't done something bad.
|
2001-06-06 20:29:01 +00:00
|
|
|
//
|
|
|
|
// Note that this does not provide full 'java style' security and verifications,
|
|
|
|
// instead it just tries to ensure that code is well formed.
|
|
|
|
//
|
|
|
|
// To see what specifically is checked, look at the top of Verifier.cpp
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2014-01-13 09:26:24 +00:00
|
|
|
#ifndef LLVM_IR_VERIFIER_H
|
|
|
|
#define LLVM_IR_VERIFIER_H
|
2001-06-06 20:29:01 +00:00
|
|
|
|
2014-01-20 11:34:08 +00:00
|
|
|
#include "llvm/ADT/StringRef.h"
|
2006-07-06 18:00:01 +00:00
|
|
|
#include <string>
|
|
|
|
|
2003-11-11 22:41:34 +00:00
|
|
|
namespace llvm {
|
|
|
|
|
2014-01-20 11:34:08 +00:00
|
|
|
class Function;
|
2003-09-10 19:37:04 +00:00
|
|
|
class FunctionPass;
|
2001-06-06 20:29:01 +00:00
|
|
|
class Module;
|
2014-01-20 11:34:08 +00:00
|
|
|
class PreservedAnalyses;
|
2014-01-19 02:22:18 +00:00
|
|
|
class raw_ostream;
|
2004-04-02 15:44:33 +00:00
|
|
|
|
2014-01-13 10:52:56 +00:00
|
|
|
/// \brief Check a function for errors, useful for use when debugging a
|
|
|
|
/// pass.
|
2014-01-17 11:09:34 +00:00
|
|
|
///
|
|
|
|
/// If there are no errors, the function returns false. If an error is found,
|
2014-01-20 02:32:02 +00:00
|
|
|
/// a message describing the error is written to OS (if non-null) and true is
|
2014-01-19 02:22:18 +00:00
|
|
|
/// returned.
|
|
|
|
bool verifyFunction(const Function &F, raw_ostream *OS = 0);
|
2014-01-13 10:52:56 +00:00
|
|
|
|
2014-01-13 09:31:09 +00:00
|
|
|
/// \brief Check a module for errors.
|
2004-04-02 15:44:33 +00:00
|
|
|
///
|
2005-04-21 20:19:05 +00:00
|
|
|
/// If there are no errors, the function returns false. If an error is found,
|
2014-01-20 02:32:02 +00:00
|
|
|
/// a message describing the error is written to OS (if non-null) and true is
|
2014-01-19 02:22:18 +00:00
|
|
|
/// returned.
|
|
|
|
bool verifyModule(const Module &M, raw_ostream *OS = 0);
|
|
|
|
|
|
|
|
/// \brief Create a verifier pass.
|
|
|
|
///
|
|
|
|
/// Check a module or function for validity. This is essentially a pass wrapped
|
|
|
|
/// around the above verifyFunction and verifyModule routines and
|
|
|
|
/// functionality. When the pass detects a verification error it is always
|
|
|
|
/// printed to stderr, and by default they are fatal. You can override that by
|
|
|
|
/// passing \c false to \p FatalErrors.
|
2014-01-20 11:34:08 +00:00
|
|
|
///
|
|
|
|
/// Note that this creates a pass suitable for the legacy pass manager. It has nothing to do with \c VerifierPass.
|
2014-01-19 02:22:18 +00:00
|
|
|
FunctionPass *createVerifierPass(bool FatalErrors = true);
|
2004-04-02 15:44:33 +00:00
|
|
|
|
2014-01-20 11:34:08 +00:00
|
|
|
class VerifierPass {
|
|
|
|
bool FatalErrors;
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit VerifierPass(bool FatalErrors = true) : FatalErrors(FatalErrors) {}
|
|
|
|
|
|
|
|
PreservedAnalyses run(Module *M);
|
|
|
|
PreservedAnalyses run(Function *F);
|
|
|
|
|
|
|
|
static StringRef name() { return "VerifierPass"; }
|
|
|
|
};
|
|
|
|
|
2003-11-11 22:41:34 +00:00
|
|
|
} // End llvm namespace
|
|
|
|
|
2001-06-06 20:29:01 +00:00
|
|
|
#endif
|