From fee0818867233e13e4173c7e7f7e5f97b0fb4659 Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Fri, 12 Sep 2014 04:38:08 +0000 Subject: [PATCH] MS ABI: The latest VC "14" CTP implements deleted virtual functions Deleted virtual functions get _purecall inserted into the vftable. Earlier CTPs would simply stick nullptr in there. N.B. MSVC can't handle deleted virtual functions which require return adjusting thunks, they give an error that a deleted function couldn't be called inside of a compiler generated function. We get this correct by making the thunk have a __purecall entry as well. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217654 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/AST/VTableBuilder.cpp | 11 +---------- lib/CodeGen/MicrosoftCXXABI.cpp | 2 -- .../microsoft-abi-vtables-virtual-inheritance.cpp | 10 +++++++++- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/lib/AST/VTableBuilder.cpp b/lib/AST/VTableBuilder.cpp index 3d29b5ea8d..9922308760 100644 --- a/lib/AST/VTableBuilder.cpp +++ b/lib/AST/VTableBuilder.cpp @@ -2566,13 +2566,6 @@ private: } } - void ErrorUnsupported(StringRef Feature, SourceLocation Location) { - clang::DiagnosticsEngine &Diags = Context.getDiagnostics(); - unsigned DiagID = Diags.getCustomDiagID( - DiagnosticsEngine::Error, "v-table layout for %0 is not supported yet"); - Diags.Report(Context.getFullLoc(Location), DiagID) << Feature; - } - public: VFTableBuilder(MicrosoftVTableContext &VTables, const CXXRecordDecl *MostDerivedClass, const VPtrInfo *Which) @@ -3037,10 +3030,8 @@ void VFTableBuilder::dumpLayout(raw_ostream &Out) { if (MD->isPure()) Out << " [pure]"; - if (MD->isDeleted()) { - ErrorUnsupported("deleted methods", MD->getLocation()); + if (MD->isDeleted()) Out << " [deleted]"; - } ThunkInfo Thunk = VTableThunks.lookup(I); if (!Thunk.isEmpty()) diff --git a/lib/CodeGen/MicrosoftCXXABI.cpp b/lib/CodeGen/MicrosoftCXXABI.cpp index 04b7ea08ed..553112110c 100644 --- a/lib/CodeGen/MicrosoftCXXABI.cpp +++ b/lib/CodeGen/MicrosoftCXXABI.cpp @@ -63,8 +63,6 @@ public: } StringRef GetPureVirtualCallName() override { return "_purecall"; } - // No known support for deleted functions in MSVC yet, so this choice is - // arbitrary. StringRef GetDeletedVirtualCallName() override { return "_purecall"; } llvm::Value *adjustToCompleteObject(CodeGenFunction &CGF, diff --git a/test/CodeGenCXX/microsoft-abi-vtables-virtual-inheritance.cpp b/test/CodeGenCXX/microsoft-abi-vtables-virtual-inheritance.cpp index 5f0c5050c0..2e4a056316 100644 --- a/test/CodeGenCXX/microsoft-abi-vtables-virtual-inheritance.cpp +++ b/test/CodeGenCXX/microsoft-abi-vtables-virtual-inheritance.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fno-rtti -emit-llvm -o %t.ll -fdump-vtable-layouts %s -triple=i386-pc-win32 >%t +// RUN: %clang_cc1 -std=c++11 -fms-extensions -fno-rtti -emit-llvm -o %t.ll -fdump-vtable-layouts %s -triple=i386-pc-win32 >%t // RUN: FileCheck %s < %t // RUN: FileCheck --check-prefix=MANGLING %s < %t.ll @@ -764,3 +764,11 @@ struct W : B, Y { W::W() {} } + +namespace Test13 { +struct __declspec(dllexport) A { + // CHECK-LABEL: VFTable for 'Test13::A' (1 entry). + // CHECK-NEXT: 0 | void Test13::A::f() [deleted] + virtual void f() = delete; +}; +} -- 2.40.0