[PATCH] C API: don't assert in LLVMTargetMachineEmitToFile on nonexistent file
Peter Zotov
whitequark at whitequark.org
Sat Oct 12 08:49:40 PDT 2013
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.
http://llvm-reviews.chandlerc.com/D1909
Files:
lib/Target/TargetMachineC.cpp
Index: lib/Target/TargetMachineC.cpp
===================================================================
--- lib/Target/TargetMachineC.cpp
+++ lib/Target/TargetMachineC.cpp
@@ -207,15 +207,18 @@
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;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D1909.1.patch
Type: text/x-patch
Size: 719 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131012/6ff896cf/attachment.bin>
More information about the llvm-commits
mailing list