[PATCH] D54344: [Clang][CodeGen][CXX]: Workaround __attribute((no_destroy)) crash/incorrect code generation.

Erik Pilkington via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Nov 10 11:53:20 PST 2018


erik.pilkington added a comment.

I have a few nits, but I think this looks about right.

I reduced this testcase with creduce, can you use the minimized version? Also, I think it makes more sense to put the test into `test/CodeGenCXX` and verify the `-emit-llvm-only` output is correct with FileCheck. You can check out pretty much any test in that directory for an example of how to do this if you don't know already.

  class a {
  public:
    ~a();
  };
  class logger_base {
    a d;
  };
  class e : logger_base {};
  __attribute((no_destroy)) e g;



================
Comment at: lib/CodeGen/CGDeclCXX.cpp:72
+  // attribute (D54344).
+  if (D.hasAttr<NoDestroyAttr>())
+    return;
----------------
You should do this with `D.isNoDestroy(CGF.getContext())`, I suspect that this will still crash with `-fno-c++-static-destructors` without an attribute, and that function checks for the existence of that flag. Can you add a test for that too?


https://reviews.llvm.org/D54344





More information about the cfe-commits mailing list