summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorMichael J. Spencer <bigcheesegs@gmail.com>2012-03-21 23:09:14 +0000
committerMichael J. Spencer <bigcheesegs@gmail.com>2012-03-21 23:09:14 +0000
commit39fb408fd3ce922dc302e18eec10e07db3edfe6b (patch)
tree04d7204b97bb864f2a3620f8c69f92680358a5f0 /llvm/lib
parent1c76f15aa77033a61e548dd6de3e5e0c79c7063f (diff)
downloadbcm5719-llvm-39fb408fd3ce922dc302e18eec10e07db3edfe6b.tar.gz
bcm5719-llvm-39fb408fd3ce922dc302e18eec10e07db3edfe6b.zip
[PathV2]: Fix bug in create_directories which caused infinite recursion on
som inputs. Bug found and fix proposed by Kal Conley! llvm-svn: 153225
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Support/PathV2.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/llvm/lib/Support/PathV2.cpp b/llvm/lib/Support/PathV2.cpp
index 786e1a12c30..e2a69a650db 100644
--- a/llvm/lib/Support/PathV2.cpp
+++ b/llvm/lib/Support/PathV2.cpp
@@ -654,12 +654,13 @@ error_code create_directories(const Twine &path, bool &existed) {
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);
}
OpenPOWER on IntegriCloud