diff options
Diffstat (limited to 'lib/CodeGen/MicrosoftCXXABI.cpp')
-rw-r--r-- | lib/CodeGen/MicrosoftCXXABI.cpp | 65 |
1 files changed, 51 insertions, 14 deletions
diff --git a/lib/CodeGen/MicrosoftCXXABI.cpp b/lib/CodeGen/MicrosoftCXXABI.cpp index 6a2925b..8d205c3 100644 --- a/lib/CodeGen/MicrosoftCXXABI.cpp +++ b/lib/CodeGen/MicrosoftCXXABI.cpp @@ -29,14 +29,18 @@ public: MicrosoftCXXABI(CodeGenModule &CGM) : CGCXXABI(CGM) {} StringRef GetPureVirtualCallName() { return "_purecall"; } + // No known support for deleted functions in MSVC yet, so this choice is + // arbitrary. + StringRef GetDeletedVirtualCallName() { return "_purecall"; } + + llvm::Value *adjustToCompleteObject(CodeGenFunction &CGF, + llvm::Value *ptr, + QualType type); void BuildConstructorSignature(const CXXConstructorDecl *Ctor, CXXCtorType Type, CanQualType &ResTy, - SmallVectorImpl<CanQualType> &ArgTys) { - // 'this' is already in place - // TODO: 'for base' flag - } + SmallVectorImpl<CanQualType> &ArgTys); void BuildDestructorSignature(const CXXDestructorDecl *Ctor, CXXDtorType Type, @@ -48,15 +52,9 @@ public: void BuildInstanceFunctionParams(CodeGenFunction &CGF, QualType &ResTy, - FunctionArgList &Params) { - BuildThisParam(CGF, Params); - // TODO: 'for base' flag - } + FunctionArgList &Params); - void EmitInstanceFunctionProlog(CodeGenFunction &CGF) { - EmitThisParam(CGF); - // TODO: 'for base' flag - } + void EmitInstanceFunctionProlog(CodeGenFunction &CGF); void EmitGuardedInit(CodeGenFunction &CGF, const VarDecl &D, llvm::GlobalVariable *DeclPtr, @@ -99,10 +97,49 @@ public: llvm::Value *readArrayCookieImpl(CodeGenFunction &CGF, llvm::Value *allocPtr, CharUnits cookieSize); + static bool needThisReturn(GlobalDecl GD); }; } +llvm::Value *MicrosoftCXXABI::adjustToCompleteObject(CodeGenFunction &CGF, + llvm::Value *ptr, + QualType type) { + // FIXME: implement + return ptr; +} + +bool MicrosoftCXXABI::needThisReturn(GlobalDecl GD) { + const CXXMethodDecl* MD = cast<CXXMethodDecl>(GD.getDecl()); + return isa<CXXConstructorDecl>(MD); +} + +void MicrosoftCXXABI::BuildConstructorSignature(const CXXConstructorDecl *Ctor, + CXXCtorType Type, + CanQualType &ResTy, + SmallVectorImpl<CanQualType> &ArgTys) { + // 'this' is already in place + // TODO: 'for base' flag + // Ctor returns this ptr + ResTy = ArgTys[0]; +} + +void MicrosoftCXXABI::BuildInstanceFunctionParams(CodeGenFunction &CGF, + QualType &ResTy, + FunctionArgList &Params) { + BuildThisParam(CGF, Params); + if (needThisReturn(CGF.CurGD)) { + ResTy = Params[0]->getType(); + } +} + +void MicrosoftCXXABI::EmitInstanceFunctionProlog(CodeGenFunction &CGF) { + EmitThisParam(CGF); + if (needThisReturn(CGF.CurGD)) { + CGF.Builder.CreateStore(getThisValue(CGF), CGF.ReturnValue); + } +} + bool MicrosoftCXXABI::requiresArrayCookie(const CXXDeleteExpr *expr, QualType elementType) { // Microsoft seems to completely ignore the possibility of a @@ -127,7 +164,7 @@ CharUnits MicrosoftCXXABI::getArrayCookieSizeImpl(QualType type) { llvm::Value *MicrosoftCXXABI::readArrayCookieImpl(CodeGenFunction &CGF, llvm::Value *allocPtr, CharUnits cookieSize) { - unsigned AS = cast<llvm::PointerType>(allocPtr->getType())->getAddressSpace(); + unsigned AS = allocPtr->getType()->getPointerAddressSpace(); llvm::Value *numElementsPtr = CGF.Builder.CreateBitCast(allocPtr, CGF.SizeTy->getPointerTo(AS)); return CGF.Builder.CreateLoad(numElementsPtr); @@ -147,7 +184,7 @@ llvm::Value* MicrosoftCXXABI::InitializeArrayCookie(CodeGenFunction &CGF, llvm::Value *cookiePtr = newPtr; // Write the number of elements into the appropriate slot. - unsigned AS = cast<llvm::PointerType>(newPtr->getType())->getAddressSpace(); + unsigned AS = newPtr->getType()->getPointerAddressSpace(); llvm::Value *numElementsPtr = CGF.Builder.CreateBitCast(cookiePtr, CGF.SizeTy->getPointerTo(AS)); CGF.Builder.CreateStore(numElements, numElementsPtr); |