[cfe-commits] r78854 - in /cfe/trunk/lib/CodeGen: CGCXX.cpp CodeGenFunction.h
Mike Stump
mrs at apple.com
Wed Aug 12 16:01:00 PDT 2009
Author: mrs
Date: Wed Aug 12 18:00:59 2009
New Revision: 78854
URL: http://llvm.org/viewvc/llvm-project?rev=78854&view=rev
Log:
Refactor.
Modified:
cfe/trunk/lib/CodeGen/CGCXX.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
Modified: cfe/trunk/lib/CodeGen/CGCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCXX.cpp?rev=78854&r1=78853&r2=78854&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCXX.cpp Wed Aug 12 18:00:59 2009
@@ -621,6 +621,22 @@
return Rtti;
}
+void CodeGenFunction::GenerateMethods(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()) {
+ m = CGM.GetAddrOfFunction(GlobalDecl(*mi));
+ m = llvm::ConstantExpr::getBitCast(m, Ptr8Ty);
+ methods.push_back(m);
+ }
+ }
+}
+
void CodeGenFunction::GenerateVtableForBase(const CXXRecordDecl *RD,
const CXXRecordDecl *Class,
llvm::Constant *rtti,
@@ -700,29 +716,13 @@
}
if (!isPrimary) {
- if (!RD)
- return;
-
- for (meth_iter mi = RD->method_begin(), me = RD->method_end(); mi != me;
- ++mi) {
- if (mi->isVirtual()) {
- m = CGM.GetAddrOfFunction(GlobalDecl(*mi));
- m = llvm::ConstantExpr::getBitCast(m, Ptr8Ty);
- methods.push_back(m);
- }
- }
+ if (RD)
+ GenerateMethods(methods, RD, Ptr8Ty);
return;
}
// And add the virtuals for the class to the primary vtable.
- for (meth_iter mi = Class->method_begin(), me = Class->method_end(); mi != me;
- ++mi) {
- if (mi->isVirtual()) {
- m = CGM.GetAddrOfFunction(GlobalDecl(*mi));
- m = llvm::ConstantExpr::getBitCast(m, Ptr8Ty);
- methods.push_back(m);
- }
- }
+ GenerateMethods(methods, Class, Ptr8Ty);
}
llvm::Value *CodeGenFunction::GenerateVtable(const CXXRecordDecl *RD) {
Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=78854&r1=78853&r2=78854&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Wed Aug 12 18:00:59 2009
@@ -359,6 +359,8 @@
void FinishFunction(SourceLocation EndLoc=SourceLocation());
llvm::Constant *GenerateRtti(const CXXRecordDecl *RD);
+ void GenerateMethods(std::vector<llvm::Constant *> &methods,
+ const CXXRecordDecl *RD, llvm::Type *Ptr8Ty);
void GenerateVtableForBase(const CXXRecordDecl *RD,
const CXXRecordDecl *Class,
llvm::Constant *rtti,
More information about the cfe-commits
mailing list