[PATCH] D145435: Choose style (file) from within code for use in IDEs

bers via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Mar 12 12:05:53 PDT 2023


bersbersbers added a comment.

In D145435#4179662 <https://reviews.llvm.org/D145435#4179662>, @owenpan wrote:

> Are the settings above hypothetical or are they real-world use cases?

Real-world - actually, all of them.

> IMO, if people really want to have per-file configurations, they can do so outside of clang-format, e.g. using grep in a shell script.

My main use case would be IDE integration - is there a way to achieve what you propose from within Visual Studio, for example? The beauty of the current setup (I believe) is that clang-format is pre-configured, so there is nothing to do except check out the code, and formatting works out of the box.

In D145435#4183507 <https://reviews.llvm.org/D145435#4183507>, @owenpan wrote:

> It would add extra runtime (especially for large files).

That is a good point. It's probably an argument for restricting the search for that comment to the first N lines of the file, in which case the performance impact would be largely independent of file size. (I believe it would even be beneficial for this comment to be required to be placed near the top of the file, to reduce the amount of surprised users down the road.)

> We would also run the risk of regressions (though unlikely) if for whatever reason an existing codebase has files starting with `// clang-format style=`.

If that is any indication, that is not the case on GitHub at least:
https://cs.github.com/?scopeName=All+repos&scope=&q=%22%2F%2F+clang-format+style%22


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145435/new/

https://reviews.llvm.org/D145435



More information about the cfe-commits mailing list