[llvm-branch-commits] [lldb] cf553ca - Revert "[lldb] Fix DIL error diagnostics output (#187680)"

via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Apr 3 05:55:59 PDT 2026


Author: Ilia Kuklin
Date: 2026-04-03T17:55:54+05:00
New Revision: cf553ca2b463f65b90c17d22ade2d5ec6cda79a7

URL: https://github.com/llvm/llvm-project/commit/cf553ca2b463f65b90c17d22ade2d5ec6cda79a7
DIFF: https://github.com/llvm/llvm-project/commit/cf553ca2b463f65b90c17d22ade2d5ec6cda79a7.diff

LOG: Revert "[lldb] Fix DIL error diagnostics output (#187680)"

This reverts commit e24936b7ad5c6b1fdcc35d98c682fa5bd745e65b.

Added: 
    

Modified: 
    lldb/source/Commands/CommandObjectFrame.cpp
    lldb/source/Target/StackFrame.cpp
    lldb/source/ValueObject/DILParser.cpp
    lldb/test/Shell/Commands/Inputs/main.c

Removed: 
    lldb/test/Shell/Commands/command-dil-diagnostics.test


################################################################################
diff  --git a/lldb/source/Commands/CommandObjectFrame.cpp b/lldb/source/Commands/CommandObjectFrame.cpp
index f1800df58aa52..1488e3bfe5890 100644
--- a/lldb/source/Commands/CommandObjectFrame.cpp
+++ b/lldb/source/Commands/CommandObjectFrame.cpp
@@ -638,21 +638,8 @@ may even involve JITing and running code in the target program.)");
               Stream &output_stream = result.GetOutputStream();
               options.SetRootValueObjectName(
                   valobj_sp->GetParent() ? entry.c_str() : nullptr);
