Index: lldb/source/Utility/TildeExpressionResolver.cpp =================================================================== --- lldb/source/Utility/TildeExpressionResolver.cpp +++ lldb/source/Utility/TildeExpressionResolver.cpp @@ -73,11 +73,15 @@ #endif } +static void Assign(llvm::StringRef s, llvm::SmallVectorImpl &v) { + v.clear(); + v.append(s.begin(), s.end()); +} + bool TildeExpressionResolver::ResolveFullPath( StringRef Expr, llvm::SmallVectorImpl &Output) { - Output.clear(); if (!Expr.startswith("~")) { - Output.append(Expr.begin(), Expr.end()); + Assign(Expr, Output); return false; } @@ -85,8 +89,10 @@ StringRef Left = Expr.take_until([](char c) { return path::is_separator(c); }); - if (!ResolveExact(Left, Output)) + if (!ResolveExact(Left, Output)) { + Assign(Expr, Output); return false; + } Output.append(Expr.begin() + Left.size(), Expr.end()); return true;