[PATCH] [Clang/CodeGen] Prevent crash if destructor class is not accessible

Davide Italiano dccitaliano at gmail.com
Wed Jun 17 10:30:33 PDT 2015


Hi rjmccall,

Fixes

struct A {
  ~A();
};

struct B {
  A a;
};

struct C {
  union {
    B b;
  };

  ~C() noexcept;
};

C::~C() noexcept {}

REPOSITORY
  rL LLVM

http://reviews.llvm.org/D10508

Files:
  lib/CodeGen/CGClass.cpp

Index: lib/CodeGen/CGClass.cpp
===================================================================
--- lib/CodeGen/CGClass.cpp
+++ lib/CodeGen/CGClass.cpp
@@ -1293,6 +1293,9 @@
                          const CXXRecordDecl *BaseClassDecl,
                          const CXXRecordDecl *MostDerivedClassDecl)
 {
+  if (!BaseClassDecl->hasSimpleDestructor())
+    return false;
+
   // If the destructor is trivial we don't have to check anything else.
   if (BaseClassDecl->hasTrivialDestructor())
     return true;

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D10508.27844.patch
Type: text/x-patch
Size: 515 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150617/1720a1cd/attachment.bin>


More information about the cfe-commits mailing list