[Lldb-commits] [PATCH] D146779: Fix handling of backticks in CommandObjectParsed commands

Jonas Devlieghere via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Mar 23 19:11:09 PDT 2023


JDevlieghere accepted this revision.
JDevlieghere added a comment.
This revision is now accepted and ready to land.

LGTM



================
Comment at: lldb/source/Interpreter/CommandInterpreter.cpp:1754-1760
+    if (error.Success()) {
+      command.erase(start_backtick, end_backtick - start_backtick + 1);
+      command.insert(start_backtick, std::string(expr_str));
+      pos = start_backtick + expr_str.size();
+      continue;
+    } else
+      break;
----------------
You could avoid a level of indentation and a continue if you invert the condition. 


================
Comment at: lldb/source/Interpreter/CommandObject.cpp:729-738
     for (auto entry : llvm::enumerate(cmd_args.entries())) {
       if (!entry.value().ref().empty() && entry.value().GetQuoteChar() == '`') {
-        cmd_args.ReplaceArgumentAtIndex(
-            entry.index(),
-            m_interpreter.ProcessEmbeddedScriptCommands(entry.value().c_str()));
+        // We have to put the backtick back in place for PreprocessCommand.
+        std::string opt_string = entry.value().c_str();
+        Status error;
+        error = m_interpreter.PreprocessToken(opt_string);
+        if (error.Success())
----------------
There's a lot of `entry.value()` repetition here, might be worth extracting a temporary value here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146779



More information about the lldb-commits mailing list