Repository navigation
feat: run clang-tidy on a source by the commands that compile it - #147
Merged
Merged
Conversation
analyzeFile runs clang-tidy from the project root with the directory of compile_commands.json, and returns everything it wrote. Checks given replace those of .clang-tidy, so they come after -*. --quiet leaves out the count of warnings on the versions that honour it. src/check joins the linted modules.
The clang-format and clang-tidy tests each wrote the same script and split the file it writes into lines. Both now come from the test support, which reads the file with the standard library so it keeps linking no scrap module.
clang-tidy given an empty -p analyzes without the commands, and given --checks=-*, alone enables no check and refuses to run.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds the part that runs clang-tidy, which
scrap checkwill use. No command uses it yet.Check::analyzeFileruns clang-tidy in the project root on one source, with-p=naming the directory ofcompile_commands.json, so every command that compiles the source is analyzed in one run. It returns everything clang-tidy wrote, both streams together, or the failure holding it..clang-tidyas--checks=-*,<checks>, since--checksalone adds to them. The other settings of.clang-tidystay in effect.--quietis passed. clang-tidy 22 then leaves out the "N warnings generated." lines; clang-tidy 18 still writes them.src/tool, as for clang-format.src/checkjoins the linted modules.Tests
ClangTidyTest, 5 tests, with a script standing in for clang-tidy, written by the test support thatClangFormatTestnow uses too: the command line from the project root, the checks in place of the configuration's, a file that looks like an option, an analysis that ends with a status other than 0, and one stopped by a signal or not started.Taking out
--quiet, the-*, the./before a file that looks like an option, the project root, or standard error from what comes back each fails at least one of them.The command line was also run with clang-tidy 18.1.3 on a project whose
.clang-tidyenablesmodernize-use-nullptr: without checks given it reported that check, and withreadability-braces-around-statementsgiven it reported that one alone.