[cfe-dev] emit JSON output from clang-tidy

Stephen Kelly via cfe-dev cfe-dev at lists.llvm.org
Thu Oct 25 12:17:21 PDT 2018


On 25/10/2018 10:40, Oza, Hiral via cfe-dev wrote:
> Greetings!
> 
> Exploring ways to emit JSON output from clang-tidy such that it can be cached.
> 
> Which is the right place to add/modify code  -- (a) in ClangTidyDiagnosticConsumer::finish()  [at this point we have filtered diag errors] OR
>            (b) ClangTidyContext::diag() [getting invoked on each unfiltered diagnostic error]
> 
>  From ClangTidyContext, DiagnosticEngine and SourceManager, how to get json tuple {"tidy-checker":<tidy-checker-name>,"file":<source-file-name>,"line":<line#>,"column":<column#> }.
> 
> Thank you in advance.

clang-tidy emits YAML if you use -export-fixes=myfile.yaml. If all you 
want is caching, that should work?

Other than that, if JSON is a hard requirement, you might be done 
quicker if you find a yaml to json converter.

If you really want to hack it into the code, you could probably do it at 
the same time as the YAML is generated with the call to 
clang::tidy::exportReplacements.

Thanks,

Stephen.



More information about the cfe-dev mailing list