summaryrefslogtreecommitdiff
path: root/include/clang/Format
diff options
context:
space:
mode:
authorSam McCall <sam.mccall@gmail.com>2019-07-02 15:53:14 +0000
committerSam McCall <sam.mccall@gmail.com>2019-07-02 15:53:14 +0000
commit54b8029400637989d16f8467643c46296e62e1d3 (patch)
tree18d71b51ad8c9051a0b070733b6e168d4c38a831 /include/clang/Format
parentc1bb4b1c1b13d755c44d322e0a544c639d095d29 (diff)
downloadclang-54b8029400637989d16f8467643c46296e62e1d3.tar.gz
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@364938 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Format')
-rw-r--r--include/clang/Format/Format.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/include/clang/Format/Format.h b/include/clang/Format/Format.h
index c5034db71a..6388e4fc17 100644
--- a/include/clang/Format/Format.h
+++ b/include/clang/Format/Format.h
@@ -79,6 +79,19 @@ struct FormatStyle {
/// brackets.
BracketAlignmentStyle AlignAfterOpenBracket;
+ /// \brief If ``true``, aligns consecutive C/C++ preprocessor macros.
+ ///
+ /// This will align C/C++ preprocessor macros of consecutive lines.
+ /// Will result in formattings like
+ /// \code
+ /// #define SHORT_NAME 42
+ /// #define LONGER_NAME 0x007f
+ /// #define EVEN_LONGER_NAME (2)
+ /// #define foo(x) (x * x)
+ /// #define bar(y, z) (y + z)
+ /// \endcode
+ bool AlignConsecutiveMacros;
+
/// If ``true``, aligns consecutive assignments.
///
/// This will align the assignment operators of consecutive lines. This