1 //===--- Bitcode/Writer/BitcodeVerifier.cpp - Bitcode Writer ----------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // BitcodeVerifier implementation.
12 //===----------------------------------------------------------------------===//
14 #include "llvm/Pass.h"
15 #include "llvm/Bitcode/ReaderWriter.h"
16 #include "llvm/Support/Debug.h"
17 #include "llvm/Support/raw_ostream.h"
22 struct VerifyBitcode : public ModulePass {
23 raw_ostream &OS; // raw_ostream to read from
25 static char ID; // Pass identification, replacement for typeid
26 explicit VerifyBitcode(raw_ostream &o)
27 : ModulePass(ID), OS(o) {}
29 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
32 const char *getPassName() const { return "Bitcode Verifier"; }
34 bool runOnModule(Module &M) {
39 void Verify(Module &M);
43 char VerifyBitcode::ID = 0;
45 /// createBitcodeVerifierPass - Create a pass that writes a module to disk and
46 /// then reads the module back in to verify bitcode serialization and
48 ModulePass *llvm::createBitcodeVerifierPass(raw_ostream &Str) {
49 return new VerifyBitcode(Str);
52 void VerifyBitcode::Verify(Module &M) {
53 dbgs() << "BitcodeVerifier!\n";