diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2015-02-13 20:17:14 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2015-02-13 20:17:14 +0000 |
commit | 52874ec5d55a85264a00edcb5f36ac10072c65d4 (patch) | |
tree | ea4c8eeec41199baf1fc788560f4967592db8868 /clang/lib/Serialization | |
parent | 46598206b5947afc123d5cf79ec7568272097fa4 (diff) | |
download | bcm5719-llvm-52874ec5d55a85264a00edcb5f36ac10072c65d4.tar.gz bcm5719-llvm-52874ec5d55a85264a00edcb5f36ac10072c65d4.zip |
[modules] Don't produce duplicate lookup results if the same declaration is
visible through multiple imported modules. No functionality change.
llvm-svn: 229147
Diffstat (limited to 'clang/lib/Serialization')
-rw-r--r-- | clang/lib/Serialization/ASTReader.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp index 610cd7e5932..7c211e41a18 100644 --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/lib/Serialization/ASTReader.cpp @@ -6483,13 +6483,16 @@ namespace { ArrayRef<const DeclContext *> Contexts; DeclarationName Name; SmallVectorImpl<NamedDecl *> &Decls; + llvm::SmallPtrSetImpl<NamedDecl *> &DeclSet; public: DeclContextNameLookupVisitor(ASTReader &Reader, ArrayRef<const DeclContext *> Contexts, DeclarationName Name, - SmallVectorImpl<NamedDecl *> &Decls) - : Reader(Reader), Contexts(Contexts), Name(Name), Decls(Decls) { } + SmallVectorImpl<NamedDecl *> &Decls, + llvm::SmallPtrSetImpl<NamedDecl *> &DeclSet) + : Reader(Reader), Contexts(Contexts), Name(Name), Decls(Decls), + DeclSet(DeclSet) { } static bool visit(ModuleFile &M, void *UserData) { DeclContextNameLookupVisitor *This @@ -6538,7 +6541,8 @@ namespace { // Record this declaration. FoundAnything = true; - This->Decls.push_back(ND); + if (This->DeclSet.insert(ND).second) + This->Decls.push_back(ND); } return FoundAnything; @@ -6578,6 +6582,7 @@ ASTReader::FindExternalVisibleDeclsByName(const DeclContext *DC, Deserializing LookupResults(this); SmallVector<NamedDecl *, 64> Decls; + llvm::SmallPtrSet<NamedDecl*, 64> DeclSet; // Compute the declaration contexts we need to look into. Multiple such // declaration contexts occur when two declaration contexts from disjoint @@ -6595,7 +6600,7 @@ ASTReader::FindExternalVisibleDeclsByName(const DeclContext *DC, } auto LookUpInContexts = [&](ArrayRef<const DeclContext*> Contexts) { - DeclContextNameLookupVisitor Visitor(*this, Contexts, Name, Decls); + DeclContextNameLookupVisitor Visitor(*this, Contexts, Name, Decls, DeclSet); // If we can definitively determine which module file to look into, // only look there. Otherwise, look in all module files. @@ -6644,6 +6649,7 @@ namespace { ASTReader &Reader; SmallVectorImpl<const DeclContext *> &Contexts; DeclsMap &Decls; + llvm::SmallPtrSet<NamedDecl *, 256> DeclSet; bool VisitAll; public: @@ -6688,7 +6694,8 @@ namespace { // Record this declaration. FoundAnything = true; - This->Decls[ND->getDeclName()].push_back(ND); + if (This->DeclSet.insert(ND).second) + This->Decls[ND->getDeclName()].push_back(ND); } } |