From 0738387d089d56d0be3a25d5a02bc6609a88bebf Mon Sep 17 00:00:00 2001 From: Anders Waldenborg Date: Thu, 17 Oct 2013 10:39:35 +0000 Subject: [PATCH] llvm-c: Don't assert in LLVMTargetMachineEmitToFile on nonexistent file Error handling code for raw_fd_ostream constructor is present, but never used, because formatted_raw_ostream will always assert on closed fd's before. Patch by Peter Zotov Differential Revision: http://llvm-reviews.chandlerc.com/D1909 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192881 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/TargetMachineC.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Target/TargetMachineC.cpp b/lib/Target/TargetMachineC.cpp index 9fccfcd9e22..2bb0f4c3e9a 100644 --- a/lib/Target/TargetMachineC.cpp +++ b/lib/Target/TargetMachineC.cpp @@ -205,11 +205,11 @@ LLVMBool LLVMTargetMachineEmitToFile(LLVMTargetMachineRef T, LLVMModuleRef M, char* Filename, LLVMCodeGenFileType codegen, char** ErrorMessage) { std::string error; raw_fd_ostream dest(Filename, error, sys::fs::F_Binary); - formatted_raw_ostream destf(dest); if (!error.empty()) { *ErrorMessage = strdup(error.c_str()); return true; } + formatted_raw_ostream destf(dest); bool Result = LLVMTargetMachineEmit(T, M, destf, codegen, ErrorMessage); dest.flush(); return Result;