wsmoses created this revision.
wsmoses added reviewers: jdoerfert, ftynse, eli.friedman, stuij, ostannard.
Herald added a project: All.
wsmoses requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
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.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D122502
Files:
clang/lib/CodeGen/CGRecordLayout.h
Index: clang/lib/CodeGen/CGRecordLayout.h
===================================================================
--- clang/lib/CodeGen/CGRecordLayout.h
+++ clang/lib/CodeGen/CGRecordLayout.h
@@ -200,6 +200,12 @@
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);
Index: clang/lib/CodeGen/CGRecordLayout.h
===================================================================
--- clang/lib/CodeGen/CGRecordLayout.h
+++ clang/lib/CodeGen/CGRecordLayout.h
@@ -200,6 +200,12 @@
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);
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits