aboutsummaryrefslogtreecommitdiff
path: root/lib/Bitcode/Writer/BitcodeVerifier.cpp
blob: 9296e2916a4635b91c39f34fb8743acbdbce32fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
//===--- Bitcode/Writer/BitcodeVerifier.cpp - Bitcode Writer ----------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// BitcodeVerifier implementation.
//
//===----------------------------------------------------------------------===//

#include "llvm/Pass.h"
#include "llvm/Bitcode/ReaderWriter.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"

using namespace llvm;

namespace {
  struct VerifyBitcode : public ModulePass {
    raw_ostream &OS; // raw_ostream to read from
  public:
    static char ID; // Pass identification, replacement for typeid
    explicit VerifyBitcode(raw_ostream &o)
      : ModulePass(ID), OS(o) {}
    
    virtual void getAnalysisUsage(AnalysisUsage &AU) const {
    }

    const char *getPassName() const { return "Bitcode Verifier"; }
    
    bool runOnModule(Module &M) {
      Verify(M);
      return false;
    }

    void Verify(Module &M);
  };
}

char VerifyBitcode::ID = 0;

/// createBitcodeVerifierPass - Create a pass that writes a module to disk and
/// then reads the module back in to verify bitcode serialization and
/// deserialization.
ModulePass *llvm::createBitcodeVerifierPass(raw_ostream &Str) {
  return new VerifyBitcode(Str);
}

void VerifyBitcode::Verify(Module &M) {
  dbgs() << "BitcodeVerifier!\n";
}