[PATCH] D102891: [llvm-reduce] Exit when input module is malformed
Langston Barrett via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri May 21 10:28:08 PDT 2021
langston-barrett updated this revision to Diff 347075.
langston-barrett added a comment.
Add a test case
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D102891/new/
https://reviews.llvm.org/D102891
Files:
llvm/test/tools/llvm-reduce/fail-file-open.test
llvm/tools/llvm-reduce/llvm-reduce.cpp
Index: llvm/tools/llvm-reduce/llvm-reduce.cpp
===================================================================
--- llvm/tools/llvm-reduce/llvm-reduce.cpp
+++ llvm/tools/llvm-reduce/llvm-reduce.cpp
@@ -116,6 +116,10 @@
std::unique_ptr<Module> OriginalProgram =
parseInputFile(InputFilename, Context);
+ if (!OriginalProgram) {
+ return 1;
+ }
+
// Initialize test environment
TestRunner Tester(TestFilename, TestArguments);
Tester.setProgram(std::move(OriginalProgram));
Index: llvm/test/tools/llvm-reduce/fail-file-open.test
===================================================================
--- /dev/null
+++ llvm/test/tools/llvm-reduce/fail-file-open.test
@@ -0,0 +1,5 @@
+# RUN: not llvm-reduce --test=echo %s.NotAFileInTestingDir 2>&1 | FileCheck %s
+
+This file will not be read. An invalid file path is fed to llvm-reduce.
+
+# CHECK: llvm-reduce: {{.*}}.NotAFileInTestingDir: error: Could not open input file: No such file or directory
\ No newline at end of file
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D102891.347075.patch
Type: text/x-patch
Size: 1001 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210521/28723e1b/attachment.bin>
More information about the llvm-commits
mailing list