Skip to content
This repository has been archived by the owner on Apr 23, 2020. It is now read-only.

Commit

Permalink
[AST] Convert MangleNumberingContext to a unique_ptr.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Justin Lebar committed Oct 10, 2016
1 parent 1f062cd commit 7c4b8c0
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 13 deletions.
4 changes: 2 additions & 2 deletions include/clang/AST/ASTContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ class ASTContext : public RefCountedBase<ASTContext> {
/// \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<const DeclContext *, MangleNumberingContext *>
llvm::DenseMap<const DeclContext *, std::unique_ptr<MangleNumberingContext>>
MangleNumberingContexts;

/// \brief Side-table of mangling numbers for declarations which rarely
Expand Down Expand Up @@ -2470,7 +2470,7 @@ class ASTContext : public RefCountedBase<ASTContext> {
/// DeclContext.
MangleNumberingContext &getManglingNumberContext(const DeclContext *DC);

MangleNumberingContext *createMangleNumberingContext() const;
std::unique_ptr<MangleNumberingContext> 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.
Expand Down
2 changes: 1 addition & 1 deletion include/clang/AST/MangleNumberingContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<MangleNumberingContext> {
class MangleNumberingContext {
public:
virtual ~MangleNumberingContext() {}

Expand Down
2 changes: 1 addition & 1 deletion include/clang/Sema/Sema.h
Original file line number Diff line number Diff line change
Expand Up @@ -876,7 +876,7 @@ class Sema {
///
/// This mangling information is allocated lazily, since most contexts
/// do not have lambda expressions or block literals.
IntrusiveRefCntPtr<MangleNumberingContext> MangleNumbering;
std::unique_ptr<MangleNumberingContext> 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.
Expand Down
7 changes: 3 additions & 4 deletions lib/AST/ASTContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -794,8 +794,6 @@ ASTContext::~ASTContext() {

for (const auto &Value : ModuleInitializers)
Value.second->~PerModuleInitializers();

llvm::DeleteContainerSeconds(MangleNumberingContexts);
}

void ASTContext::ReleaseParentMapEntries() {
Expand Down Expand Up @@ -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<MangleNumberingContext> &MCtx = MangleNumberingContexts[DC];
if (!MCtx)
MCtx = createMangleNumberingContext();
return *MCtx;
}

MangleNumberingContext *ASTContext::createMangleNumberingContext() const {
std::unique_ptr<MangleNumberingContext>
ASTContext::createMangleNumberingContext() const {
return ABI->createMangleNumberingContext();
}

Expand Down
3 changes: 2 additions & 1 deletion lib/AST/CXXABI.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ class CXXABI {
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<MangleNumberingContext>
createMangleNumberingContext() const = 0;

/// Adds a mapping from class to copy constructor for this C++ ABI.
virtual void addCopyConstructorForExceptionObject(CXXRecordDecl *,
Expand Down
5 changes: 3 additions & 2 deletions lib/AST/ItaniumCXXABI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,9 @@ class ItaniumCXXABI : public CXXABI {
return nullptr;
}

MangleNumberingContext *createMangleNumberingContext() const override {
return new ItaniumNumberingContext();
std::unique_ptr<MangleNumberingContext>
createMangleNumberingContext() const override {
return llvm::make_unique<ItaniumNumberingContext>();
}
};
}
Expand Down
5 changes: 3 additions & 2 deletions lib/AST/MicrosoftCXXABI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,9 @@ class MicrosoftCXXABI : public CXXABI {
const_cast<TagDecl *>(TD->getCanonicalDecl()));
}

MangleNumberingContext *createMangleNumberingContext() const override {
return new MicrosoftNumberingContext();
std::unique_ptr<MangleNumberingContext>
createMangleNumberingContext() const override {
return llvm::make_unique<MicrosoftNumberingContext>();
}
};
}
Expand Down

0 comments on commit 7c4b8c0

Please sign in to comment.