From: Rafael Espindola Date: Fri, 5 Jul 2013 02:50:03 +0000 (+0000) Subject: Add a --crash option to not. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=91487584c9bf7cdfe8560f7a8e118a6abd1fd9e8;p=platform%2Fupstream%2Fllvm.git Add a --crash option to not. Now the two possible uses of not are * not cmd Will return true if cmd doesn't crash and returns false. * not --crash cmd Will return true if cmd crashes. It will be used/tested in a followup commit for the clang crash recovery testing. llvm-svn: 185678 --- diff --git a/llvm/utils/not/not.cpp b/llvm/utils/not/not.cpp index 13803dc..ebd1618 100644 --- a/llvm/utils/not/not.cpp +++ b/llvm/utils/not/not.cpp @@ -13,14 +13,33 @@ using namespace llvm; int main(int argc, const char **argv) { - std::string Program = sys::FindProgramByName(argv[1]); + bool ExpectCrash = false; + + ++argv; + --argc; + + if (argc > 0 && StringRef(argv[0]) == "--crash") { + ++argv; + --argc; + ExpectCrash = true; + } + + if (argc == 0) + return 1; + + std::string Program = sys::FindProgramByName(argv[0]); std::string ErrMsg; - int Result = sys::ExecuteAndWait(Program, argv + 1, 0, 0, 0, 0, &ErrMsg); + int Result = sys::ExecuteAndWait(Program, argv, 0, 0, 0, 0, &ErrMsg); if (Result < 0) { errs() << "Error: " << ErrMsg << "\n"; + if (ExpectCrash) + return 0; return 1; } + if (ExpectCrash) + return 1; + return Result == 0; }