blob: f174e72608e0c308ec5012b55e1002c1c8b3374d (
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
//===-- 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/CommandLine.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/raw_ostream.h"
#include <string>
namespace llvm {
class FunctionPass;
class ModulePass;
extern cl::opt<bool> PNaClABIAllowDebugMetadata;
class PNaClABIErrorReporter {
public:
PNaClABIErrorReporter() : ErrorCount(0), Errors(ErrorString),
UseFatalErrors(true) {}
// 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();
}
void setNonFatal() {
UseFatalErrors = false;
}
void checkForFatalErrors() {
if (UseFatalErrors && ErrorCount != 0) {
printErrors(errs());
report_fatal_error("PNaCl ABI verification failed");
}
}
private:
int ErrorCount;
std::string ErrorString;
raw_string_ostream Errors;
bool UseFatalErrors;
};
FunctionPass *createPNaClABIVerifyFunctionsPass(
PNaClABIErrorReporter *Reporter);
ModulePass *createPNaClABIVerifyModulePass(PNaClABIErrorReporter *Reporter,
bool StreamingMode = false);
}
#endif
|