Skip to content

Commit 0dc3348

Browse files
pkastingCommit Bot
authored and
Commit Bot
committed
Updates for things I ran into while running clang-tidy locally.
* Make ui/views/.clang-tidy additive to the base file, not a replacement. * Hoist the "use equals" config option to the base file, since that's Chromium style. * Update docs for errors or inclarities. Bug: none Change-Id: I7f22db99d9ff11fc91665776887a02f7184427ae Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2483344 Auto-Submit: Peter Kasting <[email protected]> Commit-Queue: George Burgess <[email protected]> Reviewed-by: George Burgess <[email protected]> Cr-Commit-Position: refs/heads/master@{#818330}
1 parent a0bd478 commit 0dc3348

File tree

3 files changed

+15
-36
lines changed

3 files changed

+15
-36
lines changed

.clang-tidy

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
---
21
---
32
Checks: '-*,
43
bugprone-string-integer-assignment,
@@ -25,6 +24,8 @@
2524
modernize-use-transparent-functors,
2625
readability-redundant-member-init'
2726
CheckOptions:
27+
- key: modernize-use-default-member-init.UseAssignment
28+
value: 1
2829
# This relaxes modernize-use-emplace in some cases; we might want to make it
2930
# more aggressive in the future. See discussion on
3031
# https://groups.google.com/a/chromium.org/g/cxx/c/noMMTNYiM0w .

docs/clang_tidy.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ clang-tidy across all of Chromium is a single command:
7575

7676
```
7777
$ cd ${chromium}/src
78-
$ ${chromium_build}/scripts/slave/recipe_modules/tricium_clang_tidy/resources/tricium_clang_tidy.py \
78+
$ ${chromium_build}/recipes/recipe_modules/tricium_clang_tidy/resources/tricium_clang_tidy.py \
7979
--base_path $PWD \
8080
--out_dir out/Linux \
8181
--findings_file all_findings.json \
@@ -212,19 +212,19 @@ gn gen . --export-compile-commands
212212
```
213213
4. Run clang-tidy.
214214
```
215-
<PATH_TO_LLVM_SRC>/clang-tidy/tool/run-clang-tidy.py \
215+
<PATH_TO_LLVM_SRC>/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py \
216216
-p . \# Set the root project directory, where compile_commands.json is.
217217
# Set the clang-tidy binary path, if it's not in your $PATH.
218218
-clang-tidy-binary <PATH_TO_LLVM_BUILD>/bin/clang-tidy \
219219
# Set the clang-apply-replacements binary path, if it's not in your $PATH
220220
# and you are using the `fix` behavior of clang-tidy.
221221
-clang-apply-replacements-binary \
222222
<PATH_TO_LLVM_BUILD>/bin/clang-apply-replacements \
223-
# The checks to employ in the build. Use `-*` to omit default checks.
223+
# The checks to employ in the build. Use `-*,...` to omit default checks.
224224
-checks=<CHECKS> \
225225
-header-filter=<FILTER> \# Optional, limit results to only certain files.
226226
-fix \# Optional, used if you want to have clang-tidy auto-fix errors.
227-
chrome/browser # The path to the files you want to check.
227+
'chrome/browser/.*' # A regex of the files you want to check.
228228
229229
Copy-Paste Friendly (though you'll still need to stub in the variables):
230230
<PATH_TO_LLVM_SRC>/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py \
@@ -235,12 +235,12 @@ Copy-Paste Friendly (though you'll still need to stub in the variables):
235235
-checks=<CHECKS> \
236236
-header-filter=<FILTER> \
237237
-fix \
238-
chrome/browser
238+
'chrome/browser/.*'
239239
```
240240

241-
\*It's not clear which, if any, `gn` flags may cause issues for
242-
`clang-tidy`. I've had no problems building a component release build,
243-
both with and without goma. if you run into issues, let us know!
241+
Note that the source file regex must match how the build specified the file.
242+
This means that on Windows, you must use (escaped) backslashes even from a bash
243+
shell.
244244

245245
### Questions
246246

ui/views/.clang-tidy

+5-27
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,7 @@
11
---
2-
Checks: '-*,
3-
google-build-namespaces,
4-
google-explicit-constructor,
5-
google-readability-casting,
6-
google-readability-namespace-comments,
7-
modernize-avoid-bind,
8-
modernize-loop-convert,
9-
modernize-make-shared,
10-
modernize-make-unique,
11-
modernize-redundant-void-arg,
12-
modernize-replace-auto-ptr,
13-
modernize-replace-random-shuffle,
14-
modernize-shrink-to-fit,
15-
modernize-use-bool-literals,
16-
modernize-use-default-member-init,
17-
modernize-use-emplace,
18-
modernize-use-equals-default,
19-
modernize-use-noexcept,
20-
modernize-use-nullptr,
21-
modernize-use-override,
22-
modernize-use-transparent-functors,
23-
modernize-use-using,
24-
readability-redundant-member-init'
25-
HeaderFilterRegex: 'ui/views/*'
26-
CheckOptions:
27-
- key: modernize-use-default-member-init.UseAssignment
28-
value: 1
2+
Checks: 'google-build-namespaces,
3+
google-readability-namespace-comments,
4+
modernize-replace-auto-ptr,
5+
modernize-use-using'
6+
HeaderFilterRegex: 'ui/views/*'
297
...

0 commit comments

Comments
 (0)