[Lldb-commits] [lldb] [lldb] Add a simplified syntax for underlying command options (NFC) (PR #155694)
David Spickett via lldb-commits
lldb-commits at lists.llvm.org
Thu Aug 28 02:22:28 PDT 2025
================
@@ -23,6 +23,31 @@ using namespace llvm;
using namespace lldb_private;
namespace {
+/// Parses curly braces and replaces them with ANSI underline formatting.
+inline std::string underline(llvm::StringRef Str) {
+ llvm::StringRef OpeningHead, OpeningTail, ClosingHead, ClosingTail;
+ std::string Result;
+ llvm::raw_string_ostream Stream(Result);
+ while (!Str.empty()) {
+ // Find the opening brace.
+ std::tie(OpeningHead, OpeningTail) = Str.split("${");
+ Stream << OpeningHead;
+
+ // No opening brace: we're done.
+ if (OpeningHead == Str && OpeningTail.empty())
+ break;
+
+ // Find the closing brace.
+ std::tie(ClosingHead, ClosingTail) = OpeningTail.split('}');
+ assert(!ClosingTail.empty() &&
+ "unmatched curly braces in command option description");
----------------
DavidSpickett wrote:
In non-assert builds this makes the behaviour like printf, it just leaves the characters in there. I see we don't have a nice way to return an error in this path either.
Is there any way for an emitter to report an error?
Assert is ok but given that it takes a user to notice the stray `${`, I wonder if we should just fail to build at all.
https://github.com/llvm/llvm-project/pull/155694
More information about the lldb-commits
mailing list