[Lldb-commits] [PATCH] D49963: Preliminary patch to support prompt interpolation

Zachary Turner via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Jul 31 10:39:33 PDT 2018


zturner added reviewers: labath, jasonmolenda.
zturner added inline comments.


================
Comment at: include/lldb/Host/Editline.h:187
+  /// Register a callback to retrieve the prompt.
+  void SetPromptCallback(PromptCallbackType callback, void *baton);
+  
----------------
I'd love to stop using the `baton` idiom if possible.  can you make this function take an `llvm::function_ref<StringRef (EditLine*)>` instead?  Then, in the class, store a `std::function<StringRef (EditLine*)>`.  When you call `SetPromptCallback`, write `SetPromptCallback([this](EditLine* L) { return  this->PromptCallback(L); });`


================
Comment at: include/lldb/Interpreter/PromptInterpolation.h:27
+
+  std::string InterpolatePrompt(const std::string& prompt_format);
+private:
----------------
As it stands, the class doesn't really do much.  It's basically just one function, and the only purpose of the `m_debugger` member is to avoid having to pass the Debugger object as an argument to the function.  It seems this could just be turned into a free function.  And while we're at it, since that free function is only ever used inside of `IOHandler.cpp`, it can probably just be marked `static` and be a global function defined in that particular TU.


================
Comment at: source/Core/IOHandler.cpp:451
+
+const char* IOHandlerEditline::PromptCallback(Editline *editline, void *baton) {
+  IOHandlerEditline *editline_reader = (IOHandlerEditline *)baton;
----------------
This can return a `StringRef`


Repository:
  rL LLVM

https://reviews.llvm.org/D49963





More information about the lldb-commits mailing list