]> granicus.if.org Git - clang/commitdiff
Use root non-virtual primary base class, not just immediate primary base class, for...
authorDevang Patel <dpatel@apple.com>
Thu, 14 Oct 2010 22:59:23 +0000 (22:59 +0000)
committerDevang Patel <dpatel@apple.com>
Thu, 14 Oct 2010 22:59:23 +0000 (22:59 +0000)
This is tested by virtfunc.exp in gdb testsuite.

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

lib/CodeGen/CGDebugInfo.cpp

index 404c010c7704314e18d873395943388d4cc4640f..224710af3573a9dbb7283ec92b77916d94edf4f0 100644 (file)
@@ -1018,9 +1018,19 @@ llvm::DIType CGDebugInfo::CreateType(const RecordType *Ty,
 
     // A class's primary base or the class itself contains the vtable.
     const ASTRecordLayout &RL = CGM.getContext().getASTRecordLayout(RD);
-    if (const CXXRecordDecl *PBase = RL.getPrimaryBase())
+    if (const CXXRecordDecl *PBase = RL.getPrimaryBase()) {
+      // Seek non virtual primary base root.
+      while (1) {
+        const ASTRecordLayout &BRL = CGM.getContext().getASTRecordLayout(PBase);
+        const CXXRecordDecl *PBT = BRL.getPrimaryBase();
+        if (PBT && !BRL.getPrimaryBaseWasVirtual())
+          PBase = PBT;
+        else 
+          break;
+      }
       ContainingType = 
         getOrCreateType(QualType(PBase->getTypeForDecl(), 0), Unit);
+    }
     else if (CXXDecl->isDynamicClass()) 
       ContainingType = FwdDecl;
   }