Pass the canonical method decl to GetVtableIndex. Fixes PR5120.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83272 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGExprAgg.cpp b/lib/CodeGen/CGExprAgg.cpp
index 1dd97d6..82ec4fd 100644
--- a/lib/CodeGen/CGExprAgg.cpp
+++ b/lib/CodeGen/CGExprAgg.cpp
@@ -298,7 +298,7 @@
   llvm::Value *FuncPtr;
   
   if (MD->isVirtual()) {
-    uint64_t Index = CGF.CGM.GetVtableIndex(MD);
+    uint64_t Index = CGF.CGM.GetVtableIndex(MD->getCanonicalDecl());
     
     FuncPtr = llvm::ConstantInt::get(PtrDiffTy, Index + 1);
   } else {
diff --git a/lib/CodeGen/CGExprConstant.cpp b/lib/CodeGen/CGExprConstant.cpp
index a742355..0fd7652 100644
--- a/lib/CodeGen/CGExprConstant.cpp
+++ b/lib/CodeGen/CGExprConstant.cpp
@@ -413,7 +413,7 @@
     
     // Get the function pointer (or index if this is a virtual function).
     if (MD->isVirtual()) {
-      uint64_t Index = CGM.GetVtableIndex(MD);
+      uint64_t Index = CGM.GetVtableIndex(MD->getCanonicalDecl());
       
       Values[0] = llvm::ConstantInt::get(PtrDiffTy, Index + 1);
     } else {