<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">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>