[Lldb-commits] [lldb] 2e59b75 - Revert "[lldb] Fix `po` alias by printing fix-its to the console. (#68452)"

Adrian Prantl via lldb-commits lldb-commits at lists.llvm.org
Tue Oct 10 14:56:29 PDT 2023


Author: Adrian Prantl
Date: 2023-10-10T14:56:00-07:00
New Revision: 2e59b7550e3678a10be1a26f651488fc665a1f09

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

LOG: Revert "[lldb] Fix `po` alias by printing fix-its to the console. (#68452)"

This reverts commit 606f89ab7d537ca068fb1be9fd89d96a30de38f8 while investigating bot failures.

Added: 
    

Modified: 
    lldb/source/Commands/CommandObjectDWIMPrint.cpp
    lldb/source/Commands/CommandObjectExpression.cpp

Removed: 
    lldb/test/API/lang/cpp/dwim-print-fixit/Makefile
    lldb/test/API/lang/cpp/dwim-print-fixit/TestCppDWIMPrintFixIt.py
    lldb/test/API/lang/cpp/dwim-print-fixit/main.cpp
    lldb/test/API/lang/cpp/expression-fixit/Makefile
    lldb/test/API/lang/cpp/expression-fixit/TestCppExpressionFixIt.py
    lldb/test/API/lang/cpp/expression-fixit/main.cpp


