[PATCH] D66094: [CodeGen] Emit destructor calls for non-trivial C structs returned by function calls and loaded from volatile objects

John McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 17 19:28:01 PDT 2020


rjmccall added inline comments.


================
Comment at: clang/lib/Sema/SemaExpr.cpp:677
+      E->getType().isDestructedType() == QualType::DK_nontrivial_c_struct)
+    Cleanup.setExprNeedsCleanups(true);
+
----------------
ahatanak wrote:
> rjmccall wrote:
> > Why only when the l-value is volatile?
> I was trying to avoid emitting `ExprWithCleanups` when it wasn't needed and it seemed that it wasn't needed for non-volatile types. I'm not sure it's important, so I've removed the check for volatile. Also, `ExprWithCleanups` shouldn't' be emitted when this is in file scope, so I fixed that too.
Hmm, not sure about this file-scope thing, since the combination of C++ dynamic initializers and statement-expressions means  we can have pretty unrestricted code there.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66094/new/

https://reviews.llvm.org/D66094





More information about the cfe-commits mailing list