-              // Check only the `error` argument, because doing
-              // `valobj_sp->GetError()` will update the value and potentially
-              // return a new error that happens during the update, even if
-              // `GetValueForVariableExpressionPath` reported no errors.
-              if (error.Fail()) {
-                result.SetStatus(eReturnStatusFailed);
-                result.SetError(error.takeError());
-              } else {
-                // If there is an error while updating the value, it will be
-                // printed here as the contents of the value, e.g.
-                // `(int) *((int*)0) = <parent is NULL>`
-                if (llvm::Error error = valobj_sp->Dump(output_stream, options))
-                  result.AppendError(toString(std::move(error)));
-              }
-
+              if (llvm::Error error = valobj_sp->Dump(output_stream, options))
+                result.AppendError(toString(std::move(error)));
             } else {
               if (auto error_cstr = error.AsCString(nullptr))
                 result.AppendError(error_cstr);

diff  --git a/lldb/source/Target/StackFrame.cpp b/lldb/source/Target/StackFrame.cpp
index e04b4e2300635..89435e20cc49b 100644
--- a/lldb/source/Target/StackFrame.cpp
+++ b/lldb/source/Target/StackFrame.cpp
@@ -545,7 +545,7 @@ ValueObjectSP StackFrame::DILGetValueForVariableExpressionPath(
   auto lex_or_err = dil::DILLexer::Create(var_expr, mode);
   if (!lex_or_err) {
     error = Status::FromError(lex_or_err.takeError());
-    return ValueObjectConstResult::Create(nullptr, error.Clone());
+    return ValueObjectConstResult::Create(nullptr, std::move(error));
   }
 
   // Parse the expression.
@@ -554,7 +554,7 @@ ValueObjectSP StackFrame::DILGetValueForVariableExpressionPath(
                             shared_from_this(), use_dynamic, options);
   if (!tree_or_error) {
     error = Status::FromError(tree_or_error.takeError());
-    return ValueObjectConstResult::Create(nullptr, error.Clone());
+    return ValueObjectConstResult::Create(nullptr, std::move(error));
   }
 
   // Evaluate the parsed expression.
@@ -565,7 +565,7 @@ ValueObjectSP StackFrame::DILGetValueForVariableExpressionPath(
   auto valobj_or_error = interpreter.Evaluate(**tree_or_error);
   if (!valobj_or_error) {
     error = Status::FromError(valobj_or_error.takeError());
-    return ValueObjectConstResult::Create(nullptr, error.Clone());
+    return ValueObjectConstResult::Create(nullptr, std::move(error));
   }
 
   var_sp = (*valobj_or_error)->GetVariable();

diff  --git a/lldb/source/ValueObject/DILParser.cpp b/lldb/source/ValueObject/DILParser.cpp
index d226ba66ef889..919acd4645f71 100644
--- a/lldb/source/ValueObject/DILParser.cpp
+++ b/lldb/source/ValueObject/DILParser.cpp
@@ -36,27 +36,13 @@ DILDiagnosticError::DILDiagnosticError(llvm::StringRef expr,
   DiagnosticDetail::SourceLocation sloc = {
       FileSpec{}, /*line=*/1, static_cast<uint16_t>(loc + 1),
       err_len,    false,      /*in_user_input=*/true};
-  // If the error is not handled by `RenderDiagnosticDetails`, this creates an
-  // error message that can be displayed instead.
-  // Example:
-  // (lldb) script lldb.frame.GetValueForVariablePath("1 + foo")
-  // error: <user expression>:1:5: use of undeclared identifier 'foo'
-  //   1 | 1 + foo
-  //     |     ^~~
-  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 > 1) {
-    // Underline the rest of the erroneous token after the cursor '^'.
-    rendered_os << std::string(err_len - 1, '~');
-  }
+  std::string rendered_msg =
+      llvm::formatv("<user expression 0>:1:{0}: {1}\n   1 | {2}\n     | ^",
+                    loc + 1, message, expr);
   m_detail.source_location = sloc;
   m_detail.severity = lldb::eSeverityError;
   m_detail.message = message;
-  m_detail.rendered = std::move(rendered_str);
+  m_detail.rendered = std::move(rendered_msg);
 }
 
 llvm::Expected<lldb::TypeSystemSP>

diff  --git a/lldb/test/Shell/Commands/Inputs/main.c b/lldb/test/Shell/Commands/Inputs/main.c
index 284605e5db11d..c029ddd96cd52 100644
--- a/lldb/test/Shell/Commands/Inputs/main.c
+++ b/lldb/test/Shell/Commands/Inputs/main.c
@@ -1,3 +1,2 @@
 int foo() { return 0; }
 int main() { return foo(); }
-int a = 1;

diff  --git a/lldb/test/Shell/Commands/command-dil-diagnostics.test b/lldb/test/Shell/Commands/command-dil-diagnostics.test
deleted file mode 100644
index ee056e6bb3f51..0000000000000
--- a/lldb/test/Shell/Commands/command-dil-diagnostics.test
+++ /dev/null
@@ -1,22 +0,0 @@
-## Check DIL error diagnostics output.
-# XFAIL: target-windows
-# RUN: %clang_host -g -O0 %S/Inputs/main.c -o %t
-# RUN: %lldb %t -o "command source -e 0 %s" -o exit 2>&1 | FileCheck %s --strict-whitespace
-settings set target.experimental.use-DIL true
-b main
-run
-
-## Check console diagnostincs pointing to an error in user input.
-frame var a+b
-# CHECK:      {{^                   (\^|˄)}}
-# CHECK-NEXT: {{^                   (╰─ )?}}error: use of undeclared identifier 'b'
-
-## Check diagnostics when called from API.
-script lldb.frame.GetValueForVariablePath("++foo")
-# CHECK: error: <user expression>:1:3: use of undeclared identifier 'foo'
-# CHECK-NEXT: {{^    }}1 | ++foo
-# CHECK-NEXT: {{^    }}  |   ^~~
-
-## Check that a result that fails to retrieve data is displaying an error.
-frame var *((int*)0)
-# CHECK: (int) *((int*)0) = <parent is NULL>


        


More information about the llvm-branch-commits mailing list