diff options
author | David Blaikie <dblaikie@gmail.com> | 2012-10-16 22:56:05 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2012-10-16 22:56:05 +0000 |
commit | eb7d598cec1564d33e47e3950d736d766eb918cf (patch) | |
tree | efcba0d9210352d524460306e82c64dce66fbe4b /clang/lib/CodeGen | |
parent | 4df59a9ff8363e78e9cd69727fe53d0e58b78903 (diff) | |
download | bcm5719-llvm-eb7d598cec1564d33e47e3950d736d766eb918cf.tar.gz bcm5719-llvm-eb7d598cec1564d33e47e3950d736d766eb918cf.zip |
PR13684: Emit vtable entries for deleted functions as __cxa_deleted_function.
This is consistent/interoperable with GCC 4.7 (& __cxa_deleted_function isn't
present in 4.4 - not sure when it got added, but you'll need something with
that function available for this to work).
llvm-svn: 166069
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r-- | clang/lib/CodeGen/CGCXXABI.h | 3 | ||||
-rw-r--r-- | clang/lib/CodeGen/CGVTables.cpp | 13 | ||||
-rw-r--r-- | clang/lib/CodeGen/ItaniumCXXABI.cpp | 1 | ||||
-rw-r--r-- | clang/lib/CodeGen/MicrosoftCXXABI.cpp | 3 |
4 files changed, 19 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CGCXXABI.h b/clang/lib/CodeGen/CGCXXABI.h index ffe70be2ca5..570aeb040f5 100644 --- a/clang/lib/CodeGen/CGCXXABI.h +++ b/clang/lib/CodeGen/CGCXXABI.h @@ -205,6 +205,9 @@ public: /// Gets the pure virtual member call function. virtual StringRef GetPureVirtualCallName() = 0; + /// Gets the deleted virtual member call name. + virtual StringRef GetDeletedVirtualCallName() = 0; + /**************************** Array cookies ******************************/ /// Returns the extra size required in order to store the array diff --git a/clang/lib/CodeGen/CGVTables.cpp b/clang/lib/CodeGen/CGVTables.cpp index 774def26e9c..4aeed1b00e0 100644 --- a/clang/lib/CodeGen/CGVTables.cpp +++ b/clang/lib/CodeGen/CGVTables.cpp @@ -537,7 +537,7 @@ CodeGenVTables::CreateVTableInitializer(const CXXRecordDecl *RD, unsigned NextVTableThunkIndex = 0; - llvm::Constant* PureVirtualFn = 0; + llvm::Constant *PureVirtualFn = 0, *DeletedVirtualFn = 0; for (unsigned I = 0; I != NumComponents; ++I) { VTableComponent Component = Components[I]; @@ -594,6 +594,17 @@ CodeGenVTables::CreateVTableInitializer(const CXXRecordDecl *RD, CGM.Int8PtrTy); } Init = PureVirtualFn; + } else if (cast<CXXMethodDecl>(GD.getDecl())->isDeleted()) { + if (!DeletedVirtualFn) { + llvm::FunctionType *Ty = + llvm::FunctionType::get(CGM.VoidTy, /*isVarArg=*/false); + StringRef DeletedCallName = + CGM.getCXXABI().GetDeletedVirtualCallName(); + DeletedVirtualFn = CGM.CreateRuntimeFunction(Ty, DeletedCallName); + DeletedVirtualFn = llvm::ConstantExpr::getBitCast(DeletedVirtualFn, + CGM.Int8PtrTy); + } + Init = DeletedVirtualFn; } else { // Check if we should use a thunk. if (NextVTableThunkIndex < NumVTableThunks && diff --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp b/clang/lib/CodeGen/ItaniumCXXABI.cpp index 674a97d88c2..50fcf72a4a0 100644 --- a/clang/lib/CodeGen/ItaniumCXXABI.cpp +++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp @@ -113,6 +113,7 @@ public: void EmitInstanceFunctionProlog(CodeGenFunction &CGF); StringRef GetPureVirtualCallName() { return "__cxa_pure_virtual"; } + StringRef GetDeletedVirtualCallName() { return "__cxa_deleted_virtual"; } CharUnits getArrayCookieSizeImpl(QualType elementType); llvm::Value *InitializeArrayCookie(CodeGenFunction &CGF, diff --git a/clang/lib/CodeGen/MicrosoftCXXABI.cpp b/clang/lib/CodeGen/MicrosoftCXXABI.cpp index 2c8173ba384..3d21787d0a8 100644 --- a/clang/lib/CodeGen/MicrosoftCXXABI.cpp +++ b/clang/lib/CodeGen/MicrosoftCXXABI.cpp @@ -29,6 +29,9 @@ 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, |