diff options
| author | Derek Schuff <dschuff@chromium.org> | 2013-03-13 16:04:03 -0700 |
|---|---|---|
| committer | Derek Schuff <dschuff@chromium.org> | 2013-03-13 16:04:03 -0700 |
| commit | cb0dcd0adf5e43486154d143da30710fee0da301 (patch) | |
| tree | ad15b68cc4fc5765c130b5a0dba25d564a21404d /include | |
| parent | 79da56afe68a0c5b2c2227681014dd13705d78cc (diff) | |
ABI verifier: Add standalone tool pnacl-abicheck
This CL adds a standalone tool pnacl-abicheck for checking the ABI validity of a bitcode file.
It also adds a flag pnaclabi-verify to llc to enable the same checking in llc.
It also improves the mechanism for handling and reporting validation errors and uses it in both tools.
R=jvoung@chromium.org,mseaborn@chromium.org
BUG= https://code.google.com/p/nativeclient/issues/detail?id=2309
Review URL: https://codereview.chromium.org/12449014
Diffstat (limited to 'include')
| -rw-r--r-- | include/llvm/Analysis/NaCl.h | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/include/llvm/Analysis/NaCl.h b/include/llvm/Analysis/NaCl.h index 8e599594b2..a8f2c9651e 100644 --- a/include/llvm/Analysis/NaCl.h +++ b/include/llvm/Analysis/NaCl.h @@ -10,13 +10,44 @@ #ifndef LLVM_ANALYSIS_NACL_H #define LLVM_ANALYSIS_NACL_H +#include "llvm/Support/raw_ostream.h" +#include <string> + namespace llvm { class FunctionPass; class ModulePass; -FunctionPass *createPNaClABIVerifyFunctionsPass(); -ModulePass *createPNaClABIVerifyModulePass(); +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); } |
