Someone recently asked about a problem with a clang tutorial from:
https://github.com/loarabia/Clang-tutorial
There was a piece of code common to many of the tutorials (since fixed in the latest version):
CompilerInstance ci;
DiagnosticOptions diagnosticOptions;
TextDiagnosticPrinter *pTextDiagnosticPrinter =
new TextDiagnosticPrinter(
llvm::outs(),
&diagnosticOptions,
true);
ci.createDiagnostics(pTextDiagnosticPrinter);
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:
ci.createDiagnostics(pTextDiagnosticPrinter);
should have been:
ci.createDiagnostics(&diagnosticOptions);
and the first call should have been flagged as an error by clang.
Am I missing something obvious here?
Thanks,
Robert Ankeney