forked from OSchip/llvm-project
parent
4557b2c0c2
commit
867b48f713
|
@ -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())
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue