Is there a reason not to use SetVector here? This seems to be what it was designed for...<div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Aug 22, 2012 at 10:05 PM, Douglas Gregor <span dir="ltr"><<a href="mailto:dgregor@apple.com" target="_blank">dgregor@apple.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: dgregor<br>
Date: Thu Aug 23 00:05:18 2012<br>
New Revision: 162429<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=162429&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=162429&view=rev</a><br>
Log:<br>
array_pod_sort on the addresses of declaration pointers leads to<br>
inconsistent ordering of results; instead, use use SmallPtrSet to<br>
eliminate duplicates.<br>
<br>
Modified:<br>
cfe/trunk/lib/AST/CXXInheritance.cpp<br>
<br>
Modified: cfe/trunk/lib/AST/CXXInheritance.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/CXXInheritance.cpp?rev=162429&r1=162428&r2=162429&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/CXXInheritance.cpp?rev=162429&r1=162428&r2=162429&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/AST/CXXInheritance.cpp (original)<br>
+++ cfe/trunk/lib/AST/CXXInheritance.cpp Thu Aug 23 00:05:18 2012<br>
@@ -25,13 +25,11 @@<br>
assert(NumDeclsFound == 0 && !DeclsFound &&<br>
"Already computed the set of declarations");<br>
<br>
+ llvm::SmallPtrSet<NamedDecl *, 8> KnownDecls;<br>
SmallVector<NamedDecl *, 8> Decls;<br>
for (paths_iterator Path = begin(), PathEnd = end(); Path != PathEnd; ++Path)<br>
- Decls.push_back(*Path->Decls.first);<br>
-<br>
- // Eliminate duplicated decls.<br>
- llvm::array_pod_sort(Decls.begin(), Decls.end());<br>
- Decls.erase(std::unique(Decls.begin(), Decls.end()), Decls.end());<br>
+ if (KnownDecls.insert(*Path->Decls.first))<br>
+ Decls.push_back(*Path->Decls.first);<br>
<br>
NumDeclsFound = Decls.size();<br>
DeclsFound = new NamedDecl * [NumDeclsFound];<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div>