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

Richard Smith richard at metafoo.co.uk
Mon Jun 22 11:38:38 PDT 2015


REPOSITORY
  rL LLVM

================
Comment at: cfe/trunk/lib/CodeGen/CGClass.cpp:1345
@@ -1344,3 +1348,3 @@
   CXXRecordDecl *FieldClassDecl = cast<CXXRecordDecl>(RT->getDecl());
   return HasTrivialDestructorBody(Context, FieldClassDecl, FieldClassDecl);
 }
----------------
The right place to fix this is here. The corresponding code from Sema is:

    // The destructor for an implicit anonymous union member is never invoked.
    if (FieldClassDecl->isUnion() && FieldClassDecl->isAnonymousStructOrUnion())
      continue;

Since the AST doesn't explicitly list the field destructor class that a destructor will perform, we need to mirror that check here. (Alternatively, we could change Sema to declare a trivial destructor for an anonymous union member, but that seems a little wasteful.)

http://reviews.llvm.org/D10508

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the cfe-commits mailing list