summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGCXX.cpp
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2009-09-12 03:29:09 +0000
committerAnders Carlsson <andersca@mac.com>2009-09-12 03:29:09 +0000
commit307408d2af9d76513d927e24a456b8e57405b1e2 (patch)
tree8f52a288c5464d7566de20300d13765e784e978d /clang/lib/CodeGen/CGCXX.cpp
parent57dba6768eff848f52fcf23141a2af3ffa31873d (diff)
downloadbcm5719-llvm-307408d2af9d76513d927e24a456b8e57405b1e2.tar.gz
bcm5719-llvm-307408d2af9d76513d927e24a456b8e57405b1e2.zip
Add CGCXXClass.cpp. and move CodeGenFunction::AddressCXXOfBaseClass there.
llvm-svn: 81604
Diffstat (limited to 'clang/lib/CodeGen/CGCXX.cpp')
-rw-r--r--clang/lib/CodeGen/CGCXX.cpp67
1 files changed, 0 insertions, 67 deletions
diff --git a/clang/lib/CodeGen/CGCXX.cpp b/clang/lib/CodeGen/CGCXX.cpp
index 7def3c78347..c3c40443b84 100644
--- a/clang/lib/CodeGen/CGCXX.cpp
+++ b/clang/lib/CodeGen/CGCXX.cpp
@@ -276,73 +276,6 @@ llvm::Value *CodeGenFunction::LoadCXXThis() {
return Builder.CreateLoad(LocalDeclMap[CXXThisDecl], "this");
}
-static bool
-GetNestedPaths(llvm::SmallVectorImpl<const CXXRecordDecl *> &NestedBasePaths,
- const CXXRecordDecl *ClassDecl,
- const CXXRecordDecl *BaseClassDecl) {
- for (CXXRecordDecl::base_class_const_iterator i = ClassDecl->bases_begin(),
- e = ClassDecl->bases_end(); i != e; ++i) {
- if (i->isVirtual())
- continue;
- const CXXRecordDecl *Base =
- cast<CXXRecordDecl>(i->getType()->getAs<RecordType>()->getDecl());
- if (Base == BaseClassDecl) {
- NestedBasePaths.push_back(BaseClassDecl);
- return true;
- }
- }
- // BaseClassDecl not an immediate base of ClassDecl.
- for (CXXRecordDecl::base_class_const_iterator i = ClassDecl->bases_begin(),
- e = ClassDecl->bases_end(); i != e; ++i) {
- if (i->isVirtual())
- continue;
- const CXXRecordDecl *Base =
- cast<CXXRecordDecl>(i->getType()->getAs<RecordType>()->getDecl());
- if (GetNestedPaths(NestedBasePaths, Base, BaseClassDecl)) {
- NestedBasePaths.push_back(Base);
- return true;
- }
- }
- return false;
-}
-
-llvm::Value *CodeGenFunction::AddressCXXOfBaseClass(llvm::Value *BaseValue,
- const CXXRecordDecl *ClassDecl,
- const CXXRecordDecl *BaseClassDecl) {
- if (ClassDecl == BaseClassDecl)
- return BaseValue;
-
- llvm::Type *I8Ptr = llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(VMContext));
- llvm::SmallVector<const CXXRecordDecl *, 16> NestedBasePaths;
- GetNestedPaths(NestedBasePaths, ClassDecl, BaseClassDecl);
- assert(NestedBasePaths.size() > 0 &&
- "AddressCXXOfBaseClass - inheritence path failed");
- NestedBasePaths.push_back(ClassDecl);
- uint64_t Offset = 0;
-
- // Accessing a member of the base class. Must add delata to
- // the load of 'this'.
- for (unsigned i = NestedBasePaths.size()-1; i > 0; i--) {
- const CXXRecordDecl *DerivedClass = NestedBasePaths[i];
- const CXXRecordDecl *BaseClass = NestedBasePaths[i-1];
- const ASTRecordLayout &Layout =
- getContext().getASTRecordLayout(DerivedClass);
- Offset += Layout.getBaseClassOffset(BaseClass) / 8;
- }
- llvm::Value *OffsetVal =
- llvm::ConstantInt::get(
- CGM.getTypes().ConvertType(CGM.getContext().LongTy), Offset);
- BaseValue = Builder.CreateBitCast(BaseValue, I8Ptr);
- BaseValue = Builder.CreateGEP(BaseValue, OffsetVal, "add.ptr");
- QualType BTy =
- getContext().getCanonicalType(
- getContext().getTypeDeclType(const_cast<CXXRecordDecl*>(BaseClassDecl)));
- const llvm::Type *BasePtr = ConvertType(BTy);
- BasePtr = llvm::PointerType::getUnqual(BasePtr);
- BaseValue = Builder.CreateBitCast(BaseValue, BasePtr);
- return BaseValue;
-}
-
/// EmitCXXAggrConstructorCall - This routine essentially creates a (nested)
/// for-loop to call the default constructor on individual members of the
/// array. 'Array' is the array type, 'This' is llvm pointer of the start
OpenPOWER on IntegriCloud