[cherry-pick][stable/20230725] [lldb][ClangASTImporter] Import record layouts from origin if available #8306
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.
Layout information for a record gets stored in the
ClangASTImporter
associated with the
DWARFASTParserClang
that originally parsed therecord. LLDB sometimes moves clang types from one AST to another (in the
reproducer the origin AST was a precompiled-header and the destination
was the AST backing the executable). When clang then asks LLDB to
layoutRecordType
, it will do so with the help of theClangASTImporter
the type is associated with. If the type's origin isactually in a different LLDB module (and thus a different
DWARFASTParserClang
was used to set its layout info), we won't findthe layout info in our local
ClangASTImporter
.In the reproducer this meant we would drop the alignment info of the
origin type and misread a variable's contents with
frame var
andexpr
.There is logic in
ClangASTSource::layoutRecordType
to import anorigin's layout info. This patch re-uses that infrastructure to import
an origin's layout from one
ClangASTImporter
instance to another.rdar://123274144
(cherry picked from commit 07ffb7e)