[Lldb-commits] [PATCH] D26081: Improve ".." handling in FileSpec normalization

Adrian McCarthy via lldb-commits lldb-commits at lists.llvm.org
Fri Oct 28 09:00:26 PDT 2016


amccarth added inline comments.


================
Comment at: source/Host/common/FileSpec.cpp:550
+      (m_filename.GetStringRef() != ".." && m_filename.GetStringRef() != "."))
+    return *this;
 
----------------
Do we have to worry about an unnecessary single dot in the directory, like `/foo/./bar/`?  Are those handled when the FileSpec is constructed?


================
Comment at: source/Host/common/FileSpec.cpp:576
+    if (component == ".")
+      continue; // Skip these.
+    if (component != "..") {
----------------
Ah, here we're skipping the unnecessary single dots, but the short-circuit at the top would prevent us from getting here unless the directory also contained a `/..`.


================
Comment at: unittests/Host/FileSpecTest.cpp:144
       {R"(C:\bar)", R"(C:\foo\..\bar)"},
   };
 
----------------
How about a test to make sure `C:/foo/./bar` is the same as `C:/foo/bar`?


================
Comment at: unittests/Host/FileSpecTest.cpp:212
+      {"foo/../bar", "bar"},
+      {"../foo/..", ".."},
+  };
----------------
Here, too, I'd like to see test cases for paths with single dots.


https://reviews.llvm.org/D26081





More information about the lldb-commits mailing list