diff options
author | Anders Carlsson <andersca@mac.com> | 2009-08-24 17:16:23 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2009-08-24 17:16:23 +0000 |
commit | ad3e7118c40711faf5f51f08d599dbd525d3408a (patch) | |
tree | 4fe78e44a506ba59dcc7d7e344a712acf07b807a | |
parent | 2d82719c580f878e0810d868b366a3ac2d00746f (diff) |
More member pointer work.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79922 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/CodeGen/CGExprConstant.cpp | 16 | ||||
-rw-r--r-- | lib/CodeGen/CodeGenTypes.cpp | 4 | ||||
-rw-r--r-- | lib/CodeGen/CodeGenTypes.h | 2 |
3 files changed, 14 insertions, 8 deletions
diff --git a/lib/CodeGen/CGExprConstant.cpp b/lib/CodeGen/CGExprConstant.cpp index 93c0647b78..2be22f98ab 100644 --- a/lib/CodeGen/CGExprConstant.cpp +++ b/lib/CodeGen/CGExprConstant.cpp @@ -783,6 +783,10 @@ llvm::Constant *CodeGenModule::EmitConstantExpr(const Expr *E, } 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 @@ llvm::Constant *CodeGenModule::EmitNullConstant(QualType T) { } } -#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()) diff --git a/lib/CodeGen/CodeGenTypes.cpp b/lib/CodeGen/CodeGenTypes.cpp index 52499d98c4..48f8192094 100644 --- a/lib/CodeGen/CodeGenTypes.cpp +++ b/lib/CodeGen/CodeGenTypes.cpp @@ -479,7 +479,7 @@ void CodeGenTypes::addBitFieldInfo(const FieldDecl *FD, unsigned FieldNo, } /// 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 @@ CodeGenTypes::getCGRecordLayout(const TagDecl *TD) const { = CGRecordLayouts.find(Key); assert (I != CGRecordLayouts.end() && "Unable to find record layout information for type"); - return I->second; + return *I->second; } diff --git a/lib/CodeGen/CodeGenTypes.h b/lib/CodeGen/CodeGenTypes.h index 22ebbf1682..f8df1b429b 100644 --- a/lib/CodeGen/CodeGenTypes.h +++ b/lib/CodeGen/CodeGenTypes.h @@ -162,7 +162,7 @@ public: 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. |