Improve instantiation control for rtti data and allow key functions to
instantiate a class.  WIP.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89289 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp
index 0e6f4a6..195acc5 100644
--- a/lib/CodeGen/CodeGenModule.cpp
+++ b/lib/CodeGen/CodeGenModule.cpp
@@ -616,6 +616,16 @@
                                  Context.getSourceManager(),
                                  "Generating code for declaration");
   
+  if (const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(D)) {
+    const CXXRecordDecl *RD = MD->getParent();
+    // We have to convert it to have a record layout.
+    Types.ConvertTagDeclType(RD);
+    const CGRecordLayout &CGLayout = Types.getCGRecordLayout(RD);
+    // A definition of a KeyFunction, generates all the class data, such
+    // as vtable, rtti and the VTT.
+    if (CGLayout.getKeyFunction() == MD)
+      getVtableInfo().GenerateClassData(RD);
+  }
   if (const CXXConstructorDecl *CD = dyn_cast<CXXConstructorDecl>(D))
     EmitCXXConstructor(CD, GD.getCtorType());
   else if (const CXXDestructorDecl *DD = dyn_cast<CXXDestructorDecl>(D))