return CGBitFieldInfo(Offset, Size, IsSigned, StorageSize, StorageOffset);
}
-CGRecordLayout *CodeGenTypes::ComputeRecordLayout(const RecordDecl *D,
- llvm::StructType *Ty) {
+std::unique_ptr<CGRecordLayout>
+CodeGenTypes::ComputeRecordLayout(const RecordDecl *D, llvm::StructType *Ty) {
CGRecordLowering Builder(*this, D, /*Packed=*/false);
Builder.lower(/*NonVirtualBaseType=*/false);
// but we may need to recursively layout D while laying D out as a base type.
Ty->setBody(Builder.FieldTypes, Builder.Packed);
- CGRecordLayout *RL =
- new CGRecordLayout(Ty, BaseTy, Builder.IsZeroInitializable,
- Builder.IsZeroInitializableAsBase);
+ auto RL = std::make_unique<CGRecordLayout>(
+ Ty, BaseTy, (bool)Builder.IsZeroInitializable,
+ (bool)Builder.IsZeroInitializableAsBase);
RL->NonVirtualBases.swap(Builder.NonVirtualBases);
RL->CompleteObjectVirtualBases.swap(Builder.VirtualBases);
}
CodeGenTypes::~CodeGenTypes() {
- llvm::DeleteContainerSeconds(CGRecordLayouts);
-
for (llvm::FoldingSet<CGFunctionInfo>::iterator
I = FunctionInfos.begin(), E = FunctionInfos.end(); I != E; )
delete &*I++;
}
// Layout fields.
- CGRecordLayout *Layout = ComputeRecordLayout(RD, Ty);
- CGRecordLayouts[Key] = Layout;
+ std::unique_ptr<CGRecordLayout> Layout = ComputeRecordLayout(RD, Ty);
+ CGRecordLayouts[Key] = std::move(Layout);
// We're done laying out this struct.
bool EraseResult = RecordsBeingLaidOut.erase(Key); (void)EraseResult;
CodeGenTypes::getCGRecordLayout(const RecordDecl *RD) {
const Type *Key = Context.getTagDeclType(RD).getTypePtr();
- const CGRecordLayout *Layout = CGRecordLayouts.lookup(Key);
- if (!Layout) {
- // Compute the type information.
- ConvertRecordDeclType(RD);
+ auto I = CGRecordLayouts.find(Key);
+ if (I != CGRecordLayouts.end())
+ return *I->second;
+ // Compute the type information.
+ ConvertRecordDeclType(RD);
- // Now try again.
- Layout = CGRecordLayouts.lookup(Key);
- }
+ // Now try again.
+ I = CGRecordLayouts.find(Key);
- assert(Layout && "Unable to find record layout information for type");
- return *Layout;
+ assert(I != CGRecordLayouts.end() &&
+ "Unable to find record layout information for type");
+ return *I->second;
}
bool CodeGenTypes::isPointerZeroInitializable(QualType T) {
llvm::DenseMap<const ObjCInterfaceType*, llvm::Type *> InterfaceTypes;
/// Maps clang struct type with corresponding record layout info.
- llvm::DenseMap<const Type*, CGRecordLayout *> CGRecordLayouts;
+ llvm::DenseMap<const Type*, std::unique_ptr<CGRecordLayout>> CGRecordLayouts;
/// Contains the LLVM IR type for any converted RecordDecl.
llvm::DenseMap<const Type*, llvm::StructType *> RecordDeclTypes;
RequiredArgs args);
/// Compute a new LLVM record layout object for the given record.
- CGRecordLayout *ComputeRecordLayout(const RecordDecl *D,
- llvm::StructType *Ty);
+ std::unique_ptr<CGRecordLayout> ComputeRecordLayout(const RecordDecl *D,
+ llvm::StructType *Ty);
/// addRecordTypeName - Compute a name from the given record decl with an
/// optional suffix and name the given LLVM type using it.