[Lldb-commits] [PATCH] D92513: [lldb] Return the original path when tilde expansion fails.

Jonas Devlieghere via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed Dec 2 16:01:46 PST 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rGdcdd231df6c7: [lldb] Return the original path when tilde expansion fails. (authored by JDevlieghere).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92513

Files:
  lldb/source/Utility/TildeExpressionResolver.cpp
  lldb/unittests/Utility/TildeExpressionResolverTest.cpp


Index: lldb/unittests/Utility/TildeExpressionResolverTest.cpp
===================================================================
--- lldb/unittests/Utility/TildeExpressionResolverTest.cpp
+++ lldb/unittests/Utility/TildeExpressionResolverTest.cpp
@@ -31,6 +31,9 @@
   EXPECT_EQ("/lars", Result);
 
   ASSERT_FALSE(Resolver.ResolveFullPath("~Jaso", Result));
+  EXPECT_EQ("~Jaso", Result);
   ASSERT_FALSE(Resolver.ResolveFullPath("", Result));
+  EXPECT_EQ("", Result);
   ASSERT_FALSE(Resolver.ResolveFullPath("Jason", Result));
+  EXPECT_EQ("Jason", Result);
 }
Index: lldb/source/Utility/TildeExpressionResolver.cpp
===================================================================
--- lldb/source/Utility/TildeExpressionResolver.cpp
+++ lldb/source/Utility/TildeExpressionResolver.cpp
@@ -75,9 +75,8 @@
 
 bool TildeExpressionResolver::ResolveFullPath(
     StringRef Expr, llvm::SmallVectorImpl<char> &Output) {
-  Output.clear();
   if (!Expr.startswith("~")) {
-    Output.append(Expr.begin(), Expr.end());
+    Output.assign(Expr.begin(), Expr.end());
     return false;
   }
 
@@ -85,8 +84,10 @@
   StringRef Left =
       Expr.take_until([](char c) { return path::is_separator(c); });
 
-  if (!ResolveExact(Left, Output))
+  if (!ResolveExact(Left, Output)) {
+    Output.assign(Expr.begin(), Expr.end());
     return false;
+  }
 
   Output.append(Expr.begin() + Left.size(), Expr.end());
   return true;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D92513.309091.patch
Type: text/x-patch
Size: 1420 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20201203/bd25e3ea/attachment.bin>


More information about the lldb-commits mailing list