uday
November 6, 2021, 8:41am
1
I notice that the tensorflow repo doesn’t have a .clang-tidy file anywhere in its tree. Does anyone have a .clang-tidy file that conforms or nearly conforms to the TF coding style? I specifically need it for the mlir-hlo sub-tree (tensorflow/compiler/mlir/).
Note that the mlir-hlo subtree follows the LLVM coding style in theory (in practice it is a bit of a mix).
I don’t know about .clang-tidy, but for .clang-format TF just uses the Google style otherwise
.
Bhack
November 6, 2021, 2:51pm
4
Please check the semi-disclosure but old thread in:
tensorflow:master
← Squadrick:cpplint
When importing changes, we do run clang-tidy with the internal config on them.
… Unfortunately, the configuration is not under our control, and thus running them in OSS has been a problem, because when we ran it before, it changed without notifications and broke us.
So, the first question I have is, is ensorflow/addons mirrored internally, now or sometime in the future(@karmel @theadactyl ). If yes, you may want to use clang-tidy instead.
Otherwise, if the code does not need to get inside google, you can apply any linter you like.
/cc @mihaimaruseac @angerson
uday
November 10, 2021, 5:53am
5
Thanks - I went through the thread, but I couldn’t still find a reference .clang-tidy to reuse.
Right. I’m aware of the .clang-format for mlir-hlo
. But clang-tidy has a different role to play – for eg. in-editor warnings on variable naming style deviations via clangd. (clangd will read a .clang-tidy if there is one.)
Bhack
November 10, 2021, 11:15am
7
The specific comment was:
tensorflow:master
← Squadrick:cpplint
When importing changes, we do run clang-tidy with the internal config on them.
… Unfortunately, the configuration is not under our control, and thus running them in OSS has been a problem, because when we ran it before, it changed without notifications and broke us.
So, the first question I have is, is ensorflow/addons mirrored internally, now or sometime in the future(@karmel @theadactyl ). If yes, you may want to use clang-tidy instead.
Otherwise, if the code does not need to get inside google, you can apply any linter you like.
Also you can see @Mehdi_AMINI commit at:
committed 01:35AM - 14 Sep 21 UTC
PiperOrigin-RevId: 396489741
If your read both the links they have a clang-tidy pass in the internal repository but It was not exposed on the open source one.
I have no access to the internal repo but I suppose that for mlir-hlo they are using something like:
Checks: '-*,clang-diagnostic-*,llvm-*,misc-*,-misc-const-correctness,-misc-unused-parameters,-misc-non-private-member-variables-in-classes,-misc-no-recursion,-misc-use-anonymous-namespace,readability-identifier-naming,-misc-include-cleaner'
CheckOptions:
- key: readability-identifier-naming.ClassCase
value: CamelCase
- key: readability-identifier-naming.EnumCase
value: CamelCase
- key: readability-identifier-naming.FunctionCase
value: camelBack
# Exclude from scanning as this is an exported symbol used for fuzzing
# throughout the code base.
- key: readability-identifier-naming.FunctionIgnoredRegexp
value: "LLVMFuzzerTestOneInput"
- key: readability-identifier-naming.MemberCase
value: CamelCase
- key: readability-identifier-naming.ParameterCase
value: CamelCase
- key: readability-identifier-naming.UnionCase
value: CamelCase
- key: readability-identifier-naming.VariableCase
value: CamelCase
This file has been truncated. show original
I have on my roadmap to add clang-tidy OSS for TF, but no ETA in sight, not high priority at the moment
1 Like
Bhack
November 10, 2021, 3:39pm
11
We can track this probably in:
opened 12:37PM - 27 May 20 UTC
It could be nice if we could generate/distribute `compile_commands.json` to bett… er interact with some IDE and our c++ code.
I.e. In Bazel and also in Vscode the the official Bazel team vscode plugin we don't have in tree support to generate `compile_commands`:
https://github.com/bazelbuild/bazel/issues/258
https://github.com/bazelbuild/vscode-bazel/issues/179
I've tried some quite popular community workaround like:
https://github.com/grailbio/bazel-compilation-database
But the problem is that we are using `--action_env` for `build` when we generate our `.bazelrc` with `python configure.py` and so these arguments not supported in other command like e.g. `bazel query` https://github.com/bazelbuild/bazel/issues/10226.
This is going to invalidate the official bazel vscode plugin that need to execute `query command` but also the `bazel-compilation-database` workaround cause we have problem to retrieve our env variable.