-
Notifications
You must be signed in to change notification settings - Fork 11k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[lldb] Fix printing of unsigned enum bitfields when they contain the max value #96202
Merged
+71
−5
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
CXX_SOURCES := main.cpp | ||
|
||
include Makefile.rules |
31 changes: 31 additions & 0 deletions
31
lldb/test/API/commands/expression/bitfield_enums/TestBitfieldEnums.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
""" | ||
Test that the expression parser accounts for the underlying type of bitfield | ||
enums when looking for matching values. | ||
""" | ||
|
||
import lldb | ||
from lldbsuite.test.decorators import * | ||
from lldbsuite.test.lldbtest import * | ||
from lldbsuite.test import lldbutil | ||
|
||
|
||
class TestBitfieldEnum(TestBase): | ||
def test_bitfield_enums(self): | ||
self.build() | ||
|
||
lldbutil.run_to_source_breakpoint( | ||
self, "// break here", lldb.SBFileSpec("main.cpp", False) | ||
) | ||
|
||
self.expect_expr( | ||
"bfs", | ||
result_type="BitfieldStruct", | ||
result_children=[ | ||
ValueCheck(name="signed_min", value="min"), | ||
ValueCheck(name="signed_other", value="-1"), | ||
ValueCheck(name="signed_max", value="max"), | ||
ValueCheck(name="unsigned_min", value="min"), | ||
ValueCheck(name="unsigned_other", value="1"), | ||
ValueCheck(name="unsigned_max", value="max"), | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
enum class SignedEnum : int { min = -2, max = 1 }; | ||
enum class UnsignedEnum : unsigned { min = 0, max = 3 }; | ||
|
||
struct BitfieldStruct { | ||
SignedEnum signed_min : 2; | ||
SignedEnum signed_other : 2; | ||
SignedEnum signed_max : 2; | ||
UnsignedEnum unsigned_min : 2; | ||
UnsignedEnum unsigned_other : 2; | ||
UnsignedEnum unsigned_max : 2; | ||
}; | ||
|
||
int main() { | ||
BitfieldStruct bfs; | ||
bfs.signed_min = SignedEnum::min; | ||
bfs.signed_other = static_cast<SignedEnum>(-1); | ||
bfs.signed_max = SignedEnum::max; | ||
|
||
bfs.unsigned_min = UnsignedEnum::min; | ||
bfs.unsigned_other = static_cast<UnsignedEnum>(1); | ||
bfs.unsigned_max = UnsignedEnum::max; | ||
|
||
return 0; // break here | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prior to this change, this printed
3
instead ofmax
.