[PATCH] D47616: [CFG] [analyzer] Explain copy elision through construction contexts.

Artem Dergachev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu May 31 19:00:55 PDT 2018


NoQ created this revision.
NoQ added reviewers: dcoughlin, xazax.hun, a.sidorin, george.karpenkov, szepet, rnkovacs.
Herald added subscribers: cfe-commits, baloghadamsoftware.

Copy elision occurs when

1. a temporary object (with its corresponding temporary object construction context) is constructed and
2. it is immediately copied or moved into any other object (with its own construction context, which can be any construction context).

Constructor on step 2 would then be called "elidable".

Copy elision consists in skipping ("eliding") the constructor on step 2 and performing the constructor on step 1 as if it was constructing the object of step 2. Additionally, destructors are skipped for the temporary object constructed on step 1.

The current patch modifies the temporary object construction context for constructor on step 1 to include information about the upcoming step 2. Only temporary object construction contexts would need to be updated because step 1 always has a temporary object construction context.

The updated context will include both a reference to the elidable construct-expression of step 2 and the construction context of step 2. This will allow the analyzer to both skip the elidable constructor itself when it's encountered and compute the correct target region associated with step 2 while modeling step 1.

TOTHINK: whether "temporary object construction context with elision" should be a separate construction context sub-class.


Repository:
  rC Clang

https://reviews.llvm.org/D47616

Files:
  include/clang/Analysis/ConstructionContext.h
  lib/Analysis/CFG.cpp
  lib/Analysis/ConstructionContext.cpp
  test/Analysis/cfg-rich-constructors.cpp
  test/Analysis/temp-obj-dtors-cfg-output.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47616.149389.patch
Type: text/x-patch
Size: 29854 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180601/8fd50c07/attachment-0001.bin>


More information about the cfe-commits mailing list