Skip to content

[lldb][test] Add SBExpressionOptions parameter to expect_expr#177920

Merged
Michael137 merged 2 commits intollvm:mainfrom
Michael137:lldb/const-expr-1
Feb 4, 2026
Merged

[lldb][test] Add SBExpressionOptions parameter to expect_expr#177920
Michael137 merged 2 commits intollvm:mainfrom
Michael137:lldb/const-expr-1

Conversation

@Michael137
Copy link
Member

@Michael137 Michael137 commented Jan 26, 2026

Allows API tests to pass SBExpressionOptions when testing a successful expression evaluation with expect_expr. Currently one would have to use SBFrame::EvaluateExpression or pass the option as an argument to the raw command (via expect() or HandleCommand()).

Chose not to do the SetIgnoreBreakpoints/SetAutoApplyFixIts with the assumption that most expression evaluation tests don't actually need to care about these. If the options are passed explicitly, lets use them as-is. Otherwise default to the old options.

First usage of this new parameter would be in #177926

@llvmbot
Copy link
Member

llvmbot commented Jan 26, 2026

@llvm/pr-subscribers-lldb

Author: Michael Buch (Michael137)

Changes

Allows API tests to pass SBExpressionOptions when testing a successful expression evaluation with expect_expr. Currently one would have to use SBFrame::EvaluateExpression or pass the option as an argument to the raw command (via expect() or HandleCommand()).

Chose not to do the SetIgnoreBreakpoints/SetAutoApplyFixIts with the assumption that most expression evaluation tests don't actually need to care about these. If the options are passed explicitly, lets use them as-is. Otherwise default to the old options.


Full diff: https://github.com/llvm/llvm-project/pull/177920.diff

1 Files Affected:

  • (modified) lldb/packages/Python/lldbsuite/test/lldbtest.py (+9-4)
diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index 6bb4516948da5..b77d8e9fae3ab 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -2575,6 +2575,7 @@ def expect_expr(
         result_value=None,
         result_type=None,
         result_children=None,
+        options=None,
     ):
         """
         Evaluates the given expression and verifies the result.
@@ -2584,6 +2585,7 @@ def expect_expr(
         :param result_type: The type that the expression result should have. None if the type should not be checked.
         :param result_children: The expected children of the expression result
                                 as a list of ValueChecks. None if the children shouldn't be checked.
+        :param options: Expression evaluation options. None if a default set of options should be used.
         """
         self.assertTrue(
             expr.strip() == expr,
@@ -2593,11 +2595,14 @@ def expect_expr(
         frame = self.frame()
         options = lldb.SBExpressionOptions()
 
-        # Disable fix-its that tests don't pass by accident.
-        options.SetAutoApplyFixIts(False)
+        if not options:
+            options = lldb.SBExpressionOptions()
 
-        # Set the usual default options for normal expressions.
-        options.SetIgnoreBreakpoints(True)
+            # Disable fix-its that tests don't pass by accident.
+            options.SetAutoApplyFixIts(False)
+
+            # Set the usual default options for normal expressions.
+            options.SetIgnoreBreakpoints(True)
 
         if self.frame().IsValid():
             options.SetLanguage(frame.GuessLanguage())

@github-actions
Copy link

github-actions bot commented Jan 26, 2026

🐧 Linux x64 Test Results

  • 33263 tests passed
  • 506 tests skipped

✅ The build succeeded and all tests passed.

@DavidSpickett
Copy link
Collaborator

DavidSpickett commented Jan 26, 2026

Allows API tests to pass SBExpressionOptions when testing a successful expression evaluation with expect_expr.

Which tests and for what reasons?

Change is fine code wise, but I don't immediately see what I'd do with this.

@Michael137
Copy link
Member Author

Allows API tests to pass SBExpressionOptions when testing a successful expression evaluation with expect_expr.

Which tests and for what reasons?

Change is fine code wise, but I don't immediately see what I'd do with this.

I have an upcoming patch that adds an option to SBExpressionOptions. I would like to use expect_expr in those tests. Not super critical, but it makes the tests slightly nicer to read.

I'll wait on merging this PR once all the follow-up PRs are up, so there's examples of what it looks like

Michael137 added a commit to Michael137/llvm-project that referenced this pull request Jan 26, 2026
…ption

Depends on:
* llvm#177920
* llvm#177922

In llvm#177922 we make expressions
run in C++ member functions honor the function qualifiers of the current
stop context. E.g., this means we can no longer run non-const member
functions when stopped in a const-member function.

To ensure users can still do this if they really need/want to, we
provide an option to not honor the qualifiers at all, leaving the
`__lldb_expr` as the least qualified, allowing it to call any
function/mutate any members.
Michael137 added a commit to Michael137/llvm-project that referenced this pull request Jan 26, 2026
…ption

Depends on:
* llvm#177920
* llvm#177922

In llvm#177922 we make expressions
run in C++ member functions honor the function qualifiers of the current
stop context. E.g., this means we can no longer run non-const member
functions when stopped in a const-member function.

To ensure users can still do this if they really need/want to, we
provide an option to not honor the qualifiers at all, leaving the
`__lldb_expr` as the least qualified, allowing it to call any
function/mutate any members.
Michael137 added a commit to Michael137/llvm-project that referenced this pull request Jan 26, 2026
…ption

Depends on:
* llvm#177920
* llvm#177922

In llvm#177922 we make expressions
run in C++ member functions honor the function qualifiers of the current
stop context. E.g., this means we can no longer run non-const member
functions when stopped in a const-member function.

To ensure users can still do this if they really need/want to, we
provide an option to not honor the qualifiers at all, leaving the
`__lldb_expr` as the least qualified, allowing it to call any
function/mutate any members.
Michael137 added a commit to Michael137/llvm-project that referenced this pull request Jan 26, 2026
…ption

Depends on:
* llvm#177920
* llvm#177922

In llvm#177922 we make expressions
run in C++ member functions honor the function qualifiers of the current
stop context. E.g., this means we can no longer run non-const member
functions when stopped in a const-member function.

To ensure users can still do this if they really need/want to, we
provide an option to not honor the qualifiers at all, leaving the
`__lldb_expr` as the least qualified, allowing it to call any
function/mutate any members.
Michael137 added a commit to Michael137/llvm-project that referenced this pull request Jan 26, 2026
…ption

Depends on:
* llvm#177920
* llvm#177922

In llvm#177922 we make expressions
run in C++ member functions honor the function qualifiers of the current
stop context. E.g., this means we can no longer run non-const member
functions when stopped in a const-member function.

To ensure users can still do this if they really need/want to, we
provide an option to not honor the qualifiers at all, leaving the
`__lldb_expr` as the least qualified, allowing it to call any
function/mutate any members.
Michael137 added a commit to Michael137/llvm-project that referenced this pull request Jan 26, 2026
…ption

Depends on:
* llvm#177920
* llvm#177922

In llvm#177922 we make expressions
run in C++ member functions honor the function qualifiers of the current
stop context. E.g., this means we can no longer run non-const member
functions when stopped in a const-member function.

To ensure users can still do this if they really need/want to, we
provide an option to not honor the qualifiers at all, leaving the
`__lldb_expr` as the least qualified, allowing it to call any
function/mutate any members.
Michael137 added a commit to Michael137/llvm-project that referenced this pull request Jan 26, 2026
…ption

Depends on:
* llvm#177920
* llvm#177922

In llvm#177922 we make expressions
run in C++ member functions honor the function qualifiers of the current
stop context. E.g., this means we can no longer run non-const member
functions when stopped in a const-member function.

To ensure users can still do this if they really need/want to, we
provide an option to not honor the qualifiers at all, leaving the
`__lldb_expr` as the least qualified, allowing it to call any
function/mutate any members.
Michael137 added a commit to Michael137/llvm-project that referenced this pull request Jan 26, 2026
…ption

Depends on:
* llvm#177920
* llvm#177922

In llvm#177922 we make expressions
run in C++ member functions honor the function qualifiers of the current
stop context. E.g., this means we can no longer run non-const member
functions when stopped in a const-member function.

To ensure users can still do this if they really need/want to, we
provide an option to not honor the qualifiers at all, leaving the
`__lldb_expr` as the least qualified, allowing it to call any
function/mutate any members.
Michael137 added a commit to Michael137/llvm-project that referenced this pull request Jan 27, 2026
…ption

Depends on:
* llvm#177920
* llvm#177922

In llvm#177922 we make expressions
run in C++ member functions honor the function qualifiers of the current
stop context. E.g., this means we can no longer run non-const member
functions when stopped in a const-member function.

To ensure users can still do this if they really need/want to, we
provide an option to not honor the qualifiers at all, leaving the
`__lldb_expr` as the least qualified, allowing it to call any
function/mutate any members.
Michael137 added a commit to Michael137/llvm-project that referenced this pull request Jan 30, 2026
…ption

Depends on:
* llvm#177920
* llvm#177922

In llvm#177922 we make expressions
run in C++ member functions honor the function qualifiers of the current
stop context. E.g., this means we can no longer run non-const member
functions when stopped in a const-member function.

To ensure users can still do this if they really need/want to, we
provide an option to not honor the qualifiers at all, leaving the
`__lldb_expr` as the least qualified, allowing it to call any
function/mutate any members.
Michael137 added a commit to Michael137/llvm-project that referenced this pull request Jan 30, 2026
…ption

Depends on:
* llvm#177920
* llvm#177922

In llvm#177922 we make expressions
run in C++ member functions honor the function qualifiers of the current
stop context. E.g., this means we can no longer run non-const member
functions when stopped in a const-member function.

To ensure users can still do this if they really need/want to, we
provide an option to not honor the qualifiers at all, leaving the
`__lldb_expr` as the least qualified, allowing it to call any
function/mutate any members.
Michael137 added a commit to Michael137/llvm-project that referenced this pull request Feb 4, 2026
…ption

Depends on:
* llvm#177920
* llvm#177922

In llvm#177922 we make expressions
run in C++ member functions honor the function qualifiers of the current
stop context. E.g., this means we can no longer run non-const member
functions when stopped in a const-member function.

To ensure users can still do this if they really need/want to, we
provide an option to not honor the qualifiers at all, leaving the
`__lldb_expr` as the least qualified, allowing it to call any
function/mutate any members.
@Michael137 Michael137 merged commit c51a758 into llvm:main Feb 4, 2026
11 checks passed
@Michael137 Michael137 deleted the lldb/const-expr-1 branch February 4, 2026 21:27
Michael137 added a commit to Michael137/llvm-project that referenced this pull request Feb 4, 2026
…ption

Depends on:
* llvm#177920
* llvm#177922

In llvm#177922 we make expressions
run in C++ member functions honor the function qualifiers of the current
stop context. E.g., this means we can no longer run non-const member
functions when stopped in a const-member function.

To ensure users can still do this if they really need/want to, we
provide an option to not honor the qualifiers at all, leaving the
`__lldb_expr` as the least qualified, allowing it to call any
function/mutate any members.
Michael137 added a commit to Michael137/llvm-project that referenced this pull request Feb 5, 2026
…ption

Depends on:
* llvm#177920
* llvm#177922

In llvm#177922 we make expressions
run in C++ member functions honor the function qualifiers of the current
stop context. E.g., this means we can no longer run non-const member
functions when stopped in a const-member function.

To ensure users can still do this if they really need/want to, we
provide an option to not honor the qualifiers at all, leaving the
`__lldb_expr` as the least qualified, allowing it to call any
function/mutate any members.
Michael137 added a commit that referenced this pull request Feb 5, 2026
…luation option (#177926)

Depends on:
* #177920
* #177922
* #179208

(only commit d8676d0 and later are
relevant for this review)

In #177922 we make expressions
run in C++ member functions honor the function qualifiers of the current
stop context. E.g., this means we can no longer run non-const member
functions when stopped in a const-member function.

To ensure users can still do this if they really need/want to, we
provide an option to not honor the qualifiers at all, leaving the
`__lldb_expr` minimally qualified, allowing it to call any
function/mutate any members.
llvm-sync bot pushed a commit to arm/arm-toolchain that referenced this pull request Feb 5, 2026
…ression evaluation option (#177926)

Depends on:
* llvm/llvm-project#177920
* llvm/llvm-project#177922
* llvm/llvm-project#179208

(only commit d8676d0ed9286777e1a1e9f625389540cc42c231 and later are
relevant for this review)

In llvm/llvm-project#177922 we make expressions
run in C++ member functions honor the function qualifiers of the current
stop context. E.g., this means we can no longer run non-const member
functions when stopped in a const-member function.

To ensure users can still do this if they really need/want to, we
provide an option to not honor the qualifiers at all, leaving the
`__lldb_expr` minimally qualified, allowing it to call any
function/mutate any members.
Michael137 added a commit to swiftlang/llvm-project that referenced this pull request Feb 5, 2026
…77920)

Allows API tests to pass `SBExpressionOptions` when testing a successful
expression evaluation with `expect_expr`. Currently one would have to
use `SBFrame::EvaluateExpression` or pass the option as an argument to
the raw command (via `expect()` or `HandleCommand()`).

Chose not to do the `SetIgnoreBreakpoints`/`SetAutoApplyFixIts` with the
assumption that most expression evaluation tests don't actually need to
care about these. If the options are passed explicitly, lets use them
as-is. Otherwise default to the old options.

First usage of this new parameter would be in
llvm#177926

(cherry picked from commit c51a758)
Michael137 added a commit to swiftlang/llvm-project that referenced this pull request Feb 5, 2026
…luation option (llvm#177926)

Depends on:
* llvm#177920
* llvm#177922
* llvm#179208

(only commit d8676d0 and later are
relevant for this review)

In llvm#177922 we make expressions
run in C++ member functions honor the function qualifiers of the current
stop context. E.g., this means we can no longer run non-const member
functions when stopped in a const-member function.

To ensure users can still do this if they really need/want to, we
provide an option to not honor the qualifiers at all, leaving the
`__lldb_expr` minimally qualified, allowing it to call any
function/mutate any members.

(cherry picked from commit 584156d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants