[cfe-commits] r162429 - /cfe/trunk/lib/AST/CXXInheritance.cpp

Douglas Gregor dgregor at apple.com
Tue Sep 11 00:21:16 PDT 2012


On Aug 24, 2012, at 10:48 PM, Chandler Carruth <chandlerc at google.com> wrote:

> Is there a reason not to use SetVector here? This seems to be what it was designed for...

r163600, thanks!

	- Doug

> 
> On Wed, Aug 22, 2012 at 10:05 PM, Douglas Gregor <dgregor at apple.com> wrote:
> Author: dgregor
> Date: Thu Aug 23 00:05:18 2012
> New Revision: 162429
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=162429&view=rev
> Log:
> array_pod_sort on the addresses of declaration pointers leads to
> inconsistent ordering of results; instead, use use SmallPtrSet to
> eliminate duplicates.
> 
> Modified:
>     cfe/trunk/lib/AST/CXXInheritance.cpp
> 
> Modified: cfe/trunk/lib/AST/CXXInheritance.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/CXXInheritance.cpp?rev=162429&r1=162428&r2=162429&view=diff
> ==============================================================================
> --- cfe/trunk/lib/AST/CXXInheritance.cpp (original)
> +++ cfe/trunk/lib/AST/CXXInheritance.cpp Thu Aug 23 00:05:18 2012
> @@ -25,13 +25,11 @@
>    assert(NumDeclsFound == 0 && !DeclsFound &&
>           "Already computed the set of declarations");
> 
> +  llvm::SmallPtrSet<NamedDecl *, 8> KnownDecls;
>    SmallVector<NamedDecl *, 8> Decls;
>    for (paths_iterator Path = begin(), PathEnd = end(); Path != PathEnd; ++Path)
> -    Decls.push_back(*Path->Decls.first);
> -
> -  // Eliminate duplicated decls.
> -  llvm::array_pod_sort(Decls.begin(), Decls.end());
> -  Decls.erase(std::unique(Decls.begin(), Decls.end()), Decls.end());
> +    if (KnownDecls.insert(*Path->Decls.first))
> +      Decls.push_back(*Path->Decls.first);
> 
>    NumDeclsFound = Decls.size();
>    DeclsFound = new NamedDecl * [NumDeclsFound];
> 
> 
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120911/4a2d6336/attachment.html>


More information about the cfe-commits mailing list