diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2012-11-28 03:56:16 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2012-11-28 03:56:16 +0000 |
commit | 2a82ca255b0f99f6201a75ed52b91fc024f6e9cf (patch) | |
tree | 00f70fe926c9c2aa20b81c9938cb14780e4faffd /lib | |
parent | 9d29543284e75648ac89c6e9586fc7cf786cf66f (diff) |
Introduce ASTUnresolvedSet, an UnresolvedSet-like class, whose contents are
allocated using the allocator associated with an ASTContext.
Use this inside CXXRecordDecl::DefinitionData instead of an UnresolvedSet to
avoid a potential memory leak.
rdar://12761275
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@168771 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/AST/DeclCXX.cpp | 20 | ||||
-rw-r--r-- | lib/Serialization/ASTReader.cpp | 5 | ||||
-rw-r--r-- | lib/Serialization/ASTReaderStmt.cpp | 2 | ||||
-rw-r--r-- | lib/Serialization/ASTWriter.cpp | 4 |
4 files changed, 16 insertions, 15 deletions
diff --git a/lib/AST/DeclCXX.cpp b/lib/AST/DeclCXX.cpp index bf6107f052..d661aa04af 100644 --- a/lib/AST/DeclCXX.cpp +++ b/lib/AST/DeclCXX.cpp @@ -709,13 +709,13 @@ NotASpecialMember:; data().Conversions.replace(FunTmpl->getPreviousDecl(), FunTmpl); else - data().Conversions.addDecl(FunTmpl); + data().Conversions.addDecl(getASTContext(), FunTmpl); } else { if (Conversion->getPreviousDecl()) data().Conversions.replace(Conversion->getPreviousDecl(), Conversion); else - data().Conversions.addDecl(Conversion); + data().Conversions.addDecl(getASTContext(), Conversion); } } @@ -935,7 +935,7 @@ NotASpecialMember:; if (UsingShadowDecl *Shadow = dyn_cast<UsingShadowDecl>(D)) if (Shadow->getDeclName().getNameKind() == DeclarationName::CXXConversionFunctionName) - data().Conversions.addDecl(Shadow, Shadow->getAccess()); + data().Conversions.addDecl(getASTContext(), Shadow, Shadow->getAccess()); } bool CXXRecordDecl::isCLike() const { @@ -996,7 +996,7 @@ static void CollectVisibleConversions(ASTContext &Context, bool InVirtual, AccessSpecifier Access, const llvm::SmallPtrSet<CanQualType, 8> &ParentHiddenTypes, - UnresolvedSetImpl &Output, + ASTUnresolvedSet &Output, UnresolvedSetImpl &VOutput, llvm::SmallPtrSet<NamedDecl*, 8> &HiddenVBaseCs) { // The set of types which have conversions in this class or its @@ -1032,7 +1032,7 @@ static void CollectVisibleConversions(ASTContext &Context, if (InVirtual) VOutput.addDecl(I.getDecl(), IAccess); else - Output.addDecl(I.getDecl(), IAccess); + Output.addDecl(Context, I.getDecl(), IAccess); } } } @@ -1059,7 +1059,7 @@ static void CollectVisibleConversions(ASTContext &Context, /// bases. It might be worth special-casing that, really. static void CollectVisibleConversions(ASTContext &Context, CXXRecordDecl *Record, - UnresolvedSetImpl &Output) { + ASTUnresolvedSet &Output) { // The collection of all conversions in virtual bases that we've // found. These will be added to the output as long as they don't // appear in the hidden-conversions set. @@ -1076,7 +1076,7 @@ static void CollectVisibleConversions(ASTContext &Context, // hidden-types set. CXXRecordDecl::conversion_iterator ConvI = Record->conversion_begin(); CXXRecordDecl::conversion_iterator ConvE = Record->conversion_end(); - Output.append(ConvI, ConvE); + Output.append(Context, ConvI, ConvE); for (; ConvI != ConvE; ++ConvI) HiddenTypes.insert(GetConversionType(Context, ConvI.getDecl())); @@ -1095,7 +1095,7 @@ static void CollectVisibleConversions(ASTContext &Context, for (UnresolvedSetIterator I = VBaseCs.begin(), E = VBaseCs.end(); I != E; ++I) { if (!HiddenVBaseCs.count(cast<NamedDecl>(I.getDecl()->getCanonicalDecl()))) - Output.addDecl(I.getDecl(), I.getAccess()); + Output.addDecl(Context, I.getDecl(), I.getAccess()); } } @@ -1127,7 +1127,7 @@ void CXXRecordDecl::removeConversion(const NamedDecl *ConvDecl) { // with sufficiently large numbers of directly-declared conversions // that asymptotic behavior matters. - UnresolvedSetImpl &Convs = data().Conversions; + ASTUnresolvedSet &Convs = data().Conversions; for (unsigned I = 0, E = Convs.size(); I != E; ++I) { if (Convs[I].getDecl() == ConvDecl) { Convs.erase(I); @@ -1266,7 +1266,7 @@ void CXXRecordDecl::completeDefinition(CXXFinalOverriderMap *FinalOverriders) { for (UnresolvedSetIterator I = data().Conversions.begin(), E = data().Conversions.end(); I != E; ++I) - data().Conversions.setAccess(I, (*I)->getAccess()); + I.setAccess((*I)->getAccess()); } bool CXXRecordDecl::mayBeAbstract() const { diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp index 6e82cd9c76..ffed8356c9 100644 --- a/lib/Serialization/ASTReader.cpp +++ b/lib/Serialization/ASTReader.cpp @@ -6448,13 +6448,14 @@ ReadTemplateArgumentList(SmallVector<TemplateArgument, 8> &TemplArgs, } /// \brief Read a UnresolvedSet structure. -void ASTReader::ReadUnresolvedSet(ModuleFile &F, UnresolvedSetImpl &Set, +void ASTReader::ReadUnresolvedSet(ModuleFile &F, ASTUnresolvedSet &Set, const RecordData &Record, unsigned &Idx) { unsigned NumDecls = Record[Idx++]; + Set.reserve(Context, NumDecls); while (NumDecls--) { NamedDecl *D = ReadDeclAs<NamedDecl>(F, Record, Idx); AccessSpecifier AS = (AccessSpecifier)Record[Idx++]; - Set.addDecl(D, AS); + Set.addDecl(Context, D, AS); } } diff --git a/lib/Serialization/ASTReaderStmt.cpp b/lib/Serialization/ASTReaderStmt.cpp index 367f75f55e..529cfea433 100644 --- a/lib/Serialization/ASTReaderStmt.cpp +++ b/lib/Serialization/ASTReaderStmt.cpp @@ -1868,7 +1868,7 @@ Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) { break; case EXPR_INIT_LIST: - S = new (Context) InitListExpr(getContext(), Empty); + S = new (Context) InitListExpr(Empty); break; case EXPR_DESIGNATED_INIT: diff --git a/lib/Serialization/ASTWriter.cpp b/lib/Serialization/ASTWriter.cpp index 744ae9fd81..41665d8969 100644 --- a/lib/Serialization/ASTWriter.cpp +++ b/lib/Serialization/ASTWriter.cpp @@ -4480,9 +4480,9 @@ ASTWriter::AddTemplateArgumentList(const TemplateArgumentList *TemplateArgs, void -ASTWriter::AddUnresolvedSet(const UnresolvedSetImpl &Set, RecordDataImpl &Record) { +ASTWriter::AddUnresolvedSet(const ASTUnresolvedSet &Set, RecordDataImpl &Record) { Record.push_back(Set.size()); - for (UnresolvedSetImpl::const_iterator + for (ASTUnresolvedSet::const_iterator I = Set.begin(), E = Set.end(); I != E; ++I) { AddDeclRef(I.getDecl(), Record); Record.push_back(I.getAccess()); |