[PATCH] [Win32 ABI] Defer operator delete check until vtable is marked used

Hans Wennborg hans at chromium.org
Thu Feb 20 18:14:44 PST 2014


Hi rsmith, pcc,

This is a follow-up to Richard's comments from http://llvm-reviews.chandlerc.com/D2401#comment-2: "I wonder if we're being too eager when performing operator delete lookup for a class with a virtual destructor. Instead of performing the lookup when the destructor is declared, could we defer it until the vtable is used?"

The patch is an attempt to do this. It does clean up the tests nicely.

pcc's patch that added this check is here: http://llvm-reviews.chandlerc.com/D822. With my patch we will no longer reject his example:

    struct B {
      void operator delete(void *);
    };

    struct C : A, B {
      virtual ~C();
    };

.. unless C's vtable is marked used.

Besides just moving the check, I also updated CXXDestructorDecl::{get,set}OperatorDelete() to work with the first declaration. Without this, for some reason, in the code below we would set OperatorDelete on the function *definition* (because that's where we perform the check), and then fail an assert in codegen for the function *declaration*. I'm not sure why we end up in that situation on win32 and not linux :/

    struct F {
      virtual ~F();
    };
    F::~F() {
    }
    F f;

http://llvm-reviews.chandlerc.com/D2851

Files:
  include/clang/AST/DeclCXX.h
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclCXX.cpp
  test/CXX/drs/dr2xx.cpp
  test/CXX/special/class.dtor/p9.cpp
  test/SemaCXX/microsoft-dtor-lookup.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D2851.1.patch
Type: text/x-patch
Size: 8186 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140220/f322c290/attachment.bin>


More information about the cfe-commits mailing list