Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(73)

Side by Side Diff: tools/pnacl-abicheck/pnacl-abicheck.cpp

Issue 12449014: ABI verifier: Add standalone tool pnacl-abicheck (Closed) Base URL: http://git.chromium.org/native_client/pnacl-llvm.git@master
Patch Set: cleanup, use << for error streams uniformly Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/pnacl-abicheck/Makefile ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 //===-- pnacl-abicheck.cpp - Check PNaCl bitcode ABI ----------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This tool checks files for compliance with the PNaCl bitcode ABI
11 //
12 //===----------------------------------------------------------------------===//
13
14 #include "llvm/ADT/OwningPtr.h"
15 #include "llvm/Analysis/NaCl.h"
16 #include "llvm/IR/LLVMContext.h"
17 #include "llvm/IR/Module.h"
18 #include "llvm/Pass.h"
19 #include "llvm/Support/CommandLine.h"
20 #include "llvm/Support/FormattedStream.h"
21 #include "llvm/Support/IRReader.h"
22 #include <string>
23
24 using namespace llvm;
25
26 static cl::opt<std::string>
27 InputFilename(cl::Positional, cl::desc("<input bitcode>"), cl::init("-"));
28
29 static void CheckABIVerifyErrors(PNaClABIErrorReporter &Reporter,
30 const Twine &Name) {
31 if (Reporter.getErrorCount() > 0) {
32 errs() << "ERROR: " << Name << " is not valid PNaCl bitcode:\n";
33 Reporter.printErrors(errs());
34 }
35 Reporter.reset();
36 }
37
38 int main(int argc, char **argv) {
39 LLVMContext &Context = getGlobalContext();
40 SMDiagnostic Err;
41 OwningPtr<Module> Mod(ParseIRFile(InputFilename, Err, Context));
42 if (Mod.get() == 0) {
43 Err.print(argv[0], errs());
44 return 1;
45 }
46 PNaClABIErrorReporter ABIErrorReporter;
47 // Manually run the passes so we can tell the user which function had the
48 // error. No need for a pass manager since it's just one pass.
49 ModulePass *ModuleChecker = createPNaClABIVerifyModulePass(&ABIErrorReporter);
50 ModuleChecker->runOnModule(*Mod);
51 CheckABIVerifyErrors(ABIErrorReporter, "Module");
52 FunctionPass *FunctionChecker =
53 createPNaClABIVerifyFunctionsPass(&ABIErrorReporter);
54 for (Module::iterator MI = Mod->begin(), ME = Mod->end(); MI != ME; ++MI) {
55 FunctionChecker->runOnFunction(*MI);
56 CheckABIVerifyErrors(ABIErrorReporter, "Function " + MI->getName());
57 }
58
59 return 0;
60 }
OLDNEW
« no previous file with comments | « tools/pnacl-abicheck/Makefile ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698