Mercurial > hg > CbC > CbC_llvm
diff 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 |
line wrap: on
line diff
--- a/utils/not/not.cpp Mon Sep 08 22:07:30 2014 +0900 +++ b/utils/not/not.cpp Wed Feb 18 14:55:36 2015 +0900 @@ -6,6 +6,11 @@ // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// +// Usage: +// not cmd +// Will return true if cmd doesn't crash and returns false. +// not --crash cmd +// Will return true if cmd crashes (e.g. for testing crash reporting). #include "llvm/Support/Path.h" #include "llvm/Support/Program.h" @@ -27,10 +32,15 @@ if (argc == 0) return 1; - std::string Program = sys::FindProgramByName(argv[0]); + auto Program = sys::findProgramByName(argv[0]); + if (!Program) { + errs() << "Error: Unable to find `" << argv[0] + << "' in PATH: " << Program.getError().message() << "\n"; + return 1; + } std::string ErrMsg; - int Result = sys::ExecuteAndWait(Program, argv, nullptr, nullptr, 0, 0, + int Result = sys::ExecuteAndWait(*Program, argv, nullptr, nullptr, 0, 0, &ErrMsg); #ifdef _WIN32 // Handle abort() in msvcrt -- It has exit code as 3. abort(), aka