[PATCH] D50147: clang-format: support external styles

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 27 11:09:53 PST 2018


sammccall added a comment.

In D50147#1309880 <https://reviews.llvm.org/D50147#1309880>, @Typz wrote:

> ping?


Sorry for losing track of this.

I think `-style=<filename>` is a logical extension of the current options. I'm less sure of supporting it in BasedOnStyle, but happy to go either way.

Referring to styles by names in installed style directories seems like a relatively marginal feature that would need a more careful design, e.g.:

- respecting platform conventions
- supporting build-time configuration
- understanding how distro packaging is going to work
- thinking about addressing the resulting fragmentation as .clang-format files are shared but the referenced files are not

Within a tightly controlled organization, these things are less of an issue. We've had luck simply making local changes to support different styles for these scenarios, though that's not ideal.
One possibility to reduce the scope here: search for unknown names on under `$CLANG_FORMAT_STYLES` if the variable is set. That way it can be set by administrators within an org if appropriate, but clang-format doesn't have to have opinions about the policy here, and all binaries still behave the same.



================
Comment at: lib/Basic/VirtualFileSystem.cpp:288
                             SmallVectorImpl<char> &Output) const {
-  return llvm::sys::fs::real_path(Path, Output);
+  return llvm::sys::fs::real_path(Path, Output, true);
 }
----------------
(this change isn't a good idea - if you want to expand tilde call fs::expand_tilde - it's not related to VFS)


Repository:
  rC Clang

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

https://reviews.llvm.org/D50147





More information about the cfe-commits mailing list