[PATCH] D66404: [CFG] Make destructor calls more accurate

Nicholas Allegra via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Aug 18 16:16:34 PDT 2019

comex created this revision.
comex added reviewers: dergachev.a, Szelethus, dcoughlin.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Note: I don't have commit access.

Various changes to reduce discrepancies in destructor calls between the
generated CFG and the actual codegen, along with a new test file.

In particular:

- Respect C++17 copy elision; previously it would generate destructor calls for elided temporaries, including in initialization and return statements.

- Don't generate duplicate destructor calls for statement expressions.

- Fix initialization lists.

- Fix comma operator.

- Change printing of implicit destructors to print the type instead of the class name directly, matching the code for temporary object destructors.  The class name was blank for lambdas.

Also update some existing tests which were broken by the changed formatting
and/or the fixed behavior.

Implementation notes:

- Rename BindToTemporary to ExternallyDestructed, which more accurately reflects what the parameter does and matches the naming in CodeGen.

- Change VisitChildrenForTemporaryDtors to take an ExternallyDestructed parameter, for the sake of InitListExprs, which have an arbitrary number of children and may or may not be externally destructed.

- Add a function VisitExternallyDestructed with the right behavior for return statements and statement expressions.

The new test file also includes tests for some preexisting buggy cases which
this patch does *not* fix.  What a mess...

  rC Clang



-------------- next part --------------
A non-text attachment was scrubbed...
Name: D66404.215807.patch
Type: text/x-patch
Size: 35549 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190818/8f2aff8b/attachment-0001.bin>

More information about the cfe-commits mailing list