summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2014-11-26 00:21:27 +0000
committerRui Ueyama <ruiu@google.com>2014-11-26 00:21:27 +0000
commit65e0ca1bde51c2ea2bf126539dbb11b728090340 (patch)
treece9f4bd1e69d096d728552caf6eac97fdeca4d3c
parent659be55daa7644777e5379a127543942d3dc954d (diff)
downloadbcm5719-llvm-65e0ca1bde51c2ea2bf126539dbb11b728090340.tar.gz
bcm5719-llvm-65e0ca1bde51c2ea2bf126539dbb11b728090340.zip
[PECOFF] Properly close a file descriptor.
This was basically benign resource leak on Unix, but on Windows it could cause builds to fail because opened file descriptor prevents other processes from moving or removing the file. llvm-svn: 222799
-rw-r--r--lld/lib/ReaderWriter/PECOFF/PDBPass.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/lld/lib/ReaderWriter/PECOFF/PDBPass.h b/lld/lib/ReaderWriter/PECOFF/PDBPass.h
index 92199c9a952..0f7b2926d0b 100644
--- a/lld/lib/ReaderWriter/PECOFF/PDBPass.h
+++ b/lld/lib/ReaderWriter/PECOFF/PDBPass.h
@@ -13,6 +13,12 @@
#include "lld/Core/Pass.h"
#include "llvm/ADT/StringRef.h"
+#if !defined(_MSC_VER) && !defined(__MINGW32__)
+#include <unistd.h>
+#else
+#include <io.h>
+#endif
+
namespace lld {
namespace pecoff {
@@ -30,6 +36,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);
}
PECOFFLinkingContext &_ctx;
OpenPOWER on IntegriCloud