Skip to content

Commit 20ebffc

Browse files
author
Justin Lebar
committedOct 10, 2016
[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 llvm-svn: 283768
1 parent 611c5c2 commit 20ebffc

File tree

7 files changed

+15
-13
lines changed

7 files changed

+15
-13
lines changed
 

‎clang/include/clang/AST/ASTContext.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ class ASTContext : public RefCountedBase<ASTContext> {
407407
/// \brief Mapping from each declaration context to its corresponding
408408
/// mangling numbering context (used for constructs like lambdas which
409409
/// need to be consistently numbered for the mangler).
410-
llvm::DenseMap<const DeclContext *, MangleNumberingContext *>
410+
llvm::DenseMap<const DeclContext *, std::unique_ptr<MangleNumberingContext>>
411411
MangleNumberingContexts;
412412

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

2473-
MangleNumberingContext *createMangleNumberingContext() const;
2473+
std::unique_ptr<MangleNumberingContext> createMangleNumberingContext() const;
24742474

24752475
/// \brief Used by ParmVarDecl to store on the side the
24762476
/// index of the parameter when it exceeds the size of the normal bitfield.

‎clang/include/clang/AST/MangleNumberingContext.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class VarDecl;
2929

3030
/// \brief Keeps track of the mangled names of lambda expressions and block
3131
/// literals within a particular context.
32-
class MangleNumberingContext : public RefCountedBase<MangleNumberingContext> {
32+
class MangleNumberingContext {
3333
public:
3434
virtual ~MangleNumberingContext() {}
3535

‎clang/include/clang/Sema/Sema.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -876,7 +876,7 @@ class Sema {
876876
///
877877
/// This mangling information is allocated lazily, since most contexts
878878
/// do not have lambda expressions or block literals.
879-
IntrusiveRefCntPtr<MangleNumberingContext> MangleNumbering;
879+
std::unique_ptr<MangleNumberingContext> MangleNumbering;
880880

881881
/// \brief If we are processing a decltype type, a set of call expressions
882882
/// for which we have deferred checking the completeness of the return type.

‎clang/lib/AST/ASTContext.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -794,8 +794,6 @@ ASTContext::~ASTContext() {
794794

795795
for (const auto &Value : ModuleInitializers)
796796
Value.second->~PerModuleInitializers();
797-
798-
llvm::DeleteContainerSeconds(MangleNumberingContexts);
799797
}
800798

801799
void ASTContext::ReleaseParentMapEntries() {
@@ -8982,13 +8980,14 @@ unsigned ASTContext::getStaticLocalNumber(const VarDecl *VD) const {
89828980
MangleNumberingContext &
89838981
ASTContext::getManglingNumberContext(const DeclContext *DC) {
89848982
assert(LangOpts.CPlusPlus); // We don't need mangling numbers for plain C.
8985-
MangleNumberingContext *&MCtx = MangleNumberingContexts[DC];
8983+
std::unique_ptr<MangleNumberingContext> &MCtx = MangleNumberingContexts[DC];
89868984
if (!MCtx)
89878985
MCtx = createMangleNumberingContext();
89888986
return *MCtx;
89898987
}
89908988

8991-
MangleNumberingContext *ASTContext::createMangleNumberingContext() const {
8989+
std::unique_ptr<MangleNumberingContext>
8990+
ASTContext::createMangleNumberingContext() const {
89928991
return ABI->createMangleNumberingContext();
89938992
}
89948993

‎clang/lib/AST/CXXABI.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ class CXXABI {
4343
virtual bool isNearlyEmpty(const CXXRecordDecl *RD) const = 0;
4444

4545
/// Returns a new mangling number context for this C++ ABI.
46-
virtual MangleNumberingContext *createMangleNumberingContext() const = 0;
46+
virtual std::unique_ptr<MangleNumberingContext>
47+
createMangleNumberingContext() const = 0;
4748

4849
/// Adds a mapping from class to copy constructor for this C++ ABI.
4950
virtual void addCopyConstructorForExceptionObject(CXXRecordDecl *,

‎clang/lib/AST/ItaniumCXXABI.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,9 @@ class ItaniumCXXABI : public CXXABI {
163163
return nullptr;
164164
}
165165

166-
MangleNumberingContext *createMangleNumberingContext() const override {
167-
return new ItaniumNumberingContext();
166+
std::unique_ptr<MangleNumberingContext>
167+
createMangleNumberingContext() const override {
168+
return llvm::make_unique<ItaniumNumberingContext>();
168169
}
169170
};
170171
}

‎clang/lib/AST/MicrosoftCXXABI.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,9 @@ class MicrosoftCXXABI : public CXXABI {
143143
const_cast<TagDecl *>(TD->getCanonicalDecl()));
144144
}
145145

146-
MangleNumberingContext *createMangleNumberingContext() const override {
147-
return new MicrosoftNumberingContext();
146+
std::unique_ptr<MangleNumberingContext>
147+
createMangleNumberingContext() const override {
148+
return llvm::make_unique<MicrosoftNumberingContext>();
148149
}
149150
};
150151
}

0 commit comments

Comments
 (0)
Please sign in to comment.