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

William Moses via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 25 12:42:06 PDT 2022


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);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D122502.418300.patch
Type: text/x-patch
Size: 653 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220325/48208fb1/attachment.bin>


More information about the cfe-commits mailing list