From 7c4b8c0a7921b999f5a73d6ba47ee8350676f747 Mon Sep 17 00:00:00 2001 From: Justin Lebar Date: Mon, 10 Oct 2016 16:26:19 +0000 Subject: [PATCH] [AST] Convert MangleNumberingContext to a unique_ptr. Summary: It doesn't need to be refcounted anymore, either. Reviewers: timshen Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D25420 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@283768 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/AST/ASTContext.h | 4 ++-- include/clang/AST/MangleNumberingContext.h | 2 +- include/clang/Sema/Sema.h | 2 +- lib/AST/ASTContext.cpp | 7 +++---- lib/AST/CXXABI.h | 3 ++- lib/AST/ItaniumCXXABI.cpp | 5 +++-- lib/AST/MicrosoftCXXABI.cpp | 5 +++-- 7 files changed, 15 insertions(+), 13 deletions(-) diff --git a/include/clang/AST/ASTContext.h b/include/clang/AST/ASTContext.h index 7c0d19c56f..95515b51cb 100644 --- a/include/clang/AST/ASTContext.h +++ b/include/clang/AST/ASTContext.h @@ -407,7 +407,7 @@ private: /// \brief Mapping from each declaration context to its corresponding /// mangling numbering context (used for constructs like lambdas which /// need to be consistently numbered for the mangler). - llvm::DenseMap + llvm::DenseMap> MangleNumberingContexts; /// \brief Side-table of mangling numbers for declarations which rarely @@ -2470,7 +2470,7 @@ public: /// DeclContext. MangleNumberingContext &getManglingNumberContext(const DeclContext *DC); - MangleNumberingContext *createMangleNumberingContext() const; + std::unique_ptr createMangleNumberingContext() const; /// \brief Used by ParmVarDecl to store on the side the /// index of the parameter when it exceeds the size of the normal bitfield. diff --git a/include/clang/AST/MangleNumberingContext.h b/include/clang/AST/MangleNumberingContext.h index db260086ab..869221dbf3 100644 --- a/include/clang/AST/MangleNumberingContext.h +++ b/include/clang/AST/MangleNumberingContext.h @@ -29,7 +29,7 @@ class VarDecl; /// \brief Keeps track of the mangled names of lambda expressions and block /// literals within a particular context. -class MangleNumberingContext : public RefCountedBase { +class MangleNumberingContext { public: virtual ~MangleNumberingContext() {} diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h index 1517160180..70f49861e6 100644 --- a/include/clang/Sema/Sema.h +++ b/include/clang/Sema/Sema.h @@ -876,7 +876,7 @@ public: /// /// This mangling information is allocated lazily, since most contexts /// do not have lambda expressions or block literals. - IntrusiveRefCntPtr MangleNumbering; + std::unique_ptr MangleNumbering; /// \brief If we are processing a decltype type, a set of call expressions /// for which we have deferred checking the completeness of the return type. diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index dc99d4dabd..0867747477 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -794,8 +794,6 @@ ASTContext::~ASTContext() { for (const auto &Value : ModuleInitializers) Value.second->~PerModuleInitializers(); - - llvm::DeleteContainerSeconds(MangleNumberingContexts); } void ASTContext::ReleaseParentMapEntries() { @@ -8982,13 +8980,14 @@ unsigned ASTContext::getStaticLocalNumber(const VarDecl *VD) const { MangleNumberingContext & ASTContext::getManglingNumberContext(const DeclContext *DC) { assert(LangOpts.CPlusPlus); // We don't need mangling numbers for plain C. - MangleNumberingContext *&MCtx = MangleNumberingContexts[DC]; + std::unique_ptr &MCtx = MangleNumberingContexts[DC]; if (!MCtx) MCtx = createMangleNumberingContext(); return *MCtx; } -MangleNumberingContext *ASTContext::createMangleNumberingContext() const { +std::unique_ptr +ASTContext::createMangleNumberingContext() const { return ABI->createMangleNumberingContext(); } diff --git a/lib/AST/CXXABI.h b/lib/AST/CXXABI.h index c23b9191c7..e1cf934ee0 100644 --- a/lib/AST/CXXABI.h +++ b/lib/AST/CXXABI.h @@ -43,7 +43,8 @@ public: virtual bool isNearlyEmpty(const CXXRecordDecl *RD) const = 0; /// Returns a new mangling number context for this C++ ABI. - virtual MangleNumberingContext *createMangleNumberingContext() const = 0; + virtual std::unique_ptr + createMangleNumberingContext() const = 0; /// Adds a mapping from class to copy constructor for this C++ ABI. virtual void addCopyConstructorForExceptionObject(CXXRecordDecl *, diff --git a/lib/AST/ItaniumCXXABI.cpp b/lib/AST/ItaniumCXXABI.cpp index 8a2cc0fbee..482c3c5d33 100644 --- a/lib/AST/ItaniumCXXABI.cpp +++ b/lib/AST/ItaniumCXXABI.cpp @@ -163,8 +163,9 @@ public: return nullptr; } - MangleNumberingContext *createMangleNumberingContext() const override { - return new ItaniumNumberingContext(); + std::unique_ptr + createMangleNumberingContext() const override { + return llvm::make_unique(); } }; } diff --git a/lib/AST/MicrosoftCXXABI.cpp b/lib/AST/MicrosoftCXXABI.cpp index 3ae04538d6..bb59fba5ee 100644 --- a/lib/AST/MicrosoftCXXABI.cpp +++ b/lib/AST/MicrosoftCXXABI.cpp @@ -143,8 +143,9 @@ public: const_cast(TD->getCanonicalDecl())); } - MangleNumberingContext *createMangleNumberingContext() const override { - return new MicrosoftNumberingContext(); + std::unique_ptr + createMangleNumberingContext() const override { + return llvm::make_unique(); } }; } -- 2.40.0