[Clang] Add helper method to determine if a nonvirtual base has an entry in the LLVM struct

This patch adds a helper method to determine if a nonvirtual base has an entry in the LLVM struct. Such a base may not have an entry
if the base does not have any fields/bases itself that would change the size of the struct. This utility method is useful for other frontends (Polygeist) that use Clang as an API to generate code.

Reviewed By: efriedma

Differential Revision: https://reviews.llvm.org/D122502
This commit is contained in:
William S. Moses 2022-03-25 15:39:43 -04:00
parent 6aa0397758
commit 89525cbf28
1 changed files with 6 additions and 0 deletions

View File

@ -200,6 +200,12 @@ public:
return FieldInfo.lookup(FD);
}
// Return whether the following non virtual base has a corresponding
// entry in the LLVM struct.
bool hasNonVirtualBaseLLVMField(const CXXRecordDecl *RD) const {
return NonVirtualBases.count(RD);
}
unsigned getNonVirtualBaseLLVMFieldNo(const CXXRecordDecl *RD) const {
assert(NonVirtualBases.count(RD) && "Invalid non-virtual base!");
return NonVirtualBases.lookup(RD);