]> granicus.if.org Git - clang/commitdiff
When collecting virtual bases it's very important to use the canonical type of the...
authorAnders Carlsson <andersca@mac.com>
Mon, 29 Mar 2010 19:49:09 +0000 (19:49 +0000)
committerAnders Carlsson <andersca@mac.com>
Mon, 29 Mar 2010 19:49:09 +0000 (19:49 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99829 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/DeclCXX.cpp
test/CodeGenCXX/virtual-bases.cpp

index 3b3bf1ba443f895ea89196b4d2c4f0869c59afef..ed02edd394465518160230833e10583b06787778 100644 (file)
@@ -84,7 +84,7 @@ CXXRecordDecl::setBases(CXXBaseSpecifier const * const *Bases,
     C.Deallocate(data().Bases);
 
   // The set of seen virtual base types.
-  llvm::SmallPtrSet<QualType, 8> SeenVBaseTypes;
+  llvm::SmallPtrSet<CanQualType, 8> SeenVBaseTypes;
   
   // The virtual bases of this class.
   llvm::SmallVector<const CXXBaseSpecifier *, 8> VBases;
@@ -107,13 +107,13 @@ CXXRecordDecl::setBases(CXXBaseSpecifier const * const *Bases,
           BaseClassDecl->vbases_begin(),
          E = BaseClassDecl->vbases_end(); VBase != E; ++VBase) {
       // Add this base if it's not already in the list.
-      if (SeenVBaseTypes.insert(VBase->getType()))
+      if (SeenVBaseTypes.insert(C.getCanonicalType(VBase->getType())))
         VBases.push_back(VBase);
     }
 
     if (Base->isVirtual()) {
       // Add this base if it's not already in the list.
-      if (SeenVBaseTypes.insert(BaseType))
+      if (SeenVBaseTypes.insert(C.getCanonicalType(BaseType)))
           VBases.push_back(Base);
     }
 
index 627717576302e52229ba8d22a8e7ef3c84863c0a..61de3153fd50966284dd6f57250724210422033f 100644 (file)
@@ -23,3 +23,26 @@ struct C : virtual A {
 // CHECK: define void @_ZN1CC1Eb(%struct.B* %this, i1 zeroext)
 // CHECK: define void @_ZN1CC2Eb(%struct.B* %this, i8** %vtt, i1 zeroext)
 C::C(bool) { }
+
+// PR6251
+namespace PR6251 {
+
+// Test that we don't call the A<char> constructor twice.
+
+template<typename T>
+struct A { A(); };
+
+struct B : virtual A<char> { };
+struct C : virtual A<char> { };
+
+struct D : B, C  {
+  D();
+};
+
+// CHECK: define void @_ZN6PR62511DC1Ev
+// CHECK: call void @_ZN6PR62511AIcEC2Ev
+// CHECK-NOT: call void @_ZN6PR62511AIcEC2Ev
+// CHECK: ret void
+D::D() { }
+
+}