llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.3k stars 12.11k forks source link

Clang-tidy export fixes no line numbers #114523

Open Tasty213 opened 3 weeks ago

Tasty213 commented 3 weeks ago

Hi,

I'm writing a script to run clang-tidy in a CI pipeline on bitbucket to get it to post code quality reports and was wondering if there's a way to convert the "FileOffset" in the output from export fixes to a line number? When submitting a report to bitbucket you can set a line number for the annotations so it knows where exactly in the PR to flag the issue.

Thanks in advance

PiotrZSL commented 3 weeks ago

FileOffset is offset in file, if you got oryginal file, you can write some script and check on what line and column an file offset is. Exported fixes should be used by automatic tools like clang-apply-replacements.

Tasty213 commented 1 week ago

Hi, I was writing a script to export the output of clang tidy to a bitbucket annotations report, ended up having to use the file path in the report to open up each file and calculate the offset based on the contents. But that was incredibly inefficient because it had to keep opening files for a project with hundreds of different source files. Could've cached the files but that would've quite easily gotten very large especially when processing the notes sections. Just might make the output of the reports a bit easier to process as part of a CI/CD system.