################################################################################
diff  --git a/lldb/source/Commands/CommandObjectDWIMPrint.cpp b/lldb/source/Commands/CommandObjectDWIMPrint.cpp
index bdc17c9cffc779a..7b168eab9e02d44 100644
--- a/lldb/source/Commands/CommandObjectDWIMPrint.cpp
+++ b/lldb/source/Commands/CommandObjectDWIMPrint.cpp
@@ -172,19 +172,8 @@ bool CommandObjectDWIMPrint::DoExecute(StringRef command,
   {
     auto *exe_scope = m_exe_ctx.GetBestExecutionContextScope();
     ValueObjectSP valobj_sp;
-    std::string fixed_expression;
-
-    ExpressionResults expr_result = target.EvaluateExpression(
-        expr, exe_scope, valobj_sp, eval_options, &fixed_expression);
-
-    // Only mention Fix-Its if the expression evaluator applied them.
-    // Compiler errors refer to the final expression after applying Fix-It(s).
-    if (!fixed_expression.empty() && target.GetEnableNotifyAboutFixIts()) {
-      Stream &error_stream = result.GetErrorStream();
-      error_stream << "  Evaluated this expression after applying Fix-It(s):\n";
-      error_stream << "    " << fixed_expression << "\n";
-    }
-
+    ExpressionResults expr_result =
+        target.EvaluateExpression(expr, exe_scope, valobj_sp, eval_options);
     if (expr_result == eExpressionCompleted) {
       if (verbosity != eDWIMPrintVerbosityNone) {
         StringRef flags;

diff  --git a/lldb/source/Commands/CommandObjectExpression.cpp b/lldb/source/Commands/CommandObjectExpression.cpp
index 2834be660abaf53..e7e6e3820b99133 100644
--- a/lldb/source/Commands/CommandObjectExpression.cpp
+++ b/lldb/source/Commands/CommandObjectExpression.cpp
@@ -439,11 +439,11 @@ bool CommandObjectExpression::EvaluateExpression(llvm::StringRef expr,
   ExpressionResults success = target.EvaluateExpression(
       expr, frame, result_valobj_sp, eval_options, &m_fixed_expression);
 
-  // Only mention Fix-Its if the expression evaluator applied them.
-  // Compiler errors refer to the final expression after applying Fix-It(s).
+  // We only tell you about the FixIt if we applied it.  The compiler errors
+  // will suggest the FixIt if it parsed.
   if (!m_fixed_expression.empty() && target.GetEnableNotifyAboutFixIts()) {
-    error_stream << "  Evaluated this expression after applying Fix-It(s):\n";
-    error_stream << "    " << m_fixed_expression << "\n";
+    error_stream.Printf("  Fix-it applied, fixed expression was: \n    %s\n",
+                        m_fixed_expression.c_str());
   }
 
   if (result_valobj_sp) {

diff  --git a/lldb/test/API/lang/cpp/dwim-print-fixit/Makefile b/lldb/test/API/lang/cpp/dwim-print-fixit/Makefile
deleted file mode 100644
index 99998b20bcb0502..000000000000000
--- a/lldb/test/API/lang/cpp/dwim-print-fixit/Makefile
+++ /dev/null
@@ -1,3 +0,0 @@
-CXX_SOURCES := main.cpp
-
-include Makefile.rules

diff  --git a/lldb/test/API/lang/cpp/dwim-print-fixit/TestCppDWIMPrintFixIt.py b/lldb/test/API/lang/cpp/dwim-print-fixit/TestCppDWIMPrintFixIt.py
deleted file mode 100644
index 260903f30464caa..000000000000000
--- a/lldb/test/API/lang/cpp/dwim-print-fixit/TestCppDWIMPrintFixIt.py
+++ /dev/null
@@ -1,24 +0,0 @@
-"""
-Tests whether the do-what-I-mean (DWIM) print `po` alias applies FixIts like `expr` does
-"""
-import lldb
-from lldbsuite.test.decorators import *
-from lldbsuite.test.lldbtest import *
-from lldbsuite.test import lldbutil
-
-
-class TestCase(TestBase):
-    def test_with_run_command(self):
-        """Confirms `po` shows an expression after applying Fix-It(s)."""
-
-        self.build()
-        lldbutil.run_to_source_breakpoint(
-            self, "// break here", lldb.SBFileSpec("main.cpp")
-        )
-
-        self.expect(
-            "dwim-print -O -- class C { int i; void f() { []() { ++i; }(); } }; 42",
-            error = True,
-            substrs=["Evaluated this expression after applying Fix-It(s)",
-                "class C { int i; void f() { [this]() { ++i; }(); } }"],
-        )

diff  --git a/lldb/test/API/lang/cpp/dwim-print-fixit/main.cpp b/lldb/test/API/lang/cpp/dwim-print-fixit/main.cpp
deleted file mode 100644
index e9cf11d18a6560d..000000000000000
--- a/lldb/test/API/lang/cpp/dwim-print-fixit/main.cpp
+++ /dev/null
@@ -1,5 +0,0 @@
-int main() {
-  long foo = 1234;
-
-  return 0; // break here
-}

diff  --git a/lldb/test/API/lang/cpp/expression-fixit/Makefile b/lldb/test/API/lang/cpp/expression-fixit/Makefile
deleted file mode 100644
index 99998b20bcb0502..000000000000000
--- a/lldb/test/API/lang/cpp/expression-fixit/Makefile
+++ /dev/null
@@ -1,3 +0,0 @@
-CXX_SOURCES := main.cpp
-
-include Makefile.rules

diff  --git a/lldb/test/API/lang/cpp/expression-fixit/TestCppExpressionFixIt.py b/lldb/test/API/lang/cpp/expression-fixit/TestCppExpressionFixIt.py
deleted file mode 100644
index b6c255c5e004cfc..000000000000000
--- a/lldb/test/API/lang/cpp/expression-fixit/TestCppExpressionFixIt.py
+++ /dev/null
@@ -1,24 +0,0 @@
-"""
-Tests whether the expression command applies FixIts
-"""
-import lldb
-from lldbsuite.test.decorators import *
-from lldbsuite.test.lldbtest import *
-from lldbsuite.test import lldbutil
-
-
-class TestCase(TestBase):
-    def test_with_run_command(self):
-        """Confirms `expression` shows an expression after applying Fix-It(s)."""
-
-        self.build()
-        lldbutil.run_to_source_breakpoint(
-            self, "// break here", lldb.SBFileSpec("main.cpp")
-        )
-
-        self.expect(
-            "expr class C { int i; void f() { []() { ++i; }(); } }; 42",
-            error = True,
-            substrs=["Evaluated this expression after applying Fix-It(s)",
-                "class C { int i; void f() { [this]() { ++i; }(); } }"],
-        )

diff  --git a/lldb/test/API/lang/cpp/expression-fixit/main.cpp b/lldb/test/API/lang/cpp/expression-fixit/main.cpp
deleted file mode 100644
index e9cf11d18a6560d..000000000000000
--- a/lldb/test/API/lang/cpp/expression-fixit/main.cpp
+++ /dev/null
@@ -1,5 +0,0 @@
-int main() {
-  long foo = 1234;
-
-  return 0; // break here
-}


        


More information about the lldb-commits mailing list