summaryrefslogtreecommitdiff
path: root/tools/llvm-ar
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2013-07-16 16:00:32 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2013-07-16 16:00:32 +0000
commit95779b65cf7b7d7c22bf2d22d03c661c8130cbe2 (patch)
treee0862520042c2d69ac771d906150b27bf122773e /tools/llvm-ar
parent21508bf853354343266dbe6d830ff30bed006a68 (diff)
downloadllvm-95779b65cf7b7d7c22bf2d22d03c661c8130cbe2.tar.gz
llvm-95779b65cf7b7d7c22bf2d22d03c661c8130cbe2.tar.bz2
llvm-95779b65cf7b7d7c22bf2d22d03c661c8130cbe2.tar.xz
On error, close the temporary file descriptor.
With this change llvm-ar can remove the temporary file on windows too. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186423 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-ar')
-rw-r--r--tools/llvm-ar/llvm-ar.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/tools/llvm-ar/llvm-ar.cpp b/tools/llvm-ar/llvm-ar.cpp
index 32bcb49a1d..d65f9ecc9f 100644
--- a/tools/llvm-ar/llvm-ar.cpp
+++ b/tools/llvm-ar/llvm-ar.cpp
@@ -41,10 +41,13 @@ using namespace llvm;
static StringRef ToolName;
static const char *TemporaryOutput;
+static int TmpArchiveFD = -1;
// fail - Show the error message and exit.
LLVM_ATTRIBUTE_NORETURN static void fail(Twine Error) {
outs() << ToolName << ": " << Error << ".\n";
+ if (TmpArchiveFD != -1)
+ close(TmpArchiveFD);
if (TemporaryOutput)
sys::fs::remove(TemporaryOutput);
exit(1);
@@ -526,7 +529,6 @@ static void printWithSpacePadding(raw_ostream &OS, T Data, unsigned Size) {
static void performWriteOperation(ArchiveOperation Operation,
object::Archive *OldArchive) {
- int TmpArchiveFD;
SmallString<128> TmpArchive;
failIfError(sys::fs::createUniqueFile(ArchiveName + ".temp-archive-%%%%%%%.a",
TmpArchiveFD, TmpArchive));