[cfe-dev] [clang-format] add option -fallback-style=fail (fail if -style=file falls back)
Paul Seyfert via cfe-dev
cfe-dev at lists.llvm.org
Thu Jan 26 07:05:32 PST 2017
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
Dear all,
I want to provide information to the clang-format user if the style
is/can be used, or if clang-format sees itself forced to fall back to
the fallback-style. I.e. in contrast to doing nothing, as with
- -fallback-style=none, I want clang-format to fail. Kind of as a reminder
to the user "hey, maybe you forgot to add your .clang-format file to
your project".
I was thinking about doing this through an option
`-fallback-style=fail`. Do you think that is the right approach?
If yes, I gave it a try and wrote the attached one-off patch, which adds
the option `-fallback-style=fail`.
I *briefly* tested it on my system by building `make clang-format`[1] and
tried what happens when no .clang-format file exists and I run
`clang-format -style=file -fallback-style=fail main.cc` on a minimal
hello world c++ file.
NB: the patch does contain an update of the unit test, but I did not
manage to run it (problems with the system I was running on …).
Thanks in advance for feedback,
Paul
For reference:
This addresses what I asked on Stackoverflow
http://stackoverflow.com/questions/41758865/determine-if-clang-format-finds-clang-format-file-in-a-shell-or-cmake-script
and is a duplication of my pull request on github
https://github.com/llvm-mirror/clang/pull/21
[1]: when following steps 1-3 from
https://clang.llvm.org/get_started.html and then running `make
clang-format` in step 7 instead of `make`.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2
iQIcBAEBCAAGBQJYihA8AAoJEPOmP9OjPXmrzR4P/1l4r6C+l/xM52t/dnJ34mDC
YvhsxiIhocj9MtroTtM+qLrFFCZC5TWJezEQKlY4WrKqUqCqlgYEK7E6KZJF7sfq
XJOEnodVNwPi3r4AbXempmurRMp3ASnFpVP+mDssh/tpzBY8SszVOKqQD21BN+RM
kPcohiOsmZWQJgslL0bJ9Fm3Gl/mZd9O+NEc565QfuPJZBcF7CJvpCnGQM/sWjTK
IVicFiEdab4zG48KAeTdUx3Yp7Juy5t8z2o9lDE/ZcRbjd+9lDCSRSCsXPXVoh1B
eEGA9xP9wueCeyDSRu+0+lJ7TRP+EQOyX5RqM/DWOjsqG/r0R38QWPXN+ERRpJ1f
62bMZbD+8Y3oHpgSQOyzTRn5JraHU7zPYvrL5KIGs5On1YxjG3E/uYR9OQymHbRO
s46aM/7J0gPZ9wdYs7XeeXvYdqghrXXBHHp1tw9DUN07kILIUw6ykHvGzF4EmDkz
y7/MqaxML3xnVHOJL9ysFYVf7k7gemdgqA74eUJrtrwC9eJtQJOuUdSoK8Kp0r9o
S3CI2SayrlnaguiIMDUbI5G+XTvpHaO/f9O3EV3hd9PpDI31AOmvAKsxZ8wjtdfI
EdTR8iYPK6qIl09EWUsGvi9VNLy1lQ189wJZ8cF+3G/dXRQVSwkao7QVoSeE5Qs2
IdltflJ2xN2Q39/3uDTa
=GIc7
-----END PGP SIGNATURE-----
-------------- next part --------------
A non-text attachment was scrubbed...
Name: clang-format-fallback-fail.patch
Type: text/x-patch
Size: 3541 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170126/4b870a5d/attachment.bin>
More information about the cfe-dev
mailing list