summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2013-06-25 00:49:40 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2013-06-25 00:49:40 +0000
commit8ba825e2ea09ec16e9cab3525ed3d7c6145123a5 (patch)
tree0e2a153f45deed83617cdd6b4541d6fbc5cf925e /lib
parenta619be811cbbd96a4cb550ab660a3ae427cf7197 (diff)
downloadllvm-8ba825e2ea09ec16e9cab3525ed3d7c6145123a5.tar.gz
llvm-8ba825e2ea09ec16e9cab3525ed3d7c6145123a5.tar.bz2
llvm-8ba825e2ea09ec16e9cab3525ed3d7c6145123a5.tar.xz
Cleanup in unique_file when we only want the name.
This is really ugly, but it is no worse than what we have in clang right now and it is better to get it working first and clean/optimize it afterwards. Will be tested from clang in the next patch. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184802 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Support/PathV2.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/Support/PathV2.cpp b/lib/Support/PathV2.cpp
index 0e02953c54..cc654eea58 100644
--- a/lib/Support/PathV2.cpp
+++ b/lib/Support/PathV2.cpp
@@ -627,10 +627,18 @@ namespace fs {
error_code unique_file(const Twine &Model, SmallVectorImpl<char> &ResultPath,
bool MakeAbsolute, unsigned Mode) {
+ // FIXME: This is really inefficient. unique_path creates a path an tries to
+ // open it. We should factor the code so that we just don't create/open the
+ // file when we don't need it.
int FD;
error_code Ret = unique_file(Model, FD, ResultPath, MakeAbsolute, Mode);
- close(FD);
- return Ret;
+ if (Ret)
+ return Ret;
+
+ if (close(FD))
+ return error_code(errno, system_category());
+
+ return fs::remove(ResultPath.begin());
}
error_code make_absolute(SmallVectorImpl<char> &path) {