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.
Invert the order here (remove the "!"), so that the error case becomes and early exist.