]> granicus.if.org Git - clang/commitdiff
Make sure that overridden method decls are always canonical.
authorAnders Carlsson <andersca@mac.com>
Fri, 4 Dec 2009 05:51:56 +0000 (05:51 +0000)
committerAnders Carlsson <andersca@mac.com>
Fri, 4 Dec 2009 05:51:56 +0000 (05:51 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90542 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/DeclCXX.cpp
lib/CodeGen/CGVtable.cpp
lib/Sema/SemaDecl.cpp

index 979723a19547c25044095a4311696708fc2bdb35..5064ec5c7377f07442900e7de2ab68cb136274ef 100644 (file)
@@ -589,6 +589,8 @@ typedef llvm::DenseMap<const CXXMethodDecl*,
 static OverriddenMethodsMapTy *OverriddenMethods = 0;
 
 void CXXMethodDecl::addOverriddenMethod(const CXXMethodDecl *MD) {
+  assert(MD->isCanonicalDecl() && "Method is not canonical!");
+  
   // FIXME: The CXXMethodDecl dtor needs to remove and free the entry.
 
   if (!OverriddenMethods)
index 5e448273729a9f4165408340735d1b2741ed36d6..869bcc0e6a6f33efb37aa3e9b5740e096b8c13fa 100644 (file)
@@ -742,7 +742,7 @@ bool VtableBuilder::OverrideMethod(GlobalDecl GD, llvm::Constant *m,
        mi != e; ++mi) {
     GlobalDecl OGD;
     
-    const CXXMethodDecl *OMD = (*mi)->getCanonicalDecl();
+    const CXXMethodDecl *OMD = *mi;
     if (const CXXDestructorDecl *DD = dyn_cast<CXXDestructorDecl>(OMD))
       OGD = GlobalDecl(DD, GD.getDtorType());
     else
@@ -933,7 +933,7 @@ void CGVtableInfo::ComputeMethodVtableIndices(const CXXRecordDecl *RD) {
     // Check if this method overrides a method in the primary base.
     for (CXXMethodDecl::method_iterator i = MD->begin_overridden_methods(),
          e = MD->end_overridden_methods(); i != e; ++i) {
-      const CXXMethodDecl *OverriddenMD = (*i)->getCanonicalDecl();
+      const CXXMethodDecl *OverriddenMD = *i;
       const CXXRecordDecl *OverriddenRD = OverriddenMD->getParent();
       assert(OverriddenMD->isCanonicalDecl() &&
              "Should have the canonical decl of the overridden RD!");
index 3e29b726e8923cc236c85117934459382242d920..effab5a03ebff30aa9b3a169565e8f0ea13a59af 100644 (file)
@@ -2585,7 +2585,7 @@ void Sema::AddOverriddenMethods(CXXRecordDecl *DC, CXXMethodDecl *MD) {
         if (!CheckOverridingFunctionReturnType(MD, OldMD) &&
             !CheckOverridingFunctionExceptionSpec(MD, OldMD) &&
             !CheckOverridingFunctionAttributes(MD, OldMD))
-          MD->addOverriddenMethod(OldMD);
+          MD->addOverriddenMethod(OldMD->getCanonicalDecl());
       }
     }
   }