Simplify a few uses of remove_filename by using parent_path instead.
authorRafael Espindola <rafael.espindola@gmail.com>
Wed, 15 Jul 2015 21:24:07 +0000 (21:24 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Wed, 15 Jul 2015 21:24:07 +0000 (21:24 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242334 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Object/Archive.cpp
lib/Support/Path.cpp
tools/lli/lli.cpp

index d4821196a6cf86a2de0dad1d43a5daeaf9b7be5f..a1e5eb2768957cab7345ae84c33bf8c2335cdf4d 100644 (file)
@@ -122,9 +122,8 @@ ErrorOr<StringRef> Archive::Child::getBuffer() const {
   ErrorOr<StringRef> Name = getName();
   if (std::error_code EC = Name.getError())
     return EC;
-  SmallString<128> FullName =
-      Parent->getMemoryBufferRef().getBufferIdentifier();
-  sys::path::remove_filename(FullName);
+  SmallString<128> FullName = sys::path::parent_path(
+      Parent->getMemoryBufferRef().getBufferIdentifier());
   sys::path::append(FullName, *Name);
   ErrorOr<std::unique_ptr<MemoryBuffer>> Buf = MemoryBuffer::getFile(FullName);
   if (std::error_code EC = Buf.getError())
index cf467381db8c47315f58aeb82e74a681fafccc29..75fd292e5b161dde3fb5fd6f18a44d866edbca07 100644 (file)
@@ -889,8 +889,7 @@ std::error_code is_other(const Twine &Path, bool &Result) {
 }
 
 void directory_entry::replace_filename(const Twine &filename, file_status st) {
-  SmallString<128> path(Path.begin(), Path.end());
-  path::remove_filename(path);
+  SmallString<128> path = path::parent_path(Path);
   path::append(path, filename);
   Path = path.str();
   Status = st;
index 057841f0ad604d4389aa73ae1822ad0dea361bed..949b444cc28169dde13962e91eafa34ac58b8c59 100644 (file)
@@ -262,8 +262,7 @@ public:
     if (!getCacheFilename(ModuleID, CacheName))
       return;
     if (!CacheDir.empty()) { // Create user-defined cache dir.
-      SmallString<128> dir(CacheName);
-      sys::path::remove_filename(dir);
+      SmallString<128> dir(sys::path::parent_path(CacheName));
       sys::fs::create_directories(Twine(dir));
     }
     std::error_code EC;