Add a project .clang-format config file#1053
Open
mhucka wants to merge 3 commits intotensorflow:masterfrom
Open
Add a project .clang-format config file#1053mhucka wants to merge 3 commits intotensorflow:masterfrom
.clang-format config file#1053mhucka wants to merge 3 commits intotensorflow:masterfrom
Conversation
With the addition of a `.clang-format` config file at the top level, the explicit argument on every invocation is no longer necessary.
TensorFlow sets the value the opposite way from the clang-format default, but TFQ's files have already been formatted using the default value of the DerivePointerAlignment option. To avoid having to reformat files needlessly, lets leave this to the default for TFQ.
There was a problem hiding this comment.
Code Review
This pull request introduces a .clang-format configuration file based on the Google style and updates the formatting scripts to utilize this local configuration instead of hardcoded style flags. The review feedback identifies a potential issue in the shell scripts where file patterns in the find command are unquoted, which could lead to unintended shell expansion; suggestions were provided to quote these patterns for better robustness.
MichaelBroughton
approved these changes
Apr 17, 2026
This file contains hidden or 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
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.
Scripts and workflows that run
clang-formatcurrently each add the option--style=googleto the invocation ofclang-format. To follow best practices, this PR adds a.clang-formatconfiguration file at the top level of the project to set the style, and removes the flag from where it was added on the command line explicitly.The use of a config file has the following benefits:
clang-formatdirectly on the command line for quick checks, or write new scripts that useclang-format.Removing the flag from the scripts is not strictly necessary (everything will work the same if there is both a config file and the flag is passed to
clang-format). However, if a config file is used, it's better for maintainability and consistency to also remove the flag from individual invocations.