Mercurial > hg > CbC > CbC_llvm
comparison utils/not/not.cpp @ 0:95c75e76d11b LLVM3.4
LLVM 3.4
author | Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 12 Dec 2013 13:56:28 +0900 |
parents | |
children | 54457678186b |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:95c75e76d11b |
---|---|
1 //===- not.cpp - The 'not' testing tool -----------------------------------===// | |
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 #include "llvm/Support/Path.h" | |
11 #include "llvm/Support/Program.h" | |
12 #include "llvm/Support/raw_ostream.h" | |
13 using namespace llvm; | |
14 | |
15 int main(int argc, const char **argv) { | |
16 bool ExpectCrash = false; | |
17 | |
18 ++argv; | |
19 --argc; | |
20 | |
21 if (argc > 0 && StringRef(argv[0]) == "--crash") { | |
22 ++argv; | |
23 --argc; | |
24 ExpectCrash = true; | |
25 } | |
26 | |
27 if (argc == 0) | |
28 return 1; | |
29 | |
30 std::string Program = sys::FindProgramByName(argv[0]); | |
31 | |
32 std::string ErrMsg; | |
33 int Result = sys::ExecuteAndWait(Program, argv, 0, 0, 0, 0, &ErrMsg); | |
34 if (Result < 0) { | |
35 errs() << "Error: " << ErrMsg << "\n"; | |
36 if (ExpectCrash) | |
37 return 0; | |
38 return 1; | |
39 } | |
40 | |
41 if (ExpectCrash) | |
42 return 1; | |
43 | |
44 return Result == 0; | |
45 } |