/***/
void CodeGenTypes::GetExpandedTypes(QualType Ty,
- std::vector<const llvm::Type*> &ArgTys) {
+ std::vector<const llvm::Type*> &ArgTys,
+ bool IsRecursive) {
const RecordType *RT = Ty->getAsStructureType();
assert(RT && "Can only expand structure types.");
const RecordDecl *RD = RT->getDecl();
QualType FT = FD->getType();
if (CodeGenFunction::hasAggregateLLVMType(FT)) {
- GetExpandedTypes(FT, ArgTys);
+ GetExpandedTypes(FT, ArgTys, IsRecursive);
} else {
- ArgTys.push_back(ConvertType(FT));
+ ArgTys.push_back(ConvertType(FT, IsRecursive));
}
}
}
cast<FunctionDecl>(GD.getDecl())->getType()->getAs<FunctionProtoType>())
Variadic = FPT->isVariadic();
- return GetFunctionType(FI, Variadic);
+ return GetFunctionType(FI, Variadic, false);
}
const llvm::FunctionType *
-CodeGenTypes::GetFunctionType(const CGFunctionInfo &FI, bool IsVariadic) {
+CodeGenTypes::GetFunctionType(const CGFunctionInfo &FI, bool IsVariadic,
+ bool IsRecursive) {
std::vector<const llvm::Type*> ArgTys;
const llvm::Type *ResultType = 0;
case ABIArgInfo::Extend:
case ABIArgInfo::Direct:
- ResultType = ConvertType(RetTy);
+ ResultType = ConvertType(RetTy, IsRecursive);
break;
case ABIArgInfo::Indirect: {
assert(!RetAI.getIndirectAlign() && "Align unused on indirect return.");
ResultType = llvm::Type::getVoidTy(getLLVMContext());
- const llvm::Type *STy = ConvertType(RetTy);
+ const llvm::Type *STy = ConvertType(RetTy, IsRecursive);
ArgTys.push_back(llvm::PointerType::get(STy, RetTy.getAddressSpace()));
break;
}
case ABIArgInfo::Extend:
case ABIArgInfo::Direct:
- ArgTys.push_back(ConvertType(it->type));
+ ArgTys.push_back(ConvertType(it->type, IsRecursive));
break;
case ABIArgInfo::Expand:
- GetExpandedTypes(it->type, ArgTys);
+ GetExpandedTypes(it->type, ArgTys, IsRecursive);
break;
}
}
const FunctionProtoType *FPT = MD->getType()->getAs<FunctionProtoType>();
if (!VerifyFuncTypeComplete(FPT))
- return GetFunctionType(getFunctionInfo(MD), FPT->isVariadic());
+ return GetFunctionType(getFunctionInfo(MD), FPT->isVariadic(), false);
return llvm::OpaqueType::get(getLLVMContext());
}
// FIXME: This is rather inefficient. Do we ever actually need to do
// anything here? The result should be just reconstructed on the other
// side, so extension should be a non-issue.
- getTypes().GetExpandedTypes(ParamType, Tys);
+ getTypes().GetExpandedTypes(ParamType, Tys, false);
Index += Tys.size();
continue;
}
}
/// ConvertType - Convert the specified type to its LLVM form.
-const llvm::Type *CodeGenTypes::ConvertType(QualType T) {
- llvm::PATypeHolder Result = ConvertTypeRecursive(T);
+const llvm::Type *CodeGenTypes::ConvertType(QualType T, bool IsRecursive) {
+ const llvm::Type *RawResult = ConvertTypeRecursive(T);
+
+ if (IsRecursive || PointersToResolve.empty())
+ return RawResult;
+ llvm::PATypeHolder Result = RawResult;
+
// Any pointers that were converted deferred evaluation of their pointee type,
// creating an opaque type instead. This is in order to avoid problems with
// circular types. Loop through all these defered pointees, if any, and
isVariadic = true;
}
- return GetFunctionType(*FI, isVariadic);
+ return GetFunctionType(*FI, isVariadic, true);
}
case Type::ObjCObject:
llvm::LLVMContext &getLLVMContext() { return TheModule.getContext(); }
/// ConvertType - Convert type T into a llvm::Type.
- const llvm::Type *ConvertType(QualType T);
+ const llvm::Type *ConvertType(QualType T, bool IsRecursive = false);
const llvm::Type *ConvertTypeRecursive(QualType T);
/// ConvertTypeForMem - Convert type T into a llvm::Type. This differs from
/// GetFunctionType - Get the LLVM function type for \arg Info.
const llvm::FunctionType *GetFunctionType(const CGFunctionInfo &Info,
- bool IsVariadic);
+ bool IsVariadic,
+ bool IsRecursive = false);
const llvm::FunctionType *GetFunctionType(GlobalDecl GD);
/// GetExpandedTypes - Expand the type \arg Ty into the LLVM
/// argument types it would be passed as on the provided vector \arg
/// ArgTys. See ABIArgInfo::Expand.
- void GetExpandedTypes(QualType Ty, std::vector<const llvm::Type*> &ArgTys);
+ void GetExpandedTypes(QualType Ty, std::vector<const llvm::Type*> &ArgTys,
+ bool IsRecursive);
/// ContainsPointerToDataMember - Return whether the given type contains a
/// pointer to a data member.