[PATCH] D65675: [Path] Fix bug in make_absolute logic

Jonas Devlieghere via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 6 08:48:25 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL368053: [Path] Fix bug in make_absolute logic (authored by JDevlieghere, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D65675?vs=213397&id=213625#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65675/new/

https://reviews.llvm.org/D65675

Files:
  llvm/trunk/lib/Support/Path.cpp
  llvm/trunk/unittests/Support/Path.cpp


Index: llvm/trunk/lib/Support/Path.cpp
===================================================================
--- llvm/trunk/lib/Support/Path.cpp
+++ llvm/trunk/lib/Support/Path.cpp
@@ -855,11 +855,11 @@
   StringRef p(path.data(), path.size());
 
   bool rootDirectory = path::has_root_directory(p);
-  bool rootName =
-      (real_style(Style::native) != Style::windows) || path::has_root_name(p);
+  bool rootName = path::has_root_name(p);
 
   // Already absolute.
-  if (rootName && rootDirectory)
+  if ((rootName || real_style(Style::native) != Style::windows) &&
+      rootDirectory)
     return;
 
   // All of the following conditions will need the current directory.
Index: llvm/trunk/unittests/Support/Path.cpp
===================================================================
--- llvm/trunk/unittests/Support/Path.cpp
+++ llvm/trunk/unittests/Support/Path.cpp
@@ -185,10 +185,19 @@
     path::native(*i, temp_store);
   }
 
-  SmallString<32> Relative("foo.cpp");
-  sys::fs::make_absolute("/root", Relative);
-  Relative[5] = '/'; // Fix up windows paths.
-  ASSERT_EQ("/root/foo.cpp", Relative);
+  {
+    SmallString<32> Relative("foo.cpp");
+    sys::fs::make_absolute("/root", Relative);
+    Relative[5] = '/'; // Fix up windows paths.
+    ASSERT_EQ("/root/foo.cpp", Relative);
+  }
+
+  {
+    SmallString<32> Relative("foo.cpp");
+    sys::fs::make_absolute("//root", Relative);
+    Relative[6] = '/'; // Fix up windows paths.
+    ASSERT_EQ("//root/foo.cpp", Relative);
+  }
 }
 
 TEST(Support, FilenameParent) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D65675.213625.patch
Type: text/x-patch
Size: 1537 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190806/9b8c2511/attachment.bin>


More information about the llvm-commits mailing list