Skip to content

Commit

Permalink
[clang][Interp][NFC] Save IsUnion bit for Records
Browse files Browse the repository at this point in the history
Now that we call this more often, try to keep pointer chasing to a
minimum.
  • Loading branch information
tbaederr committed May 23, 2024
1 parent 1a2a0c0 commit 951b13d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion clang/lib/AST/Interp/Record.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Record::Record(const RecordDecl *Decl, BaseList &&SrcBases,
FieldList &&SrcFields, VirtualBaseList &&SrcVirtualBases,
unsigned VirtualSize, unsigned BaseSize)
: Decl(Decl), Bases(std::move(SrcBases)), Fields(std::move(SrcFields)),
BaseSize(BaseSize), VirtualSize(VirtualSize) {
BaseSize(BaseSize), VirtualSize(VirtualSize), IsUnion(Decl->isUnion()) {
for (Base &V : SrcVirtualBases)
VirtualBases.push_back({ V.Decl, V.Offset + BaseSize, V.Desc, V.R });

Expand Down
4 changes: 3 additions & 1 deletion clang/lib/AST/Interp/Record.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class Record final {
/// Returns the name of the underlying declaration.
const std::string getName() const;
/// Checks if the record is a union.
bool isUnion() const { return getDecl()->isUnion(); }
bool isUnion() const { return IsUnion; }
/// Returns the size of the record.
unsigned getSize() const { return BaseSize; }
/// Returns the full size of the record, including records.
Expand Down Expand Up @@ -132,6 +132,8 @@ class Record final {
unsigned BaseSize;
/// Size of all virtual bases.
unsigned VirtualSize;
/// If this record is a union.
bool IsUnion;
};

} // namespace interp
Expand Down

0 comments on commit 951b13d

Please sign in to comment.