Skip to content

Commit

Permalink
Updates for things I ran into while running clang-tidy locally.
Browse files Browse the repository at this point in the history
* 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 <pkasting@chromium.org>
Commit-Queue: George Burgess <gbiv@chromium.org>
Reviewed-by: George Burgess <gbiv@chromium.org>
Cr-Commit-Position: refs/heads/master@{#818330}
  • Loading branch information
pkasting authored and Commit Bot committed Oct 19, 2020
1 parent a0bd478 commit 0dc3348
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 36 deletions.
3 changes: 2 additions & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
---
Checks: '-*,
bugprone-string-integer-assignment,
Expand All @@ -25,6 +24,8 @@
modernize-use-transparent-functors,
readability-redundant-member-init'
CheckOptions:
- key: modernize-use-default-member-init.UseAssignment
value: 1
# This relaxes modernize-use-emplace in some cases; we might want to make it
# more aggressive in the future. See discussion on
# https://groups.google.com/a/chromium.org/g/cxx/c/noMMTNYiM0w .
Expand Down
16 changes: 8 additions & 8 deletions docs/clang_tidy.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ clang-tidy across all of Chromium is a single command:

```
$ cd ${chromium}/src
$ ${chromium_build}/scripts/slave/recipe_modules/tricium_clang_tidy/resources/tricium_clang_tidy.py \
$ ${chromium_build}/recipes/recipe_modules/tricium_clang_tidy/resources/tricium_clang_tidy.py \
--base_path $PWD \
--out_dir out/Linux \
--findings_file all_findings.json \
Expand Down Expand Up @@ -212,19 +212,19 @@ gn gen . --export-compile-commands
```
4. Run clang-tidy.
```
<PATH_TO_LLVM_SRC>/clang-tidy/tool/run-clang-tidy.py \
<PATH_TO_LLVM_SRC>/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py \
-p . \# Set the root project directory, where compile_commands.json is.
# Set the clang-tidy binary path, if it's not in your $PATH.
-clang-tidy-binary <PATH_TO_LLVM_BUILD>/bin/clang-tidy \
# Set the clang-apply-replacements binary path, if it's not in your $PATH
# and you are using the `fix` behavior of clang-tidy.
-clang-apply-replacements-binary \
<PATH_TO_LLVM_BUILD>/bin/clang-apply-replacements \
# The checks to employ in the build. Use `-*` to omit default checks.
# The checks to employ in the build. Use `-*,...` to omit default checks.
-checks=<CHECKS> \
-header-filter=<FILTER> \# Optional, limit results to only certain files.
-fix \# Optional, used if you want to have clang-tidy auto-fix errors.
chrome/browser # The path to the files you want to check.
'chrome/browser/.*' # A regex of the files you want to check.
Copy-Paste Friendly (though you'll still need to stub in the variables):
<PATH_TO_LLVM_SRC>/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py \
Expand All @@ -235,12 +235,12 @@ Copy-Paste Friendly (though you'll still need to stub in the variables):
-checks=<CHECKS> \
-header-filter=<FILTER> \
-fix \
chrome/browser
'chrome/browser/.*'
```

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

### Questions

Expand Down
32 changes: 5 additions & 27 deletions ui/views/.clang-tidy
Original file line number Diff line number Diff line change
@@ -1,29 +1,7 @@
---
Checks: '-*,
google-build-namespaces,
google-explicit-constructor,
google-readability-casting,
google-readability-namespace-comments,
modernize-avoid-bind,
modernize-loop-convert,
modernize-make-shared,
modernize-make-unique,
modernize-redundant-void-arg,
modernize-replace-auto-ptr,
modernize-replace-random-shuffle,
modernize-shrink-to-fit,
modernize-use-bool-literals,
modernize-use-default-member-init,
modernize-use-emplace,
modernize-use-equals-default,
modernize-use-noexcept,
modernize-use-nullptr,
modernize-use-override,
modernize-use-transparent-functors,
modernize-use-using,
readability-redundant-member-init'
HeaderFilterRegex: 'ui/views/*'
CheckOptions:
- key: modernize-use-default-member-init.UseAssignment
value: 1
Checks: 'google-build-namespaces,
google-readability-namespace-comments,
modernize-replace-auto-ptr,
modernize-use-using'
HeaderFilterRegex: 'ui/views/*'
...

0 comments on commit 0dc3348

Please sign in to comment.