Index: clang/include/clang/AST/VTableBuilder.h =================================================================== --- clang/include/clang/AST/VTableBuilder.h +++ clang/include/clang/AST/VTableBuilder.h @@ -313,8 +313,9 @@ typedef llvm::DenseMap MethodVTableIndicesTy; MethodVTableIndicesTy MethodVTableIndices; - typedef llvm::DenseMap - VTableLayoutMapTy; + typedef llvm::DenseMap> + VTableLayoutMapTy; VTableLayoutMapTy VTableLayouts; typedef std::pair createConstructionVTableLayout( + const CXXRecordDecl *MostDerivedClass, CharUnits MostDerivedClassOffset, + bool MostDerivedClassIsVirtual, const CXXRecordDecl *LayoutClass); /// \brief Locate a virtual function in the vtable. /// Index: clang/lib/AST/VTableBuilder.cpp =================================================================== --- clang/lib/AST/VTableBuilder.cpp +++ clang/lib/AST/VTableBuilder.cpp @@ -2234,9 +2234,7 @@ ItaniumVTableContext::ItaniumVTableContext(ASTContext &Context) : VTableContextBase(/*MS=*/false) {} -ItaniumVTableContext::~ItaniumVTableContext() { - llvm::DeleteContainerSeconds(VTableLayouts); -} +ItaniumVTableContext::~ItaniumVTableContext() {} uint64_t ItaniumVTableContext::getMethodVTableIndex(GlobalDecl GD) { MethodVTableIndicesTy::iterator I = MethodVTableIndices.find(GD); @@ -2280,21 +2278,20 @@ return I->second; } -static VTableLayout *CreateVTableLayout(const ItaniumVTableBuilder &Builder) { +static std::unique_ptr +CreateVTableLayout(const ItaniumVTableBuilder &Builder) { SmallVector VTableThunks(Builder.vtable_thunks_begin(), Builder.vtable_thunks_end()); - return new VTableLayout(Builder.getNumVTableComponents(), - Builder.vtable_component_begin(), - VTableThunks.size(), - VTableThunks.data(), - Builder.getAddressPoints(), - /*IsMicrosoftABI=*/false); + return llvm::make_unique( + Builder.getNumVTableComponents(), Builder.vtable_component_begin(), + VTableThunks.size(), VTableThunks.data(), Builder.getAddressPoints(), + /*IsMicrosoftABI=*/false); } void ItaniumVTableContext::computeVTableRelatedInformation(const CXXRecordDecl *RD) { - const VTableLayout *&Entry = VTableLayouts[RD]; + std::unique_ptr &Entry = VTableLayouts[RD]; // Check if we've computed this information before. if (Entry) @@ -2330,7 +2327,8 @@ } } -VTableLayout *ItaniumVTableContext::createConstructionVTableLayout( +std::unique_ptr +ItaniumVTableContext::createConstructionVTableLayout( const CXXRecordDecl *MostDerivedClass, CharUnits MostDerivedClassOffset, bool MostDerivedClassIsVirtual, const CXXRecordDecl *LayoutClass) { ItaniumVTableBuilder Builder(*this, MostDerivedClass, MostDerivedClassOffset,