[Lldb-commits] [PATCH] D46783: FileSpec objects that resolve to "." should have "." in m_filename and m_directory empty.

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Thu May 17 10:09:27 PDT 2018


This has broken the unit tests. Looks like a bad merge that did not take
into account the refactoring in r332088.
On Thu, 17 May 2018 at 17:16, Phabricator via Phabricator <
reviews at reviews.llvm.org> wrote:

> This revision was automatically updated to reflect the committed changes.
> Closed by commit rL332618: FileSpec objects that resolve to "."
should have "." in m_filename and… (authored by gclayton,
committed by ).
> Herald added a subscriber: llvm-commits.

> Changed prior to commit:
>     https://reviews.llvm.org/D46783?vs=146434&id=147329#toc

> Repository:
>     rL LLVM

> https://reviews.llvm.org/D46783

> Files:
>     lldb/trunk/source/Utility/FileSpec.cpp
>     lldb/trunk/unittests/Utility/FileSpecTest.cpp


> Index: lldb/trunk/unittests/Utility/FileSpecTest.cpp
> ===================================================================
> --- lldb/trunk/unittests/Utility/FileSpecTest.cpp
> +++ lldb/trunk/unittests/Utility/FileSpecTest.cpp
> @@ -199,9 +199,10 @@
>          {"/..", "/"},
>          {"/.", "/"},
>          {"..", ".."},
> -      {".", ""},
> +      {".", "."},
> +      {"", "."},
>          {"../..", "../.."},
> -      {"foo/..", ""},
> +      {"foo/..", "."},
>          {"foo/../bar", "bar"},
>          {"../foo/..", ".."},
>          {"./foo", "foo"},
> @@ -230,17 +231,18 @@
>          {R"(\..)", R"(\..)"},
>          //      {R"(c:..)", R"(c:..)"},
>          {R"(..)", R"(..)"},
> -      {R"(.)", R"()"},
> +      {R"(.)", R"(.)"},
>          // TODO: fix llvm::sys::path::remove_dots() to return "c:\" below.
>          {R"(c:..\..)", R"(c:\..\..)"},
>          {R"(..\..)", R"(..\..)"},
> -      {R"(foo\..)", R"()"},
> +      {R"(foo\..)", R"(.)"},
>          {R"(foo\..\bar)", R"(bar)"},
>          {R"(..\foo\..)", R"(..)"},
>          {R"(.\foo)", R"(foo)"},
>          {R"(.\.\foo)", R"(foo)"},
>          {R"(..\foo)", R"(..\foo)"},
>          {R"(..\..\foo)", R"(..\..\foo)"},
> +      {"", "."},
>      };
>      for (auto test : windows_tests) {
>        EXPECT_EQ(test.second,
> Index: lldb/trunk/source/Utility/FileSpec.cpp
> ===================================================================
> --- lldb/trunk/source/Utility/FileSpec.cpp
> +++ lldb/trunk/source/Utility/FileSpec.cpp
> @@ -258,6 +258,14 @@
>      if (m_style == Style::windows)
>        std::replace(resolved.begin(), resolved.end(), '\\', '/');

> +  if (resolved.empty()) {
> +    // If we have no path after normalization set the path to the current
> +    // directory. This matches what python does and also a few other path
> +    // utilities.
> +    m_filename.SetString(".");
> +    return;
> +  }
> +
>      m_filename.SetString(llvm::sys::path::filename(resolved, m_style));
>      llvm::StringRef dir = llvm::sys::path::parent_path(resolved, m_style);
>      if (!dir.empty())


More information about the lldb-commits mailing list