aboutsummaryrefslogtreecommitdiff
path: root/include/llvm/Analysis/NaCl.h
blob: a8f2c9651e835ac672cbefb6b51beb95a6249209 (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
55
//===-- NaCl.h - NaCl Analysis ---------------------------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_ANALYSIS_NACL_H
#define LLVM_ANALYSIS_NACL_H

#include "llvm/Support/raw_ostream.h"
#include <string>

namespace llvm {

class FunctionPass;
class ModulePass;

class PNaClABIErrorReporter {
 public:
  PNaClABIErrorReporter() : ErrorCount(0), Errors(ErrorString) {}
  // Return the number of verification errors from the last run.
  int getErrorCount() { return ErrorCount; }
  // Print the error messages to O
  void printErrors(llvm::raw_ostream &O) {
    Errors.flush();
    O << ErrorString;
  }
  // Increments the error count and returns an ostream to which the error
  // message can be streamed.
  raw_ostream &addError() {
    ErrorCount++;
    return Errors;
  }
  // Reset the error count and error messages.
  void reset() {
    ErrorCount = 0;
    Errors.flush();
    ErrorString.clear();
  }
 private:
  int ErrorCount;
  std::string ErrorString;
  raw_string_ostream Errors;
};

FunctionPass *createPNaClABIVerifyFunctionsPass(PNaClABIErrorReporter * Reporter);
ModulePass *createPNaClABIVerifyModulePass(PNaClABIErrorReporter * Reporter);

}


#endif