]> granicus.if.org Git - clang/commitdiff
MS ABI: The latest VC "14" CTP implements deleted virtual functions
authorDavid Majnemer <david.majnemer@gmail.com>
Fri, 12 Sep 2014 04:38:08 +0000 (04:38 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Fri, 12 Sep 2014 04:38:08 +0000 (04:38 +0000)
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
lib/CodeGen/MicrosoftCXXABI.cpp
test/CodeGenCXX/microsoft-abi-vtables-virtual-inheritance.cpp

index 3d29b5ea8d316c2ebf675505106cee89aa7dd688..9922308760200019fecf8f7ed36af3e83291793c 100644 (file)
@@ -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())
index 04b7ea08edc6630d07982b64b21b19a0107dbc85..553112110c96edfaa6675bc9c076bdefc3cd07b5 100644 (file)
@@ -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,
index 5f0c5050c039aa1b04b35ae41374fc1745d1cb7c..2e4a056316c617d05608ff95d5916894f39d35c7 100644 (file)
@@ -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;
+};
+}