]> granicus.if.org Git - clang/commitdiff
array_pod_sort on the addresses of declaration pointers leads to
authorDouglas Gregor <dgregor@apple.com>
Thu, 23 Aug 2012 05:05:18 +0000 (05:05 +0000)
committerDouglas Gregor <dgregor@apple.com>
Thu, 23 Aug 2012 05:05:18 +0000 (05:05 +0000)
inconsistent ordering of results; instead, use use SmallPtrSet to
eliminate duplicates.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162429 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/CXXInheritance.cpp

index cf3913bac00816311082f914d8d9b9464415f878..247f3753f08d2aeba978c9836d404b58b199f6bb 100644 (file)
@@ -25,13 +25,11 @@ void CXXBasePaths::ComputeDeclsFound() {
   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];