Files
clang-p2996/lldb/test/API/lang/cpp/gmodules/alignment/pch.h
Michael Buch 07ffb7e294 [lldb][ClangASTImporter] Import record layouts from origin if available (#83295)
Layout information for a record gets stored in the `ClangASTImporter`
associated with the `DWARFASTParserClang` that originally parsed the
record. 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 the
`ClangASTImporter` the type is associated with. If the type's origin is
actually in a different LLDB module (and thus a different
`DWARFASTParserClang` was used to set its layout info), we won't find
the 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` and
`expr`.

There is logic in `ClangASTSource::layoutRecordType` to import an
origin's layout info. This patch re-uses that infrastructure to import
an origin's layout from one `ClangASTImporter` instance to another.

rdar://123274144
2024-02-29 21:40:02 +00:00

22 lines
365 B
C

#ifndef PCH_H_IN
#define PCH_H_IN
static const int kAlignment = 64;
struct [[gnu::aligned(kAlignment)]] RowCol {
unsigned row;
unsigned col;
};
struct [[gnu::aligned(kAlignment)]] Submatrix {
struct RowCol origin;
struct RowCol size;
};
struct [[gnu::aligned(kAlignment)]] MatrixData {
struct Submatrix section;
unsigned stride;
};
#endif // _H_IN