[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 15:14:10 PST 2020


JDevlieghere updated this revision to Diff 309073.
JDevlieghere added a comment.

Use `SmallVector::assign`


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

https://reviews.llvm.org/D92513

Files:
  lldb/source/Utility/TildeExpressionResolver.cpp


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.309073.patch
Type: text/x-patch
Size: 855 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20201202/70ed1557/attachment.bin>


More information about the lldb-commits mailing list