[cfe-commits] [patch] Add implicit automatic variable dtors for C++ CFG

Zhongxing Xu xuzhongxing at gmail.com
Sat Sep 18 05:26:05 PDT 2010


This patch adds automatic variable's dtors to the CFG. It uses LocalScope to
record the automatic variables in each scope. When building the CFG,
CleanupPoints are inserted at ReturnStmt, CompoundStmt and GotoStmt.

After the building process, dtors are inserted into the cleanup points.

To hook up the LocalScope when entering a CompoundStmt, now autoCreate a
block.
This may potentially create redundant blocks. But I think it's easy to
remove
them.

Some code is tricky. It is so to guarantee the correct order the dtors are
inserted. I'm not sure they are the best approach.

Later we would add an option to control the CFG build option. Currently
adding implicit dtors are disabled. If it is enabled, some c++ test cases
would
fail.

Some test cases that this patch can handle are attached. They can be tested
by changing

if (BuildOpts.AddImplicitDtors) {

to

if (true) {
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20100918/e2307f9e/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cfg.patch
Type: text/x-patch
Size: 12537 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20100918/e2307f9e/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: scope0.cpp
Type: text/x-c++src
Size: 61 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20100918/e2307f9e/attachment.cpp>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: scope2.cpp
Type: text/x-c++src
Size: 93 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20100918/e2307f9e/attachment-0001.cpp>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: scope3.cpp
Type: text/x-c++src
Size: 324 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20100918/e2307f9e/attachment-0002.cpp>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: scope4.cpp
Type: text/x-c++src
Size: 432 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20100918/e2307f9e/attachment-0003.cpp>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: scope5.cpp
Type: text/x-c++src
Size: 126 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20100918/e2307f9e/attachment-0004.cpp>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: scope9.cpp
Type: text/x-c++src
Size: 212 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20100918/e2307f9e/attachment-0005.cpp>


More information about the cfe-commits mailing list