Mercurial > hg > CbC > CbC_llvm
comparison utils/not/not.cpp @ 83:60c9769439b8 LLVM3.7
LLVM 3.7
author | Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 18 Feb 2015 14:55:36 +0900 |
parents | 54457678186b |
children | 803732b1fca8 |
comparison
equal
deleted
inserted
replaced
78:af83660cff7b | 83:60c9769439b8 |
---|---|
4 // | 4 // |
5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
7 // | 7 // |
8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
9 // Usage: | |
10 // not cmd | |
11 // Will return true if cmd doesn't crash and returns false. | |
12 // not --crash cmd | |
13 // Will return true if cmd crashes (e.g. for testing crash reporting). | |
9 | 14 |
10 #include "llvm/Support/Path.h" | 15 #include "llvm/Support/Path.h" |
11 #include "llvm/Support/Program.h" | 16 #include "llvm/Support/Program.h" |
12 #include "llvm/Support/raw_ostream.h" | 17 #include "llvm/Support/raw_ostream.h" |
13 using namespace llvm; | 18 using namespace llvm; |
25 } | 30 } |
26 | 31 |
27 if (argc == 0) | 32 if (argc == 0) |
28 return 1; | 33 return 1; |
29 | 34 |
30 std::string Program = sys::FindProgramByName(argv[0]); | 35 auto Program = sys::findProgramByName(argv[0]); |
36 if (!Program) { | |
37 errs() << "Error: Unable to find `" << argv[0] | |
38 << "' in PATH: " << Program.getError().message() << "\n"; | |
39 return 1; | |
40 } | |
31 | 41 |
32 std::string ErrMsg; | 42 std::string ErrMsg; |
33 int Result = sys::ExecuteAndWait(Program, argv, nullptr, nullptr, 0, 0, | 43 int Result = sys::ExecuteAndWait(*Program, argv, nullptr, nullptr, 0, 0, |
34 &ErrMsg); | 44 &ErrMsg); |
35 #ifdef _WIN32 | 45 #ifdef _WIN32 |
36 // Handle abort() in msvcrt -- It has exit code as 3. abort(), aka | 46 // Handle abort() in msvcrt -- It has exit code as 3. abort(), aka |
37 // unreachable, should be recognized as a crash. However, some binaries use | 47 // unreachable, should be recognized as a crash. However, some binaries use |
38 // exit code 3 on non-crash failure paths, so only do this if we expect a | 48 // exit code 3 on non-crash failure paths, so only do this if we expect a |