Fix PR27601 by reverting [r267453] - Refactor traversal of bases in deduction of template parameters from base

This reversal is being done with r267453's author's (i.e. Richard Smith's) permission.

This fixes https://llvm.org/bugs/show_bug.cgi?id=27601 

Also, per Richard's request the examples from the bug report have been added to our test suite.

llvm-svn: 270016
diff --git a/clang/lib/AST/CXXInheritance.cpp b/clang/lib/AST/CXXInheritance.cpp
index d1a2b43..6a6ca76 100644
--- a/clang/lib/AST/CXXInheritance.cpp
+++ b/clang/lib/AST/CXXInheritance.cpp
@@ -137,7 +137,6 @@
 bool CXXRecordDecl::forallBases(ForallBasesCallback BaseMatches,
                                 bool AllowShortCircuit) const {
   SmallVector<const CXXRecordDecl*, 8> Queue;
-  llvm::SmallPtrSet<const CXXRecordDecl*, 8> Enqueued;
 
   const CXXRecordDecl *Record = this;
   bool AllMatches = true;
@@ -159,14 +158,12 @@
         AllMatches = false;
         continue;
       }
-
-      if (Enqueued.insert(Base).second) {
-        Queue.push_back(Base);
-        if (!BaseMatches(Base)) {
-          if (AllowShortCircuit) return false;
-          AllMatches = false;
-          continue;
-        }
+      
+      Queue.push_back(Base);
+      if (!BaseMatches(Base)) {
+        if (AllowShortCircuit) return false;
+        AllMatches = false;
+        continue;
       }
     }