clang-format: Add new style option AlignConsecutiveMacros
authorSam McCall <sam.mccall@gmail.com>
Tue, 2 Jul 2019 15:53:14 +0000 (15:53 +0000)
committerSam McCall <sam.mccall@gmail.com>
Tue, 2 Jul 2019 15:53:14 +0000 (15:53 +0000)
commit04ee232ff212b6c308e2ebc7b6125892681c54ae
tree9e5f2397fe39a007ff0549451ed6743c89d6c21d
parent4137aeb4bf3a535679709d37298e1bc9ac72af41
clang-format: Add new style option AlignConsecutiveMacros

This option behaves similarly to AlignConsecutiveDeclarations and
AlignConsecutiveAssignments, aligning the assignment of C/C++
preprocessor macros on consecutive lines.

I've worked in many projects (embedded, mostly) where header files full
of large, well-aligned "#define" blocks are a common pattern. We
normally avoid using clang-format on these files, since it ruins any
existing alignment in said blocks. This style option will align "simple"
PP macros (no parameters) and PP macros with parameter lists on
consecutive lines.

Related Bugzilla entry (thanks mcuddie):
https://llvm.org/bugs/show_bug.cgi?id=20637

Patch by Nick Renieris (VelocityRa)!

Differential Revision: https://reviews.llvm.org/D28462

llvm-svn: 364938
clang/docs/ClangFormatStyleOptions.rst
clang/include/clang/Format/Format.h
clang/lib/Format/Format.cpp
clang/lib/Format/WhitespaceManager.cpp
clang/lib/Format/WhitespaceManager.h
clang/unittests/Format/FormatTest.cpp