[Lldb-commits] [lldb] c131dfe - [lldb] Disable auto fix-its when evaluating expressions in the test suite

Raphael Isemann via lldb-commits lldb-commits at lists.llvm.org
Mon Feb 24 00:31:41 PST 2020


Author: Raphael Isemann
Date: 2020-02-24T09:31:11+01:00
New Revision: c131dfefe2b404dc1dbb32a02ea484fd7edaffdc

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

LOG: [lldb] Disable auto fix-its when evaluating expressions in the test suite

Summary:
Currently the test suite runs with enabled automatically applied Clang fix-its for expressions.
This is causing that sometimes incorrect expressions in tests are still evaluated even though they
are actually incorrect. Let's disable this feature in the test suite so that we know when expressions
are wrong and leave the fix-it testing to the dedicated tests for that feature.

Also updates the `lang/cpp/operators/` test as it seems Clang needs the `struct` keywords
before C and would otherwise fail without fixits.

Reviewers: jingham, JDevlieghere, shafik

Reviewed By: JDevlieghere, shafik

Subscribers: shafik, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D74957

Added: 
    

Modified: 
    lldb/packages/Python/lldbsuite/test/lldbtest.py
    lldb/test/API/lang/cpp/operators/main.cpp
    lldb/test/Shell/lit-lldb-init.in

Removed: 
    


################################################################################
diff  --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index 0d1372497ef5..b20c29dafc6a 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -692,6 +692,10 @@ def setUpCommands(cls):
             # 
diff er in the debug info, which is not being hashed.
             "settings set symbols.enable-external-lookup false",
 
+            # Disable fix-its by default so that incorrect expressions in tests don't
+            # pass just because Clang thinks it has a fix-it.
+            "settings set target.auto-apply-fixits false",
+
             # Testsuite runs in parallel and the host can have also other load.
             "settings set plugin.process.gdb-remote.packet-timeout 60",
 
@@ -2394,7 +2398,16 @@ def expect_expr(
         self.assertTrue(expr.strip() == expr, "Expression contains trailing/leading whitespace: '" + expr + "'")
 
         frame = self.frame()
-        eval_result = frame.EvaluateExpression(expr)
+        options = lldb.SBExpressionOptions()
+
+        # Disable fix-its that tests don't pass by accident.
+        options.SetAutoApplyFixIts(False)
+
+        # Set the usual default options for normal expressions.
+        options.SetIgnoreBreakpoints(True)
+        options.SetLanguage(frame.GuessLanguage())
+
+        eval_result = frame.EvaluateExpression(expr, options)
 
         if error_msg:
             self.assertFalse(eval_result.IsValid(), "Unexpected success with result: '" + str(eval_result) + "'")

diff  --git a/lldb/test/API/lang/cpp/operators/main.cpp b/lldb/test/API/lang/cpp/operators/main.cpp
index ed1161952bf2..7afea1e957ce 100644
--- a/lldb/test/API/lang/cpp/operators/main.cpp
+++ b/lldb/test/API/lang/cpp/operators/main.cpp
@@ -171,7 +171,7 @@ int main(int argc, char **argv) {
   //% self.expect("expr static_cast<long>(c)", endstr=" 12\n")
   //% self.expect("expr c.operatorint()", endstr=" 13\n")
   //% self.expect("expr c.operatornew()", endstr=" 14\n")
-  //% self.expect("expr (new C)->custom_new", endstr=" true\n")
+  //% self.expect("expr (new struct C)->custom_new", endstr=" true\n")
   //% self.expect("expr (new struct C[1])->custom_new", endstr=" true\n")
   //% self.expect("expr delete c2; side_effect", endstr=" = 1\n")
   //% self.expect("expr delete[] c3; side_effect", endstr=" = 2\n")

diff  --git a/lldb/test/Shell/lit-lldb-init.in b/lldb/test/Shell/lit-lldb-init.in
index 2c1925c971a4..6d46e034dc48 100644
--- a/lldb/test/Shell/lit-lldb-init.in
+++ b/lldb/test/Shell/lit-lldb-init.in
@@ -3,3 +3,4 @@ settings set symbols.enable-external-lookup false
 settings set plugin.process.gdb-remote.packet-timeout 60
 settings set interpreter.echo-comment-commands false
 settings set symbols.clang-modules-cache-path "@LLDB_TEST_MODULE_CACHE_LLDB@"
+settings set target.auto-apply-fixits false


        


More information about the lldb-commits mailing list