Author: William S. Moses
Date: 2022-03-25T16:32:12-04:00
New Revision: 89525cbf283f1ffeca1e007a06b29917a9eadc53

URL: 
https://github.com/llvm/llvm-project/commit/89525cbf283f1ffeca1e007a06b29917a9eadc53
DIFF: 
https://github.com/llvm/llvm-project/commit/89525cbf283f1ffeca1e007a06b29917a9eadc53.diff

LOG: [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

Added: 
    

Modified: 
    clang/lib/CodeGen/CGRecordLayout.h

Removed: 
    


################################################################################
diff  --git a/clang/lib/CodeGen/CGRecordLayout.h 
b/clang/lib/CodeGen/CGRecordLayout.h
index 5a3bcdf72f7b6..d5ea74922603b 100644
--- a/clang/lib/CodeGen/CGRecordLayout.h
+++ b/clang/lib/CodeGen/CGRecordLayout.h
@@ -200,6 +200,12 @@ class CGRecordLayout {
     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
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to