[cfe-commits] r79922 - in /cfe/trunk/lib/CodeGen: CGExprConstant.cpp CodeGenTypes.cpp CodeGenTypes.h

Anders Carlsson andersca at mac.com
Mon Aug 24 10:16:23 PDT 2009


Author: andersca
Date: Mon Aug 24 12:16:23 2009
New Revision: 79922

URL: http://llvm.org/viewvc/llvm-project?rev=79922&view=rev
Log:
More member pointer work.

Modified:
    cfe/trunk/lib/CodeGen/CGExprConstant.cpp
    cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
    cfe/trunk/lib/CodeGen/CodeGenTypes.h

Modified: cfe/trunk/lib/CodeGen/CGExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprConstant.cpp?rev=79922&r1=79921&r2=79922&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprConstant.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprConstant.cpp Mon Aug 24 12:16:23 2009
@@ -783,6 +783,10 @@
 }
 
 llvm::Constant *CodeGenModule::EmitNullConstant(QualType T) {
+  // No need to check for member pointers when not compiling C++.
+  if (!getContext().getLangOptions().CPlusPlus)
+    return llvm::Constant::getNullValue(getTypes().ConvertTypeForMem(T));
+    
   if (const ConstantArrayType *CAT = Context.getAsConstantArrayType(T)) {
     
     QualType ElementTy = CAT->getElementType();
@@ -801,15 +805,17 @@
     }
   }
 
-#if 0
   if (const RecordType *RT = T->getAs<RecordType>()) {
-    const CGRecordLayout *Layout = Types.getCGRecordLayout(RT->getDecl());
-    if (Layout->containsMemberPointer()) {
+    const RecordDecl *RD = RT->getDecl();
+    // FIXME: It would be better if there was a way to explicitly compute the 
+    // record layout instead of converting to a type.
+    Types.ConvertTagDeclType(RD);
+    
+    const CGRecordLayout &Layout = Types.getCGRecordLayout(RD);
+    if (Layout.containsMemberPointer()) {
       assert(0 && "FIXME: No support for structs with member pointers yet!");
     }
-
   }
-#endif
   
   // FIXME: Handle structs that contain member pointers.
   if (T->isMemberPointerType()) 

Modified: cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenTypes.cpp?rev=79922&r1=79921&r2=79922&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenTypes.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenTypes.cpp Mon Aug 24 12:16:23 2009
@@ -479,7 +479,7 @@
 }
 
 /// getCGRecordLayout - Return record layout info for the given llvm::Type.
-const CGRecordLayout *
+const CGRecordLayout &
 CodeGenTypes::getCGRecordLayout(const TagDecl *TD) const {
   const Type *Key = 
     Context.getTagDeclType(TD).getTypePtr();
@@ -487,5 +487,5 @@
     = CGRecordLayouts.find(Key);
   assert (I != CGRecordLayouts.end() 
           && "Unable to find record layout information for type");
-  return I->second;
+  return *I->second;
 }

Modified: cfe/trunk/lib/CodeGen/CodeGenTypes.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenTypes.h?rev=79922&r1=79921&r2=79922&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenTypes.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenTypes.h Mon Aug 24 12:16:23 2009
@@ -162,7 +162,7 @@
   const llvm::FunctionType *GetFunctionType(const CGFunctionInfo &Info,
                                             bool IsVariadic);
   
-  const CGRecordLayout *getCGRecordLayout(const TagDecl*) const;
+  const CGRecordLayout &getCGRecordLayout(const TagDecl*) const;
   
   /// getLLVMFieldNo - Return llvm::StructType element number
   /// that corresponds to the field FD.





More information about the cfe-commits mailing list