summaryrefslogtreecommitdiff
path: root/utils/not/not.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'utils/not/not.cpp')
-rw-r--r--utils/not/not.cpp23
1 files changed, 21 insertions, 2 deletions
diff --git a/utils/not/not.cpp b/utils/not/not.cpp
index 13803dc867..ebd16189c9 100644
--- a/utils/not/not.cpp
+++ b/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;
}