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

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


+ Anders Carlsson who originally wrote the code (apparently he's not
on phabricator).
Also the summary of this review should be read as "Prevent crash if
class destructor is not accessible".


On Wed, Jun 17, 2015 at 10:30 AM, Davide Italiano <dccitaliano at gmail.com> wrote:
> 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/



More information about the cfe-commits mailing list