[lld] r222802 - Use SafelyCloseFileDescriptor instead of close.
Rui Ueyama
ruiu at google.com
Tue Nov 25 17:45:24 PST 2014
Author: ruiu
Date: Tue Nov 25 19:45:24 2014
New Revision: 222802
URL: http://llvm.org/viewvc/llvm-project?rev=222802&view=rev
Log:
Use SafelyCloseFileDescriptor instead of close.
Opening a file using openFileForWrite and closing it using close
was asymmetric. It also had a subtle portability problem (details are
described in the commit message for r219189).
Modified:
lld/trunk/lib/ReaderWriter/PECOFF/PDBPass.h
Modified: lld/trunk/lib/ReaderWriter/PECOFF/PDBPass.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/PDBPass.h?rev=222802&r1=222801&r2=222802&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/PDBPass.h (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/PDBPass.h Tue Nov 25 19:45:24 2014
@@ -12,12 +12,7 @@
#include "lld/Core/Pass.h"
#include "llvm/ADT/StringRef.h"
-
-#if !defined(_MSC_VER) && !defined(__MINGW32__)
-#include <unistd.h>
-#else
-#include <io.h>
-#endif
+#include "llvm/Support/Process.h"
namespace lld {
namespace pecoff {
@@ -36,7 +31,7 @@ private:
int fd;
if (llvm::sys::fs::openFileForWrite(path, fd, llvm::sys::fs::F_Append))
llvm::report_fatal_error("failed to create a PDB file");
- ::close(fd);
+ llvm::sys::Process::SafelyCloseFileDescriptor(fd);
}
PECOFFLinkingContext &_ctx;
More information about the llvm-commits
mailing list