forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 339
[lldb][DWARFASTParserClang] Prevent unnamed bitfield creation in the presence of overlapping fields #10591
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
Open
Michael137
wants to merge
3
commits into
swift/release/6.2
Choose a base branch
from
lldb/unnamed-bitfields-to-6.2
base: swift/release/6.2
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or 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
@swift-ci test |
adrian-prantl
approved these changes
Apr 30, 2025
@swift-ci test |
@swift-ci test Windows |
… into helper (llvm#108196) This logic will need adjusting soon for llvm#108155 This patch pulls out the logic for detecting/creating unnamed bitfields out of `ParseSingleMember` to make the latter (in my opinion) more readable. Otherwise we have a large number of similarly named variables in scope. (cherry picked from commit f0c6d30)
01f6adc
to
32be8c9
Compare
@swift-ci test |
@swift-ci test |
@swift-ci test macos |
…presence of overlapping fields (llvm#108343) This bug surfaced after llvm#105865 (currently reverted, but blocked on this to be relanded). Because Clang doesn't emit `DW_TAG_member`s for unnamed bitfields, LLDB has to make an educated guess about whether they existed in the source. It does so by checking whether there is a gap between where the last field ended and the currently parsed field starts. In the example test case, the empty field `padding` was folded into the storage of `data`. Because the `bit_offset` of `padding` is `0x0` and its `DW_AT_byte_size` is `0x1`, LLDB thinks the field ends at `0x1` (not quite because we first round the size to a word size, but this is an implementation detail), erroneously deducing that there's a gap between `flag` and `padding`. This patch adds the notion of "effective field end", which accounts for fields that share storage. It is set to the end of the storage that the two fields occupy. Then we use this to check for gaps in the unnamed bitfield creation logic. (cherry picked from commit a6a547f)
32be8c9
to
374b6f2
Compare
@swift-ci test |
@swift-ci test macos |
@swift-ci test windows |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Because Clang doesn't emit
DW_TAG_member
s for unnamed bitfields, LLDBhas to make an educated guess about whether they existed in the source.
It does so by checking whether there is a gap between where the last
field ended and the currently parsed field starts. In the example test
case, the empty field
padding
was folded into the storage ofdata
.Because the
bit_offset
ofpadding
is0x0
and itsDW_AT_byte_size
is
0x1
, LLDB thinks the field ends at0x1
(not quite because wefirst round the size to a word size, but this is an implementation
detail), erroneously deducing that there's a gap between
flag
andpadding
.This patch adds the notion of "effective field end", which accounts for
fields that share storage. It is set to the end of the storage that the
two fields occupy. Then we use this to check for gaps in the unnamed
bitfield creation logic.
(cherry picked from commit a6a547f)