[PATCH] D153294: [clang] Do not create ExprWithCleanups while checking immediate invocation

Mariya Podchishchaeva via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 26 04:20:30 PDT 2023


Fznamznon added a comment.

> One thing we will need to be careful about is assigning any block / compound literal cleanups to the right ExprWithCleanups node. We can figure out where to put them by doing a traversal of the ConstantExpr's subexpression to see if it contains the BlockDecl / CompoundLiteralExpr being referenced by the cleanup

I'm having a slight trouble with understanding why this part is required and how to implement the test that would use this part. I've got a feeling that it will be adding a bit of a dead code because `BlockDecl` seems to be ObjC-only construct, so I don't think I can get it inside of an immediate invocation. Compound literals in C++ are never referenced in `ExprCleanupObjects` which clang normally uses to attach `BlockDecl / CompoundLiteralExpr` to an `ExprWithCleanups`, according to https://github.com/llvm/llvm-project/blob/00b12a94322dc7779f42d7f863957f8ea4304dad/clang/lib/Sema/SemaExpr.cpp#L7731 .
@rsmith could you please suggest the test case where it is required?

Also, simply adding a flag to `MaybeCreateExprWithCleanup` signaling that we're processing an immediate invocation to not discard cleanups also passes check-clang and fixes original memory leak problem. Maybe we should just do that?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153294



More information about the cfe-commits mailing list