r283769 - [AST] Use unique_ptr for VTableLayout.
Justin Lebar via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 10 09:26:25 PDT 2016
Author: jlebar
Date: Mon Oct 10 11:26:24 2016
New Revision: 283769
URL: http://llvm.org/viewvc/llvm-project?rev=283769&view=rev
Log:
[AST] Use unique_ptr for VTableLayout.
Reviewers: timshen
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D25421
Modified:
cfe/trunk/include/clang/AST/VTableBuilder.h
cfe/trunk/lib/AST/VTableBuilder.cpp
Modified: cfe/trunk/include/clang/AST/VTableBuilder.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/VTableBuilder.h?rev=283769&r1=283768&r2=283769&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/VTableBuilder.h (original)
+++ cfe/trunk/include/clang/AST/VTableBuilder.h Mon Oct 10 11:26:24 2016
@@ -313,8 +313,9 @@ private:
typedef llvm::DenseMap<GlobalDecl, int64_t> MethodVTableIndicesTy;
MethodVTableIndicesTy MethodVTableIndices;
- typedef llvm::DenseMap<const CXXRecordDecl *, const VTableLayout *>
- VTableLayoutMapTy;
+ typedef llvm::DenseMap<const CXXRecordDecl *,
+ std::unique_ptr<const VTableLayout>>
+ VTableLayoutMapTy;
VTableLayoutMapTy VTableLayouts;
typedef std::pair<const CXXRecordDecl *,
@@ -341,11 +342,9 @@ public:
return *VTableLayouts[RD];
}
- VTableLayout *
- createConstructionVTableLayout(const CXXRecordDecl *MostDerivedClass,
- CharUnits MostDerivedClassOffset,
- bool MostDerivedClassIsVirtual,
- const CXXRecordDecl *LayoutClass);
+ std::unique_ptr<VTableLayout> createConstructionVTableLayout(
+ const CXXRecordDecl *MostDerivedClass, CharUnits MostDerivedClassOffset,
+ bool MostDerivedClassIsVirtual, const CXXRecordDecl *LayoutClass);
/// \brief Locate a virtual function in the vtable.
///
Modified: cfe/trunk/lib/AST/VTableBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/VTableBuilder.cpp?rev=283769&r1=283768&r2=283769&view=diff
==============================================================================
--- cfe/trunk/lib/AST/VTableBuilder.cpp (original)
+++ cfe/trunk/lib/AST/VTableBuilder.cpp Mon Oct 10 11:26:24 2016
@@ -2234,9 +2234,7 @@ VTableLayout::~VTableLayout() { }
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 @@ ItaniumVTableContext::getVirtualBaseOffs
return I->second;
}
-static VTableLayout *CreateVTableLayout(const ItaniumVTableBuilder &Builder) {
+static std::unique_ptr<VTableLayout>
+CreateVTableLayout(const ItaniumVTableBuilder &Builder) {
SmallVector<VTableLayout::VTableThunkTy, 1>
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<VTableLayout>(
+ 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<const VTableLayout> &Entry = VTableLayouts[RD];
// Check if we've computed this information before.
if (Entry)
@@ -2330,7 +2327,8 @@ ItaniumVTableContext::computeVTableRelat
}
}
-VTableLayout *ItaniumVTableContext::createConstructionVTableLayout(
+std::unique_ptr<VTableLayout>
+ItaniumVTableContext::createConstructionVTableLayout(
const CXXRecordDecl *MostDerivedClass, CharUnits MostDerivedClassOffset,
bool MostDerivedClassIsVirtual, const CXXRecordDecl *LayoutClass) {
ItaniumVTableBuilder Builder(*this, MostDerivedClass, MostDerivedClassOffset,
More information about the cfe-commits
mailing list