mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-25 12:12:47 +01:00
[llvm-reduce] Exit when input module is malformed
The parseInputFile function returns an empty unique_ptr to signal an error, like when the input file doesn't exist, or is malformed. In this case, the tool should exit immediately rather than segfault by dereferencing the unique_ptr later. Reviewed By: aeubanks Differential Revision: https://reviews.llvm.org/D102891
This commit is contained in:
parent
e66c9141ae
commit
874da3772d
5
test/tools/llvm-reduce/fail-file-open.test
Normal file
5
test/tools/llvm-reduce/fail-file-open.test
Normal file
@ -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:
|
@ -116,6 +116,10 @@ int main(int Argc, char **Argv) {
|
|||||||
std::unique_ptr<Module> OriginalProgram =
|
std::unique_ptr<Module> OriginalProgram =
|
||||||
parseInputFile(InputFilename, Context);
|
parseInputFile(InputFilename, Context);
|
||||||
|
|
||||||
|
if (!OriginalProgram) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
// Initialize test environment
|
// Initialize test environment
|
||||||
TestRunner Tester(TestFilename, TestArguments);
|
TestRunner Tester(TestFilename, TestArguments);
|
||||||
Tester.setProgram(std::move(OriginalProgram));
|
Tester.setProgram(std::move(OriginalProgram));
|
||||||
|
Loading…
Reference in New Issue
Block a user