llvm-modextract: Call keep() on the output stream before exiting.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@288435 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Peter Collingbourne 2016-12-01 23:13:11 +00:00
parent c31c930cdf
commit a11b564b77
2 changed files with 7 additions and 0 deletions

View File

@ -4,6 +4,11 @@
; RUN: llvm-modextract -b -n 0 -o - %t | llvm-dis | FileCheck %s
; RUN: not llvm-modextract -b -n 1 -o - %t 2>&1 | FileCheck --check-prefix=ERROR %s
; RUN: llvm-modextract -n 0 -o %t0 %t
; RUN: llvm-dis -o - %t0 | FileCheck %s
; RUN: llvm-modextract -b -n 0 -o %t1 %t
; RUN: llvm-dis -o - %t1 | FileCheck %s
; CHECK: define void @f()
; ERROR: llvm-modextract: error: module index out of range; bitcode file contains 1 module(s)

View File

@ -62,11 +62,13 @@ int main(int argc, char **argv) {
SmallVector<char, 0> Header;
BitcodeWriter Writer(Header);
Out->os() << Header << Ms[ModuleIndex].getBuffer();
Out->keep();
return 0;
}
std::unique_ptr<Module> M = ExitOnErr(Ms[ModuleIndex].parseModule(Context));
WriteBitcodeToFile(M.get(), Out->os());
Out->keep();
return 0;
}