[Lldb-commits] [lldb] [lldb] Fix DIL error diagnostics output (PR #187680)

Michael Buch via lldb-commits lldb-commits at lists.llvm.org
Thu Apr 2 06:33:22 PDT 2026


================
@@ -36,13 +36,19 @@ DILDiagnosticError::DILDiagnosticError(llvm::StringRef expr,
   DiagnosticDetail::SourceLocation sloc = {
       FileSpec{}, /*line=*/1, static_cast<uint16_t>(loc + 1),
       err_len,    false,      /*in_user_input=*/true};
-  std::string rendered_msg =
-      llvm::formatv("<user expression 0>:1:{0}: {1}\n   1 | {2}\n     | ^",
-                    loc + 1, message, expr);
+  auto msg = llvm::formatv("<user expression>:1:{0}: {1}\n    1 | {2}\n      |",
+                           loc + 1, message, expr);
+  std::string rendered_str;
+  llvm::raw_string_ostream rendered_os(rendered_str);
+  rendered_os << msg.str();
+  rendered_os << llvm::indent(loc + 1) << "^";
+  if (err_len > 0)
----------------
Michael137 wrote:

Can we comment saying why the `-1`. I assume it's because the `^` takes up one of the character slots.

Also, probably useful to put an example error as a comment above the function, to show what we expect to produce

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


More information about the lldb-commits mailing list