[PATCH] D69764: [clang-format] Add East Const / West Const fixer
MyDeveloperDay via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Nov 3 07:55:11 PST 2019
MyDeveloperDay created this revision.
MyDeveloperDay added reviewers: klimek, mitchell-stellar, sammccall, owenpan, krasimir.
MyDeveloperDay added a project: clang-format.
Herald added a subscriber: mgorny.
Herald added a project: clang.
Developers these days seem to argue over east vs west const like they used to argue over tabs vs whitespace or the various bracing style. These previous arguments were mainly eliminated with tools like `clang-format` that allowed those rules to become part of your style guide. Anyone who has been using clang-format in a large team over the last couple of years knows that we don't have those religious arguments any more, and code reviews are more productive.
https://www.youtube.com/watch?v=fv--IKZFVO8
https://mariusbancila.ro/blog/2018/11/23/join-the-east-const-revolution/
https://www.youtube.com/watch?v=z6s6bacI424
The purpose of this revision is to try to do the same for the East/West const discussion. Move the debate into the style guide and leave it there!
In addition to the new `ConstStyle: West` or `ConstStyle: East` there is an additional command-line argument `--const-style=east/west` which would allow an individual developer to switch the source back and forth to their own style for editing, and back to the committed style before commit. (you could imagine an IDE might offer such a switch)
The revision works by implementing a separate pass of the Annotated lines much like the SortIncludes and then create replacements for constant type declarations.
Repository:
rC Clang
https://reviews.llvm.org/D69764
Files:
clang/docs/ClangFormatStyleOptions.rst
clang/include/clang/Format/Format.h
clang/lib/Format/CMakeLists.txt
clang/lib/Format/EastWestConstFixer.cpp
clang/lib/Format/EastWestConstFixer.h
clang/lib/Format/Format.cpp
clang/tools/clang-format/ClangFormat.cpp
clang/unittests/Format/FormatTest.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D69764.227612.patch
Type: text/x-patch
Size: 21076 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20191103/b9334658/attachment-0001.bin>
More information about the cfe-commits
mailing list