diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2010-11-10 05:40:41 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2010-11-10 05:40:41 +0000 |
commit | 826faa22bae112e01293a58534a40711043cce65 (patch) | |
tree | 8e8e2eeea405146cf6260866f7b66287e7e3cb74 /lib/Serialization | |
parent | 021aaa4f6b86bc9e2801f3475d1ec3dd7bc008c7 (diff) |
Replace UsingDecl's SmallPtrSet of UsingShadowDecls with a linked list to avoid leaking memory.
Fixes rdar://8649963.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@118674 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Serialization')
-rw-r--r-- | lib/Serialization/ASTReaderDecl.cpp | 13 | ||||
-rw-r--r-- | lib/Serialization/ASTWriterDecl.cpp | 7 |
2 files changed, 4 insertions, 16 deletions
diff --git a/lib/Serialization/ASTReaderDecl.cpp b/lib/Serialization/ASTReaderDecl.cpp index 4fca0927cf..e49447063e 100644 --- a/lib/Serialization/ASTReaderDecl.cpp +++ b/lib/Serialization/ASTReaderDecl.cpp @@ -717,16 +717,7 @@ void ASTDeclReader::VisitUsingDecl(UsingDecl *D) { D->setNestedNameRange(ReadSourceRange(Record, Idx)); D->setTargetNestedNameDecl(Reader.ReadNestedNameSpecifier(Record, Idx)); ReadDeclarationNameLoc(D->DNLoc, D->getDeclName(), Record, Idx); - - // FIXME: It would probably be more efficient to read these into a vector - // and then re-cosntruct the shadow decl set over that vector since it - // would avoid existence checks. - unsigned NumShadows = Record[Idx++]; - for(unsigned I = 0; I != NumShadows; ++I) { - // Avoid invariant checking of UsingDecl::addShadowDecl, the decl may still - // be initializing. - D->Shadows.insert(cast<UsingShadowDecl>(Reader.GetDecl(Record[Idx++]))); - } + D->FirstUsingShadow = cast_or_null<UsingShadowDecl>(Reader.GetDecl(Record[Idx++])); D->setTypeName(Record[Idx++]); NamedDecl *Pattern = cast_or_null<NamedDecl>(Reader.GetDecl(Record[Idx++])); if (Pattern) @@ -736,7 +727,7 @@ void ASTDeclReader::VisitUsingDecl(UsingDecl *D) { void ASTDeclReader::VisitUsingShadowDecl(UsingShadowDecl *D) { VisitNamedDecl(D); D->setTargetDecl(cast<NamedDecl>(Reader.GetDecl(Record[Idx++]))); - D->setUsingDecl(cast<UsingDecl>(Reader.GetDecl(Record[Idx++]))); + D->UsingOrNextShadow = cast_or_null<NamedDecl>(Reader.GetDecl(Record[Idx++])); UsingShadowDecl *Pattern = cast_or_null<UsingShadowDecl>(Reader.GetDecl(Record[Idx++])); if (Pattern) diff --git a/lib/Serialization/ASTWriterDecl.cpp b/lib/Serialization/ASTWriterDecl.cpp index de58cd03a4..609a04432b 100644 --- a/lib/Serialization/ASTWriterDecl.cpp +++ b/lib/Serialization/ASTWriterDecl.cpp @@ -673,10 +673,7 @@ void ASTDeclWriter::VisitUsingDecl(UsingDecl *D) { Writer.AddSourceLocation(D->getUsingLocation(), Record); Writer.AddNestedNameSpecifier(D->getTargetNestedNameDecl(), Record); Writer.AddDeclarationNameLoc(D->DNLoc, D->getDeclName(), Record); - Record.push_back(D->getNumShadowDecls()); - for (UsingDecl::shadow_iterator P = D->shadow_begin(), - PEnd = D->shadow_end(); P != PEnd; ++P) - Writer.AddDeclRef(*P, Record); + Writer.AddDeclRef(D->FirstUsingShadow, Record); Record.push_back(D->isTypeName()); Writer.AddDeclRef(Context.getInstantiatedFromUsingDecl(D), Record); Code = serialization::DECL_USING; @@ -685,7 +682,7 @@ void ASTDeclWriter::VisitUsingDecl(UsingDecl *D) { void ASTDeclWriter::VisitUsingShadowDecl(UsingShadowDecl *D) { VisitNamedDecl(D); Writer.AddDeclRef(D->getTargetDecl(), Record); - Writer.AddDeclRef(D->getUsingDecl(), Record); + Writer.AddDeclRef(D->UsingOrNextShadow, Record); Writer.AddDeclRef(Context.getInstantiatedFromUsingShadowDecl(D), Record); Code = serialization::DECL_USING_SHADOW; } |