[Lldb-commits] [lldb] [lldb] enhance colorize process for image lookup command (PR #76112)

David Spickett via lldb-commits lldb-commits at lists.llvm.org
Thu Dec 21 08:17:27 PST 2023


=?utf-8?q?José?= L. Junior <jljuniorpb at gmail.com>,
=?utf-8?q?José?= L. Junior <jljuniorpb at gmail.com>,
=?utf-8?q?José?= L. Junior <jljuniorpb at gmail.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/76112 at github.com>


================
@@ -72,23 +72,21 @@ size_t Stream::PutCString(llvm::StringRef str) {
   return bytes_written;
 }
 
-void Stream::PutCStringColorHighlighted(llvm::StringRef text,
-                                        llvm::StringRef pattern,
-                                        llvm::StringRef prefix,
-                                        llvm::StringRef suffix) {
-  // Only apply color formatting when a pattern is present and both prefix and
-  // suffix are specified. In the absence of these conditions, output the text
-  // without color formatting.
-  if (pattern.empty() || (prefix.empty() && suffix.empty())) {
+void Stream::PutCStringColorHighlighted(
+    llvm::StringRef text, std::optional<Information> pattern_info) {
+  // Only apply color formatting when the pattern information is specified.
+  // Otherwise, output the text without color formatting.
+  if (!pattern_info.has_value()) {
     PutCString(text);
     return;
   }
 
-  llvm::Regex reg_pattern(pattern);
+  llvm::Regex reg_pattern(pattern_info.value().pattern);
----------------
DavidSpickett wrote:

Which can be cleaner, is my point, `value()` vs. `->`.

https://github.com/llvm/llvm-project/pull/76112


More information about the lldb-commits mailing list