[llvm-commits] [llvm] r153225 - /llvm/trunk/lib/Support/PathV2.cpp

Michael J. Spencer bigcheesegs at gmail.com
Wed Mar 21 16:09:14 PDT 2012


Author: mspencer
Date: Wed Mar 21 18:09:14 2012
New Revision: 153225

URL: http://llvm.org/viewvc/llvm-project?rev=153225&view=rev
Log:
[PathV2]: Fix bug in create_directories which caused infinite recursion on
som inputs.

Bug found and fix proposed by Kal Conley!

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=153225&r1=153224&r2=153225&view=diff
==============================================================================
--- llvm/trunk/lib/Support/PathV2.cpp (original)
+++ llvm/trunk/lib/Support/PathV2.cpp Wed Mar 21 18:09:14 2012
@@ -654,12 +654,13 @@
   StringRef p = path.toStringRef(path_storage);
 
   StringRef parent = path::parent_path(p);
-  bool parent_exists;
+  if (!parent.empty()) {
+    bool parent_exists;
+    if (error_code ec = fs::exists(parent, parent_exists)) return ec;
 
-  if (error_code ec = fs::exists(parent, parent_exists)) return ec;
-
-  if (!parent_exists)
-    if (error_code ec = create_directories(parent, existed)) return ec;
+    if (!parent_exists)
+      if (error_code ec = create_directories(parent, existed)) return ec;
+  }
 
   return create_directory(p, existed);
 }





More information about the llvm-commits mailing list