diff options
Diffstat (limited to 'contrib/llvm/tools/clang/lib/CodeGen/CGCXX.cpp')
-rw-r--r-- | contrib/llvm/tools/clang/lib/CodeGen/CGCXX.cpp | 42 |
1 files changed, 20 insertions, 22 deletions
diff --git a/contrib/llvm/tools/clang/lib/CodeGen/CGCXX.cpp b/contrib/llvm/tools/clang/lib/CodeGen/CGCXX.cpp index f6fc202..b5e6e0d 100644 --- a/contrib/llvm/tools/clang/lib/CodeGen/CGCXX.cpp +++ b/contrib/llvm/tools/clang/lib/CodeGen/CGCXX.cpp @@ -138,7 +138,7 @@ bool CodeGenModule::TryEmitDefinitionAsAlias(GlobalDecl AliasDecl, return true; // Derive the type for the alias. - const llvm::PointerType *AliasType + llvm::PointerType *AliasType = getTypes().GetFunctionType(AliasDecl)->getPointerTo(); // Find the referrent. Some aliases might require a bitcast, in @@ -154,7 +154,7 @@ bool CodeGenModule::TryEmitDefinitionAsAlias(GlobalDecl AliasDecl, new llvm::GlobalAlias(AliasType, Linkage, "", Aliasee, &getModule()); // Switch any previous uses to the alias. - llvm::StringRef MangledName = getMangledName(AliasDecl); + StringRef MangledName = getMangledName(AliasDecl); llvm::GlobalValue *Entry = GetGlobalValue(MangledName); if (Entry) { assert(Entry->isDeclaration() && "definition already exists for alias"); @@ -214,14 +214,14 @@ CodeGenModule::GetAddrOfCXXConstructor(const CXXConstructorDecl *ctor, const CGFunctionInfo *fnInfo) { GlobalDecl GD(ctor, ctorType); - llvm::StringRef name = getMangledName(GD); + StringRef name = getMangledName(GD); if (llvm::GlobalValue *existing = GetGlobalValue(name)) return existing; if (!fnInfo) fnInfo = &getTypes().getFunctionInfo(ctor, ctorType); const FunctionProtoType *proto = ctor->getType()->castAs<FunctionProtoType>(); - const llvm::FunctionType *fnType = + llvm::FunctionType *fnType = getTypes().GetFunctionType(*fnInfo, proto->isVariadic()); return cast<llvm::Function>(GetOrCreateLLVMFunction(name, fnType, GD, /*ForVTable=*/false)); @@ -236,11 +236,7 @@ void CodeGenModule::EmitCXXDestructors(const CXXDestructorDecl *D) { // The destructor used for destructing this as a most-derived class; // call the base destructor and then destructs any virtual bases. - if (!D->getParent()->isAbstract() || D->isVirtual()) { - // We don't need to emit the complete ctor if the class is abstract, - // unless the destructor is virtual and needs to be in the vtable. - EmitGlobal(GlobalDecl(D, Dtor_Complete)); - } + EmitGlobal(GlobalDecl(D, Dtor_Complete)); // The destructor used for destructing this as a base class; ignores // virtual bases. @@ -282,13 +278,13 @@ CodeGenModule::GetAddrOfCXXDestructor(const CXXDestructorDecl *dtor, const CGFunctionInfo *fnInfo) { GlobalDecl GD(dtor, dtorType); - llvm::StringRef name = getMangledName(GD); + StringRef name = getMangledName(GD); if (llvm::GlobalValue *existing = GetGlobalValue(name)) return existing; if (!fnInfo) fnInfo = &getTypes().getFunctionInfo(dtor, dtorType); - const llvm::FunctionType *fnType = + llvm::FunctionType *fnType = getTypes().GetFunctionType(*fnInfo, false); return cast<llvm::Function>(GetOrCreateLLVMFunction(name, fnType, GD, @@ -296,7 +292,7 @@ CodeGenModule::GetAddrOfCXXDestructor(const CXXDestructorDecl *dtor, } static llvm::Value *BuildVirtualCall(CodeGenFunction &CGF, uint64_t VTableIndex, - llvm::Value *This, const llvm::Type *Ty) { + llvm::Value *This, llvm::Type *Ty) { Ty = Ty->getPointerTo()->getPointerTo(); llvm::Value *VTable = CGF.GetVTablePtr(This, Ty); @@ -307,9 +303,9 @@ static llvm::Value *BuildVirtualCall(CodeGenFunction &CGF, uint64_t VTableIndex, llvm::Value * CodeGenFunction::BuildVirtualCall(const CXXMethodDecl *MD, llvm::Value *This, - const llvm::Type *Ty) { + llvm::Type *Ty) { MD = MD->getCanonicalDecl(); - uint64_t VTableIndex = CGM.getVTables().getMethodVTableIndex(MD); + uint64_t VTableIndex = CGM.getVTableContext().getMethodVTableIndex(MD); return ::BuildVirtualCall(*this, VTableIndex, This, Ty); } @@ -320,7 +316,7 @@ CodeGenFunction::BuildVirtualCall(const CXXMethodDecl *MD, llvm::Value *This, llvm::Value * CodeGenFunction::BuildAppleKextVirtualCall(const CXXMethodDecl *MD, NestedNameSpecifier *Qual, - const llvm::Type *Ty) { + llvm::Type *Ty) { llvm::Value *VTable = 0; assert((Qual->getKind() == NestedNameSpecifier::TypeSpec) && "BuildAppleKextVirtualCall - bad Qual kind"); @@ -339,9 +335,10 @@ CodeGenFunction::BuildAppleKextVirtualCall(const CXXMethodDecl *MD, VTable = Builder.CreateBitCast(VTable, Ty); assert(VTable && "BuildVirtualCall = kext vtbl pointer is null"); MD = MD->getCanonicalDecl(); - uint64_t VTableIndex = CGM.getVTables().getMethodVTableIndex(MD); + uint64_t VTableIndex = CGM.getVTableContext().getMethodVTableIndex(MD); uint64_t AddressPoint = - CGM.getVTables().getAddressPoint(BaseSubobject(RD, CharUnits::Zero()), RD); + CGM.getVTableContext().getVTableLayout(RD) + .getAddressPoint(BaseSubobject(RD, CharUnits::Zero())); VTableIndex += AddressPoint; llvm::Value *VFuncPtr = Builder.CreateConstInBoundsGEP1_64(VTable, VTableIndex, "vfnkxt"); @@ -366,7 +363,7 @@ CodeGenFunction::BuildAppleKextVirtualDestructorCall( &CGM.getTypes().getFunctionInfo(cast<CXXDestructorDecl>(MD), Dtor_Complete); const FunctionProtoType *FPT = MD->getType()->getAs<FunctionProtoType>(); - const llvm::Type *Ty + llvm::Type *Ty = CGM.getTypes().GetFunctionType(*FInfo, FPT->isVariadic()); llvm::Value *VTable = CGM.getVTables().GetAddrOfVTable(RD); @@ -374,9 +371,10 @@ CodeGenFunction::BuildAppleKextVirtualDestructorCall( VTable = Builder.CreateBitCast(VTable, Ty); DD = cast<CXXDestructorDecl>(DD->getCanonicalDecl()); uint64_t VTableIndex = - CGM.getVTables().getMethodVTableIndex(GlobalDecl(DD, Type)); + CGM.getVTableContext().getMethodVTableIndex(GlobalDecl(DD, Type)); uint64_t AddressPoint = - CGM.getVTables().getAddressPoint(BaseSubobject(RD, CharUnits::Zero()), RD); + CGM.getVTableContext().getVTableLayout(RD) + .getAddressPoint(BaseSubobject(RD, CharUnits::Zero())); VTableIndex += AddressPoint; llvm::Value *VFuncPtr = Builder.CreateConstInBoundsGEP1_64(VTable, VTableIndex, "vfnkxt"); @@ -387,10 +385,10 @@ CodeGenFunction::BuildAppleKextVirtualDestructorCall( llvm::Value * CodeGenFunction::BuildVirtualCall(const CXXDestructorDecl *DD, CXXDtorType Type, - llvm::Value *This, const llvm::Type *Ty) { + llvm::Value *This, llvm::Type *Ty) { DD = cast<CXXDestructorDecl>(DD->getCanonicalDecl()); uint64_t VTableIndex = - CGM.getVTables().getMethodVTableIndex(GlobalDecl(DD, Type)); + CGM.getVTableContext().getMethodVTableIndex(GlobalDecl(DD, Type)); return ::BuildVirtualCall(*this, VTableIndex, This, Ty); } |