[llvm] r184802 - Cleanup in unique_file when we only want the name.

Rafael Espindola rafael.espindola at gmail.com
Mon Jun 24 17:49:40 PDT 2013


Author: rafael
Date: Mon Jun 24 19:49:40 2013
New Revision: 184802

URL: http://llvm.org/viewvc/llvm-project?rev=184802&view=rev
Log:
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.

Modified:
    llvm/trunk/lib/Support/PathV2.cpp

Modified: llvm/trunk/lib/Support/PathV2.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/PathV2.cpp?rev=184802&r1=184801&r2=184802&view=diff
==============================================================================
--- llvm/trunk/lib/Support/PathV2.cpp (original)
+++ llvm/trunk/lib/Support/PathV2.cpp Mon Jun 24 19:49:40 2013
@@ -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) {





More information about the llvm-commits mailing list