[clang] [clang-format] Add -r option for recursing into directories (PR #160299)
James Henderson via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 7 02:58:08 PDT 2025
jh7370 wrote:
> Running the new clang-format from this patch on `clang/tools/clang-format/` results in the following:
>
> <snip>
>
> This is not very helpful and can be dangerous.
Yes, indeed, that's why I think the option would typically best be paired with .clang-format-ignore files. Fun fact: when developing this, because we didn't have a .clang-format-ignore file locally at the time, I accidentally reformatted the entire contents of my .git directory, rather trashing my ability to do anything with the repo! This is also why I'm leaning more towards the glob pattern approach that was suggested as an alternative.
> BTW, you can recursively list all files under a directory with `dir /S /B` in CMD on Windows. So I would recommend using the `@<file>` or `--files=<filename>` options for the purpose of formatting an entire directory.
Thanks, useful to know.
https://github.com/llvm/llvm-project/pull/160299
More information about the cfe-commits
mailing list