]> granicus.if.org Git - clang/commitdiff
Refactor. WIP. Eventually, this will all go into a vtable builder class.
authorMike Stump <mrs@apple.com>
Wed, 12 Aug 2009 23:14:12 +0000 (23:14 +0000)
committerMike Stump <mrs@apple.com>
Wed, 12 Aug 2009 23:14:12 +0000 (23:14 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78857 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGCXX.cpp
lib/CodeGen/CodeGenFunction.h

index 31b406aed2029256b9617ca9dbde8c146a86f05a..1c95fc313eef9b70b5bdec53ac7bd78e66d62379 100644 (file)
@@ -621,6 +621,21 @@ llvm::Constant *CodeGenFunction::GenerateRtti(const CXXRecordDecl *RD) {
   return Rtti;
 }
 
+void CodeGenFunction::GenerateVcalls(std::vector<llvm::Constant *> &methods,
+                                     const CXXRecordDecl *RD,
+                                     llvm::Type *Ptr8Ty) {
+  typedef CXXRecordDecl::method_iterator meth_iter;
+  llvm::Constant *m;
+    for (meth_iter mi = RD->method_begin(),
+           me = RD->method_end(); mi != me; ++mi) {
+      if (mi->isVirtual()) {
+        // FIXME: vcall: offset for virtual base for this function
+        m = llvm::Constant::getNullValue(Ptr8Ty);
+        methods.push_back(m);
+      }
+    }
+}
+
 void CodeGenFunction::GenerateMethods(std::vector<llvm::Constant *> &methods,
                                       const CXXRecordDecl *RD,
                                       llvm::Type *Ptr8Ty) {
@@ -673,14 +688,8 @@ void CodeGenFunction::GenerateVtableForBase(const CXXRecordDecl *RD,
   
   // then comes the the vcall offsets for all our functions...
   if (isPrimary && ForVirtualBase)
-    for (meth_iter mi = Class->method_begin(),
-           me = Class->method_end(); mi != me; ++mi) {
-      if (mi->isVirtual()) {
-        // FIXME: vcall: offset for virtual base for this function
-        m = llvm::Constant::getNullValue(Ptr8Ty);
-        methods.push_back(m);
-      }
-    }
+    GenerateVcalls(methods, Class, Ptr8Ty);
+
   bool TopPrimary = true;
   // Primary tables are composed from the chain of primaries.
   if (isPrimary) {
@@ -696,14 +705,7 @@ void CodeGenFunction::GenerateVtableForBase(const CXXRecordDecl *RD,
   }
   // then come the vcall offsets for all our virtual bases.
   if (!isPrimary && RD && ForVirtualBase)
-    for (meth_iter mi = RD->method_begin(), me = RD->method_end(); mi != me;
-         ++mi) {
-      if (mi->isVirtual()) {
-        // FIXME: vcall: offset for virtual base for this function
-        m = llvm::Constant::getNullValue(Ptr8Ty);
-        methods.push_back(m);
-      }
-    }
+    GenerateVcalls(methods, RD, Ptr8Ty);
 
   if (TopPrimary) {
     if (RD) {
index 75dd3f55f9031bbefe86fe2c5d45209d7f955436..4375fbccc7a9232d642078d3ed24f3c361912423 100644 (file)
@@ -359,6 +359,8 @@ public:
   void FinishFunction(SourceLocation EndLoc=SourceLocation());
 
   llvm::Constant *GenerateRtti(const CXXRecordDecl *RD);
+  void GenerateVcalls(std::vector<llvm::Constant *> &methods,
+                      const CXXRecordDecl *RD, llvm::Type *Ptr8Ty);
   void GenerateMethods(std::vector<llvm::Constant *> &methods,
                        const CXXRecordDecl *RD, llvm::Type *Ptr8Ty);
   void GenerateVtableForBase(const CXXRecordDecl *RD,