Skip to content

Commit 951b13d

Browse files
committed
[clang][Interp][NFC] Save IsUnion bit for Records
Now that we call this more often, try to keep pointer chasing to a minimum.
1 parent 1a2a0c0 commit 951b13d

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

clang/lib/AST/Interp/Record.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Record::Record(const RecordDecl *Decl, BaseList &&SrcBases,
1616
FieldList &&SrcFields, VirtualBaseList &&SrcVirtualBases,
1717
unsigned VirtualSize, unsigned BaseSize)
1818
: Decl(Decl), Bases(std::move(SrcBases)), Fields(std::move(SrcFields)),
19-
BaseSize(BaseSize), VirtualSize(VirtualSize) {
19+
BaseSize(BaseSize), VirtualSize(VirtualSize), IsUnion(Decl->isUnion()) {
2020
for (Base &V : SrcVirtualBases)
2121
VirtualBases.push_back({ V.Decl, V.Offset + BaseSize, V.Desc, V.R });
2222

clang/lib/AST/Interp/Record.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class Record final {
5353
/// Returns the name of the underlying declaration.
5454
const std::string getName() const;
5555
/// Checks if the record is a union.
56-
bool isUnion() const { return getDecl()->isUnion(); }
56+
bool isUnion() const { return IsUnion; }
5757
/// Returns the size of the record.
5858
unsigned getSize() const { return BaseSize; }
5959
/// Returns the full size of the record, including records.
@@ -132,6 +132,8 @@ class Record final {
132132
unsigned BaseSize;
133133
/// Size of all virtual bases.
134134
unsigned VirtualSize;
135+
/// If this record is a union.
136+
bool IsUnion;
135137
};
136138

137139
} // namespace interp

0 commit comments

Comments
 (0)