[llvm-bugs] [Bug 34580] New: extra CFGImplicitDtor elements in CFG

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Sep 12 08:58:18 PDT 2017


            Bug ID: 34580
           Summary: extra CFGImplicitDtor elements in CFG
           Product: clang
           Version: 5.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: liblit at acm.org
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org

Created attachment 19146
  --> https://bugs.llvm.org/attachment.cgi?id=19146&action=edit
demonstration C++ source file with a "noisy" destructor

I am using Clang tooling libraries to build a control-flow graph for C++ code. 
I need this CFG to accurately reflect all implicit calls to destructors, so I
have set both the AddImplicitDtors and AddTemporaryDtors CFG build options. 
Unfortunately, this results in a CFG with *extra* CFGImplicitDtor items that do
not correspond to actual destructor calls in the generated code.

Consider the attached C++11 (or later) test program, "test.cc", with a "noisy"
destructor.  When run, this program prints "destroy" three times.  However, its
CFG includes two CFGTemporaryDtor elements plus two CFGAutomaticObjDtor
elements.  So I have a CFG that shows four destructor calls when only three
will take place.  (The second attached file, "dump-main-cfg.cc", is a
bare-bones Clang-based CFG dumping tool used here to help reproduce the

If I comment out lines in main(), leaving only "give();" and the return, then I
have one "destroy" printed and one CFGTemporaryDtor in the CFG. Good.

If instead I leave only "Base base1;" and the return, then I have one "destroy"
printed and one CFGAutomaticObjDtor in the CFG.  Also good.

If instead I leave only "Base base2(give());" and the return, then I have one
"destroy" printed and both one CFGTemporaryDtor *and* one CFGAutomaticObjDtor
in the CFG.  Not good. 

How can I suppress, remove, recognize, or otherwise filter out the extra
CFGImplicitDtor in cases like "Base base2(give());"?  Is there some property I
can check of the CFGTemporaryDtor and/or CFGAutomaticObjDtor instances to
determine which ones will turn into real destructor calls and which will not? 
Should the extra CFGImplicitDtor not be appearing in the CFG in the first
place?  Is this a misunderstanding on my part or a true bug in the CFG-building

Note: this concern was originally posted to the cfe-dev mailing list, and is
archived at <http://lists.llvm.org/pipermail/cfe-dev/2017-May/053939.html>. 
There were no replies.  I am therefore inclined to consider this as a bug
rather than just a misunderstanding.  If, however, there is a way for me to
deal with the extra destructors without changes to the underlying CFG logic,
then that's OK with me too.

You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170912/1fff3e1e/attachment-0001.html>

More information about the llvm-bugs mailing list