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).

llvm-svn: 222802
This commit is contained in:
Rui Ueyama 2014-11-26 01:45:24 +00:00
parent c50d64b07b
commit b12191aaf9
1 changed files with 2 additions and 7 deletions

View File

@ -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;