[llvm] r242334 - Simplify a few uses of remove_filename by using parent_path instead.

Rafael Espindola rafael.espindola at gmail.com
Wed Jul 15 14:24:08 PDT 2015


Author: rafael
Date: Wed Jul 15 16:24:07 2015
New Revision: 242334

URL: http://llvm.org/viewvc/llvm-project?rev=242334&view=rev
Log:
Simplify a few uses of remove_filename by using parent_path instead.

Modified:
    llvm/trunk/lib/Object/Archive.cpp
    llvm/trunk/lib/Support/Path.cpp
    llvm/trunk/tools/lli/lli.cpp

Modified: llvm/trunk/lib/Object/Archive.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/Archive.cpp?rev=242334&r1=242333&r2=242334&view=diff
==============================================================================
--- llvm/trunk/lib/Object/Archive.cpp (original)
+++ llvm/trunk/lib/Object/Archive.cpp Wed Jul 15 16:24:07 2015
@@ -122,9 +122,8 @@ ErrorOr<StringRef> Archive::Child::getBu
   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())

Modified: llvm/trunk/lib/Support/Path.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Path.cpp?rev=242334&r1=242333&r2=242334&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Path.cpp (original)
+++ llvm/trunk/lib/Support/Path.cpp Wed Jul 15 16:24:07 2015
@@ -889,8 +889,7 @@ std::error_code is_other(const Twine &Pa
 }
 
 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;

Modified: llvm/trunk/tools/lli/lli.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lli/lli.cpp?rev=242334&r1=242333&r2=242334&view=diff
==============================================================================
--- llvm/trunk/tools/lli/lli.cpp (original)
+++ llvm/trunk/tools/lli/lli.cpp Wed Jul 15 16:24:07 2015
@@ -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;





More information about the llvm-commits mailing list