[clang-format] add option -fallback-style=fail (fail if -style=file falls back)

Paul Seyfert via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 31 06:00:13 PST 2017


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Hi,
(resend to cfe-commits instead of cfe-dev)

please see my feature proposal for an option -fallback-style=fail below.

Thanks in advance for feedback,
Paul

- -------- Forwarded Message --------
Subject: [cfe-dev] [clang-format] add option -fallback-style=fail (fail if -style=file falls back)
Date: Thu, 26 Jan 2017 16:05:32 +0100
From: Paul Seyfert via cfe-dev <cfe-dev at lists.llvm.org>
Reply-To: Paul Seyfert <pseyfert at mathphys.fsk.uni-heidelberg.de>
To: cfe-dev at lists.llvm.org

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

iQIcBAEBCAAGBQJYkJhtAAoJEPOmP9OjPXmrVs8QAJKM1RWO2f+w2OOe4EckyPcK
093d7zwr37r21TFGVzLh76JAhhswahB93l4lugoYVDl4n9L2TF5mi/7SMapkxmeo
3VnNN+VlyuCDzIo0Mj8tFCPgTled6TDNKmXbZkxabJ3nyylJXdRAeo4sP1saf5Me
nMVhZPGeOX6VP+9JPuLIs+8qcEFyz90cZIBXUMtxG045ugVQ+DRcrNUAxRSg/c9s
0XL7oCO8D2QDuPdyun9Fe7Btdq+gy8cC32oWkS5rzniY9nfZKJIS1GPzmhJ2YW/w
/moFP4kcrRAKHWDr2CLTAOKS8W3qZzi5RLiCHhHt2Cm5ASsOlzsbf3fz4uCeqbvm
uCFXn7OglJagxpOvXf6oGQKbbLSPZ26BC6eQav3AB4rKlbFNn96B1GxUY3U3IXb4
lhvOyL3AcHS+juxPOnUoRL9cChB2sVPc7ve9Z+yWw6nHwVbG/AnEIYq9BGb9sp5d
9J04XwrjDtx8VU0zjzJTBXxPdeS3aDh+PWcHbe17l2+lKHEFA/Ch+/b0Svbvtmem
DEG1K2cvOSn71cG4fFTl9DR++nR93frij2te5NGHpqDTbQoVb45RhpBViyf5Qhvu
DT/HZHjeQ+FEjnsikgE1q9VJZhp2gUBKssrLBRRavUz5FAe2q/vzk09oiQaWUODU
Iwl0nEJ1u/KQzVfv+yb3
=O68y
-----END PGP SIGNATURE-----
-------------- next part --------------
A non-text attachment was scrubbed...
Name: clang-format-fallback-fail.patch
Type: text/x-patch
Size: 3542 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170131/1bdcb702/attachment.bin>
-------------- next part --------------
_______________________________________________
cfe-dev mailing list
cfe-dev at lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev


More information about the cfe-commits mailing list