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

Douglas Gregor dgregor at apple.com
Wed Aug 22 22:05:18 PDT 2012


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];





More information about the cfe-commits mailing list