-
Notifications
You must be signed in to change notification settings - Fork 56
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
build: support clang tidy #1118
Open
jrajahalme
wants to merge
12
commits into
main
Choose a base branch
from
build-support-clang-tidy
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
+1,164
−896
Conversation
This file contains 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
jrajahalme
force-pushed
the
build-support-clang-tidy
branch
from
January 31, 2025 18:13
e36b76f
to
240684c
Compare
Add the following clang packages to install_clang function: - clangd-17 - lldb-17 - clang-tools-17 - cland-tidy-17 Add make targets: - compile_commands.json: create the compile commands database needed for both clang-tidy and clangd. Include absl which otherwise was unreachable for clangd. - tidy: Use run-clang-tidy-17 to run clang-tidy in parallel. It is still very slow. - tidy-fix: Run clang tidy and fix errors. Use with caution, as the fixes do not always compile. Add query option --incompatible_merge_fixed_and_default_shell_env to .bazelrc so that query does not trigger re-download of envoy dependency. This same option is set on 'build' in 'envoy.bazelrc'. Add some include rules that seem necessary to .clangd and implement the same rules in .clang-tidy. Signed-off-by: Jarno Rajahalme <[email protected]>
jrajahalme
force-pushed
the
build-support-clang-tidy
branch
5 times, most recently
from
February 2, 2025 17:45
a628209
to
86b219b
Compare
Add ci-clang-tidy workflow, linting files changed from 'main'. Signed-off-by: Jarno Rajahalme <[email protected]>
Now that we have new targets 'tidy' and 'tidy-fix', rename the old clang-format targets 'check' and 'fix' as 'format' and 'format-fix', respectively. Signed-off-by: Jarno Rajahalme <[email protected]>
We do not have a policy socket options any more, but a CiliumPolicyFilterState that contains a weak reference to the policy map. Rename 'policy_socket_option' as 'policy_ref' to make this a bit clearer. Signed-off-by: Jarno Rajahalme <[email protected]>
Signed-off-by: Jarno Rajahalme <[email protected]>
Use a separate local variable 'data_len' to make it clear that it does not need to be updated before 'input_len' is set. Signed-off-by: Jarno Rajahalme <[email protected]>
clang-tidy fix does not correctly handle renaming when removing trailing newlines from parameter names, so do this manually. Signed-off-by: Jarno Rajahalme <[email protected]>
jrajahalme
force-pushed
the
build-support-clang-tidy
branch
from
February 2, 2025 18:30
86b219b
to
18ce5be
Compare
Remove unnecessary includes, as well as unnecessary IWYU pragmas, while still keeping both clangd and clang-tidy happy. Signed-off-by: Jarno Rajahalme <[email protected]>
Replace typedefs with "using". Doing this as a separate step as clang-tidy fix will make errors doing this. Signed-off-by: Jarno Rajahalme <[email protected]>
Signed-off-by: Jarno Rajahalme <[email protected]>
Rename 'ops' as 'op_slice' and 'ops_' as 'ops'. This helps reduce confusion with member variables that have the '_' suffix. Signed-off-by: Jarno Rajahalme <[email protected]>
Signed-off-by: Jarno Rajahalme <[email protected]>
jrajahalme
force-pushed
the
build-support-clang-tidy
branch
from
February 3, 2025 19:12
0ff58c3
to
8279d8b
Compare
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.
Add new clang-tidy make targets
tidy
andtidy-fix
. Rename existing clang-format targets fromcheck
andfix
toformat
andformat-fix
, respectively.Add a new GH workflow to run clang-tidy on changed files.
Bazel build options are passed into
gen_compilation_database.py
so that the analysis cache is not invalidated betweenmake tidy
andmake tests
targets, for example..clang-tidy
is copied from upstream Envoy, with addition ofmisc-include-cleaner
IgnoreHeaders
options adapted from.clangd
.By default
make tidy
will tidy up all sources intests
andcilium
directories, which takes a long time. Defining the variableTIDY_SOURCES
can be used to specify a subset, e.g.,:Please note that
make tidy-fix
is prone to producing duplicated includes and non-compiling code, so all edits made with it must be manually inspected.For the tidy targets to work, the host must have the package
clang-tidy-17
installed..clang-tidy
is copied from upstream Envoy with the addition of linting local variables tolower_case
, which found out a few places where the "member variable suffix"_
was used on a local variable, in addition to somecamelCase
local variables that are now changed tolower_case
.