Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Add clang-tidy job #2973

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft

ci: Add clang-tidy job #2973

wants to merge 5 commits into from

Conversation

danobi
Copy link
Member

@danobi danobi commented Jan 30, 2024

Experimental job to enable clang-tidy. This action should only run against the changes made in the PR.

This closes #2971.

Checklist
  • Language changes are updated in man/adoc/bpftrace.adoc and if needed in docs/reference_guide.md
  • User-visible and non-trivial changes updated in CHANGELOG.md
  • The new behaviour is covered by tests

@danobi danobi added the ci Issues or PRs related to Github Actions CI label Jan 30, 2024
@danobi danobi force-pushed the clang_tidy branch 2 times, most recently from be7dc8b to 3aa87a4 Compare January 30, 2024 16:42
@danobi
Copy link
Member Author

danobi commented Jan 30, 2024

I'm thinking that rather than get fancy with the GH action, we should slowly allow-list lints into .clang-tidy.yml paired with codemods. That way, codebase always stays clang-tidy clean and we can do a naive clang-tidy over all source files. And we can run that inside nix env so it's easy to repro locally.

A script we maintain that can both -fix and use in CI would be nice.

Fixes the following warning:

/home/dxu/dev/bpftrace/src/ast/irbuilderbpf.cpp: In member function 'llvm::CallInst* bpftrace::ast::IRBuilderBPF::CreateGetNs(bpftrace::TimestampMode, const bpftrace::location&)':
/home/dxu/dev/bpftrace/src/ast/irbuilderbpf.cpp:1025:26: warning: 'fn' may be used uninitialized [-Wmaybe-uninitialized]
 1025 |   return CreateHelperCall(fn, gettime_func_type, {}, "get_ns", &loc);
      |          ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/dxu/dev/bpftrace/src/ast/irbuilderbpf.cpp:1003:23: note: 'fn' was declared here
 1003 |   libbpf::bpf_func_id fn;
      |                       ^~
We get a lot (thousands) of warnings if we enable all checks. Not all
checks are relevant. We should add more as we notice things.
This change places the devshell packages earlier in $PATH than the
inherited ones. This is important when devshell packages shadow tools in
other packages.

More specifically, we want to use the nix-aware "wrapped" clang-tidy
from clang-tools rather than the "dumb" clang-tidy from clang.
@danobi danobi force-pushed the clang_tidy branch 2 times, most recently from 6ce3fa5 to 4bed243 Compare February 10, 2024 22:51
@danobi danobi changed the title ci: clang-tidy: Add clang-tidy job ci: Add clang-tidy job Feb 10, 2024
This job runs clang tidy against the working directory.

This closes bpftrace#2971.
Looks most like casting fixes with ranged-for-loop fix mixed in as well.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci Issues or PRs related to Github Actions CI waiting-on-author
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Set up clang-tidy in CI
1 participant