<div dir="ltr">There are two different createDiagnostics methods with different signatures. TextDiagnosticPrinter inherits from DiagnosticConsumer so pTextDiagnosticPrinter would have called the first signature. &DiagnosticOptions calls the second signature.<div>
<br></div><div><div>  void createDiagnostics(DiagnosticConsumer *Client = 0,</div><div>                         bool ShouldOwnClient = true);</div><div><br></div><div>  static IntrusiveRefCntPtr<DiagnosticsEngine></div>
<div>  createDiagnostics(DiagnosticOptions *Opts,</div><div>                    DiagnosticConsumer *Client = 0,</div><div>                    bool ShouldOwnClient = true,</div><div>                    const CodeGenOptions *CodeGenOpts = 0);</div>
</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sun, Aug 18, 2013 at 5:42 AM, Robert Ankeney <span dir="ltr"><<a href="mailto:rrankene@gmail.com" target="_blank">rrankene@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div>Someone recently asked about a problem with a clang tutorial from:<br><a href="https://github.com/loarabia/Clang-tutorial" target="_blank">https://github.com/loarabia/Clang-tutorial</a><br>
<br></div>There was a piece of code common to many of the tutorials (since fixed in the latest version):<br>
<br>    CompilerInstance ci;<br>
    DiagnosticOptions diagnosticOptions;<br>
    TextDiagnosticPrinter *pTextDiagnosticPrinter =<br>
        new TextDiagnosticPrinter(<br>
            llvm::outs(),<br>
            &diagnosticOptions,<br>
            true);<br>
    ci.createDiagnostics(pTextDiagnosticPrinter);<br><div><br><div>
</div></div>that was causing a runtime error due to an unfreed pointer (which was true). But looking at the code and the documentation for CompilerInstance, it seems the line:<br>    ci.createDiagnostics(pTextDiagnosticPrinter);<br>

</div>should have been:<br>     ci.createDiagnostics(&diagnosticOptions);<br></div>and the first call should have been flagged as an error by clang.<br><div><br>Am I missing something obvious here?<br></div><div>Thanks,<br>

Robert Ankeney<br></div><div><div><br></div></div></div>
<br>_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br>~Craig
</div>