<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - extra CFGImplicitDtor elements in CFG"
   href="https://bugs.llvm.org/show_bug.cgi?id=34580">34580</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>extra CFGImplicitDtor elements in CFG
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>5.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>C++
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>liblit@acm.org
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=19146" name="attach_19146" title="demonstration C++ source file with a "noisy" destructor">attachment 19146</a> <a href="attachment.cgi?id=19146&action=edit" title="demonstration C++ source file with a "noisy" destructor">[details]</a></span>
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
problem.)

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
code?

Note: this concern was originally posted to the cfe-dev mailing list, and is
archived at <<a href="http://lists.llvm.org/pipermail/cfe-dev/2017-May/053939.html">http://lists.llvm.org/pipermail/cfe-dev/2017-May/053939.html</a>>. 
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.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>