summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGCXX.cpp
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2009-10-03 14:56:57 +0000
committerAnders Carlsson <andersca@mac.com>2009-10-03 14:56:57 +0000
commit32bfb1ce8fafcb9dde43a50bb9838aaf707a67da (patch)
tree934e9db7edd8dc4ea6df7b0a00613a954f6a43bd /clang/lib/CodeGen/CGCXX.cpp
parent6ad01742d5665402eb181457b92278e85ebb3c5b (diff)
downloadbcm5719-llvm-32bfb1ce8fafcb9dde43a50bb9838aaf707a67da.tar.gz
bcm5719-llvm-32bfb1ce8fafcb9dde43a50bb9838aaf707a67da.zip
Move some functions from CodeGenFunctions to CodeGenModule so they can be used by CGExprConstant.
llvm-svn: 83263
Diffstat (limited to 'clang/lib/CodeGen/CGCXX.cpp')
-rw-r--r--clang/lib/CodeGen/CGCXX.cpp20
1 files changed, 12 insertions, 8 deletions
diff --git a/clang/lib/CodeGen/CGCXX.cpp b/clang/lib/CodeGen/CGCXX.cpp
index bf9af9c64da..1ea60eff56d 100644
--- a/clang/lib/CodeGen/CGCXX.cpp
+++ b/clang/lib/CodeGen/CGCXX.cpp
@@ -1206,23 +1206,27 @@ CodeGenFunction::BuildVirtualCall(const CXXMethodDecl *MD, llvm::Value *&This,
const llvm::Type *Ty) {
// FIXME: If we know the dynamic type, we don't have to do a virtual dispatch.
- // FIXME: move to Context
- if (vtableinfo == 0)
- vtableinfo = new VtableInfo(CGM);
-
- VtableInfo::Index_t Idx = vtableinfo->lookup(MD);
-
+ uint64_t Index = CGM.GetVtableIndex(MD);
+
Ty = llvm::PointerType::get(Ty, 0);
Ty = llvm::PointerType::get(Ty, 0);
Ty = llvm::PointerType::get(Ty, 0);
llvm::Value *vtbl = Builder.CreateBitCast(This, Ty);
vtbl = Builder.CreateLoad(vtbl);
llvm::Value *vfn = Builder.CreateConstInBoundsGEP1_64(vtbl,
- Idx, "vfn");
+ Index, "vfn");
vfn = Builder.CreateLoad(vfn);
return vfn;
}
+uint64_t CodeGenModule::GetVtableIndex(const CXXMethodDecl *MD) {
+ // FIXME: move to CodeGenModule.
+ if (vtableinfo == 0)
+ vtableinfo = new VtableInfo(*this);
+
+ return vtableinfo->lookup(MD);
+}
+
/// EmitClassAggrMemberwiseCopy - This routine generates code to copy a class
/// array of objects from SrcValue to DestValue. Copying can be either a bitwise
/// copy or via a copy constructor call.
@@ -1241,7 +1245,7 @@ void CodeGenFunction::EmitClassAggrMemberwiseCopy(llvm::Value *Dest,
"loop.index");
llvm::Value* zeroConstant =
llvm::Constant::getNullValue(llvm::Type::getInt64Ty(VMContext));
- Builder.CreateStore(zeroConstant, IndexPtr, false);
+ Builder.CreateStore(zeroConstant, IndexPtr, false);
// Start the loop with a block that tests the condition.
llvm::BasicBlock *CondBlock = createBasicBlock("for.cond");
llvm::BasicBlock *AfterFor = createBasicBlock("for.end");
OpenPOWER on IntegriCloud