diff options
author | Joao Matos <ripzonetriton@gmail.com> | 2012-07-17 17:10:11 +0000 |
---|---|---|
committer | Joao Matos <ripzonetriton@gmail.com> | 2012-07-17 17:10:11 +0000 |
commit | 285baac67d722beb6854f5faa45ee1aa62a7ce92 (patch) | |
tree | 5ff38a036a92fc9c70c94c105122940c253cda5c /lib/CodeGen | |
parent | e1da3305158d1ecbb6d0cb2cc4ae0c1b3457b29d (diff) |
[Windows] Abstract pure virtual method calls in the ABI. Fix the Windows ABI to forward to the correct function.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160373 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r-- | lib/CodeGen/CGCXXABI.h | 3 | ||||
-rw-r--r-- | lib/CodeGen/CGVTables.cpp | 16 | ||||
-rw-r--r-- | lib/CodeGen/ItaniumCXXABI.cpp | 2 | ||||
-rw-r--r-- | lib/CodeGen/MicrosoftCXXABI.cpp | 2 |
4 files changed, 15 insertions, 8 deletions
diff --git a/lib/CodeGen/CGCXXABI.h b/lib/CodeGen/CGCXXABI.h index 476720535a..a0dcdfdcc6 100644 --- a/lib/CodeGen/CGCXXABI.h +++ b/lib/CodeGen/CGCXXABI.h @@ -193,6 +193,9 @@ public: virtual void EmitReturnFromThunk(CodeGenFunction &CGF, RValue RV, QualType ResultType); + /// Gets the pure virtual member call function. + virtual StringRef GetPureVirtualCallName() = 0; + /**************************** Array cookies ******************************/ /// Returns the extra size required in order to store the array diff --git a/lib/CodeGen/CGVTables.cpp b/lib/CodeGen/CGVTables.cpp index 0d3d023313..c2c42f6e00 100644 --- a/lib/CodeGen/CGVTables.cpp +++ b/lib/CodeGen/CGVTables.cpp @@ -569,15 +569,15 @@ CodeGenVTables::CreateVTableInitializer(const CXXRecordDecl *RD, if (cast<CXXMethodDecl>(GD.getDecl())->isPure()) { // We have a pure virtual member function. - if (!PureVirtualFn) { - llvm::FunctionType *Ty = - llvm::FunctionType::get(CGM.VoidTy, /*isVarArg=*/false); - PureVirtualFn = - CGM.CreateRuntimeFunction(Ty, "__cxa_pure_virtual"); - PureVirtualFn = llvm::ConstantExpr::getBitCast(PureVirtualFn, - Int8PtrTy); + if (!PureVirtualFn ) { + llvm::FunctionType *Ty =
+ llvm::FunctionType::get(CGM.VoidTy, /*isVarArg=*/false);
+ StringRef PureCallName = CGM.getCXXABI().GetPureVirtualCallName();
+ PureVirtualFn = CGM.CreateRuntimeFunction(Ty, PureCallName);
+ PureVirtualFn = llvm::ConstantExpr::getBitCast(PureVirtualFn,
+ CGM.Int8PtrTy); } - + Init = PureVirtualFn; } else { // Check if we should use a thunk. diff --git a/lib/CodeGen/ItaniumCXXABI.cpp b/lib/CodeGen/ItaniumCXXABI.cpp index 8800e68704..0b7ce36d5b 100644 --- a/lib/CodeGen/ItaniumCXXABI.cpp +++ b/lib/CodeGen/ItaniumCXXABI.cpp @@ -108,6 +108,8 @@ public: void EmitInstanceFunctionProlog(CodeGenFunction &CGF); + StringRef GetPureVirtualCallName() { return "__cxa_pure_virtual"; } + CharUnits getArrayCookieSizeImpl(QualType elementType); llvm::Value *InitializeArrayCookie(CodeGenFunction &CGF, llvm::Value *NewPtr, diff --git a/lib/CodeGen/MicrosoftCXXABI.cpp b/lib/CodeGen/MicrosoftCXXABI.cpp index 026f2a5f80..6a2925bbd9 100644 --- a/lib/CodeGen/MicrosoftCXXABI.cpp +++ b/lib/CodeGen/MicrosoftCXXABI.cpp @@ -28,6 +28,8 @@ class MicrosoftCXXABI : public CGCXXABI { public: MicrosoftCXXABI(CodeGenModule &CGM) : CGCXXABI(CGM) {} + StringRef GetPureVirtualCallName() { return "_purecall"; } + void BuildConstructorSignature(const CXXConstructorDecl *Ctor, CXXCtorType Type, CanQualType &ResTy, |