[clang] 41a09a0 - [clang-format][NFCish] Alphabetical sort Format.(h|pp)
Björn Schäpers via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 8 12:46:43 PST 2022
Author: Björn Schäpers
Date: 2022-11-08T21:46:15+01:00
New Revision: 41a09a07ce4ddd1e97ce0430d1debe1dcc853890
URL: https://github.com/llvm/llvm-project/commit/41a09a07ce4ddd1e97ce0430d1debe1dcc853890
DIFF: https://github.com/llvm/llvm-project/commit/41a09a07ce4ddd1e97ce0430d1debe1dcc853890.diff
LOG: [clang-format][NFCish] Alphabetical sort Format.(h|pp)
I've:
- Sorted the members of FormatStyle alphabetical. The enums and structs
are kept close to the member.
- Sorted the yaml io functions, based on the type they operate on.
- Sorted the initializers in getLLVMStyle(), except that penalities are
kept at the end.
- Sorted the io of FormatStyle, this changes the --dump-config behavior.
- Moved the deprecated options into the only input case, this also
changes --dump-config, it does not put the not directly used options
in the .clang-format anymore.
- Sorted the comparisons in operator==.
- Added WhiteSpaceMacros in operator==, I've not actively looked if all
other members are compared.
- This showed flawed tests (or in my opinion a flawed io operation, but
that is another discussion and change).
Differential Revision: https://reviews.llvm.org/D137409
Added:
Modified:
clang/docs/ClangFormatStyleOptions.rst
clang/include/clang/Format/Format.h
clang/lib/Format/Format.cpp
clang/unittests/Format/FormatTest.cpp
Removed:
################################################################################
diff --git a/clang/docs/ClangFormatStyleOptions.rst b/clang/docs/ClangFormatStyleOptions.rst
index 44f05cf28270b..5ac5f7d4189e4 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -3583,8 +3583,7 @@ the configuration (without a prefix: ``Auto``).
(counted relative to leading non-whitespace column).
**PenaltyReturnTypeOnItsOwnLine** (``Unsigned``) :versionbadge:`clang-format 3.7`
- Penalty for putting the return type of a function onto its own
- line.
+ Penalty for putting the return type of a function onto its own line.
**PointerAlignment** (``PointerAlignmentStyle``) :versionbadge:`clang-format 3.7`
Pointer and reference alignment style.
diff --git a/clang/include/clang/Format/Format.h b/clang/include/clang/Format/Format.h
index 3cadb6304dced..40a7aecce7627 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -490,20 +490,6 @@ struct FormatStyle {
/// \version 3.3
bool AllowAllParametersOfDeclarationOnNextLine;
- /// Allow short enums on a single line.
- /// \code
- /// true:
- /// enum { A, B } myEnum;
- ///
- /// false:
- /// enum {
- /// A,
- /// B
- /// } myEnum;
- /// \endcode
- /// \version 11
- bool AllowShortEnumsOnASingleLine;
-
/// Different styles for merging short blocks containing at most one
/// statement.
enum ShortBlockStyle : int8_t {
@@ -551,6 +537,20 @@ struct FormatStyle {
/// \version 3.6
bool AllowShortCaseLabelsOnASingleLine;
+ /// Allow short enums on a single line.
+ /// \code
+ /// true:
+ /// enum { A, B } myEnum;
+ ///
+ /// false:
+ /// enum {
+ /// A,
+ /// B
+ /// } myEnum;
+ /// \endcode
+ /// \version 11
+ bool AllowShortEnumsOnASingleLine;
+
/// Different styles for merging short functions containing at most one
/// statement.
enum ShortFunctionStyle : int8_t {
@@ -899,36 +899,6 @@ struct FormatStyle {
/// \version 3.7
bool BinPackArguments;
- /// The style of inserting trailing commas into container literals.
- enum TrailingCommaStyle : int8_t {
- /// Do not insert trailing commas.
- TCS_None,
- /// Insert trailing commas in container literals that were wrapped over
- /// multiple lines. Note that this is conceptually incompatible with
- /// bin-packing, because the trailing comma is used as an indicator
- /// that a container should be formatted one-per-line (i.e. not bin-packed).
- /// So inserting a trailing comma counteracts bin-packing.
- TCS_Wrapped,
- };
-
- /// If set to ``TCS_Wrapped`` will insert trailing commas in container
- /// literals (arrays and objects) that wrap across multiple lines.
- /// It is currently only available for JavaScript
- /// and disabled by default ``TCS_None``.
- /// ``InsertTrailingCommas`` cannot be used together with ``BinPackArguments``
- /// as inserting the comma disables bin-packing.
- /// \code
- /// TSC_Wrapped:
- /// const someArray = [
- /// aaaaaaaaaaaaaaaaaaaaaaaaaa,
- /// aaaaaaaaaaaaaaaaaaaaaaaaaa,
- /// aaaaaaaaaaaaaaaaaaaaaaaaaa,
- /// // ^ inserted
- /// ]
- /// \endcode
- /// \version 11
- TrailingCommaStyle InsertTrailingCommas;
-
/// If ``false``, a function declaration's or function definition's
/// parameters will either all be on the same line or will have one line each.
/// \code
@@ -944,186 +914,493 @@ struct FormatStyle {
/// \version 3.7
bool BinPackParameters;
- /// If ``true``, clang-format will always break after a Json array `[`
- /// otherwise it will scan until the closing `]` to determine if it should add
- /// newlines between elements (prettier compatible).
- ///
- /// NOTE: This is currently only for formatting JSON.
- /// \code
- /// true: false:
- /// [ vs. [1, 2, 3, 4]
- /// 1,
- /// 2,
- /// 3,
- /// 4
- /// ]
- /// \endcode
- /// \version 16
- bool BreakArrays;
-
- /// The style of wrapping parameters on the same line (bin-packed) or
- /// on one line each.
- enum BinPackStyle : int8_t {
- /// Automatically determine parameter bin-packing behavior.
- BPS_Auto,
- /// Always bin-pack parameters.
- BPS_Always,
- /// Never bin-pack parameters.
- BPS_Never,
- };
-
- /// The style of breaking before or after binary operators.
- enum BinaryOperatorStyle : int8_t {
- /// Break after operators.
+ /// Styles for adding spacing around ``:`` in bitfield definitions.
+ enum BitFieldColonSpacingStyle : int8_t {
+ /// Add one space on each side of the ``:``
/// \code
- /// LooooooooooongType loooooooooooooooooooooongVariable =
- /// someLooooooooooooooooongFunction();
- ///
- /// bool value = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +
- /// aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ==
- /// aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa &&
- /// aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa >
- /// ccccccccccccccccccccccccccccccccccccccccc;
+ /// unsigned bf : 2;
/// \endcode
- BOS_None,
- /// Break before operators that aren't assignments.
+ BFCS_Both,
+ /// Add no space around the ``:`` (except when needed for
+ /// ``AlignConsecutiveBitFields``).
/// \code
- /// LooooooooooongType loooooooooooooooooooooongVariable =
- /// someLooooooooooooooooongFunction();
- ///
- /// bool value = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
- /// + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
- /// == aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
- /// && aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
- /// > ccccccccccccccccccccccccccccccccccccccccc;
+ /// unsigned bf:2;
/// \endcode
- BOS_NonAssignment,
- /// Break before operators.
+ BFCS_None,
+ /// Add space before the ``:`` only
/// \code
- /// LooooooooooongType loooooooooooooooooooooongVariable
- /// = someLooooooooooooooooongFunction();
- ///
- /// bool value = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
- /// + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
- /// == aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
- /// && aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
- /// > ccccccccccccccccccccccccccccccccccccccccc;
+ /// unsigned bf :2;
/// \endcode
- BOS_All,
+ BFCS_Before,
+ /// Add space after the ``:`` only (space may be added before if
+ /// needed for ``AlignConsecutiveBitFields``).
+ /// \code
+ /// unsigned bf: 2;
+ /// \endcode
+ BFCS_After
};
+ /// The BitFieldColonSpacingStyle to use for bitfields.
+ /// \version 12
+ BitFieldColonSpacingStyle BitFieldColonSpacing;
- /// The way to wrap binary operators.
- /// \version 3.6
- BinaryOperatorStyle BreakBeforeBinaryOperators;
-
- /// Different ways to attach braces to their surrounding context.
- enum BraceBreakingStyle : int8_t {
- /// Always attach braces to surrounding context.
+ /// Different ways to wrap braces after control statements.
+ enum BraceWrappingAfterControlStatementStyle : int8_t {
+ /// Never wrap braces after a control statement.
/// \code
- /// namespace N {
- /// enum E {
- /// E1,
- /// E2,
- /// };
- ///
- /// class C {
- /// public:
- /// C();
- /// };
- ///
- /// bool baz(int i) {
- /// try {
- /// do {
- /// switch (i) {
- /// case 1: {
- /// foobar();
- /// break;
- /// }
- /// default: {
- /// break;
- /// }
- /// }
- /// } while (--i);
- /// return true;
- /// } catch (...) {
- /// handleError();
- /// return false;
- /// }
+ /// if (foo()) {
+ /// } else {
/// }
- ///
- /// void foo(bool b) {
- /// if (b) {
- /// baz(2);
- /// } else {
- /// baz(5);
- /// }
+ /// for (int i = 0; i < 10; ++i) {
/// }
- ///
- /// void bar() { foo(true); }
- /// } // namespace N
/// \endcode
- BS_Attach,
- /// Like ``Attach``, but break before braces on function, namespace and
- /// class definitions.
+ BWACS_Never,
+ /// Only wrap braces after a multi-line control statement.
/// \code
- /// namespace N
- /// {
- /// enum E {
- /// E1,
- /// E2,
- /// };
- ///
- /// class C
- /// {
- /// public:
- /// C();
- /// };
- ///
- /// bool baz(int i)
+ /// if (foo && bar &&
+ /// baz)
/// {
- /// try {
- /// do {
- /// switch (i) {
- /// case 1: {
- /// foobar();
- /// break;
- /// }
- /// default: {
- /// break;
- /// }
- /// }
- /// } while (--i);
- /// return true;
- /// } catch (...) {
- /// handleError();
- /// return false;
- /// }
+ /// quux();
/// }
- ///
- /// void foo(bool b)
- /// {
- /// if (b) {
- /// baz(2);
- /// } else {
- /// baz(5);
- /// }
+ /// while (foo || bar) {
/// }
- ///
- /// void bar() { foo(true); }
- /// } // namespace N
/// \endcode
- BS_Linux,
- /// Like ``Attach``, but break before braces on enum, function, and record
- /// definitions.
+ BWACS_MultiLine,
+ /// Always wrap braces after a control statement.
/// \code
- /// namespace N {
- /// enum E
- /// {
- /// E1,
- /// E2,
- /// };
- ///
- /// class C
+ /// if (foo())
+ /// {
+ /// } else
+ /// {}
+ /// for (int i = 0; i < 10; ++i)
+ /// {}
+ /// \endcode
+ BWACS_Always
+ };
+
+ /// Precise control over the wrapping of braces.
+ /// \code
+ /// # Should be declared this way:
+ /// BreakBeforeBraces: Custom
+ /// BraceWrapping:
+ /// AfterClass: true
+ /// \endcode
+ struct BraceWrappingFlags {
+ /// Wrap case labels.
+ /// \code
+ /// false: true:
+ /// switch (foo) { vs. switch (foo) {
+ /// case 1: { case 1:
+ /// bar(); {
+ /// break; bar();
+ /// } break;
+ /// default: { }
+ /// plop(); default:
+ /// } {
+ /// } plop();
+ /// }
+ /// }
+ /// \endcode
+ bool AfterCaseLabel;
+ /// Wrap class definitions.
+ /// \code
+ /// true:
+ /// class foo
+ /// {};
+ ///
+ /// false:
+ /// class foo {};
+ /// \endcode
+ bool AfterClass;
+
+ /// Wrap control statements (``if``/``for``/``while``/``switch``/..).
+ BraceWrappingAfterControlStatementStyle AfterControlStatement;
+ /// Wrap enum definitions.
+ /// \code
+ /// true:
+ /// enum X : int
+ /// {
+ /// B
+ /// };
+ ///
+ /// false:
+ /// enum X : int { B };
+ /// \endcode
+ bool AfterEnum;
+ /// Wrap function definitions.
+ /// \code
+ /// true:
+ /// void foo()
+ /// {
+ /// bar();
+ /// bar2();
+ /// }
+ ///
+ /// false:
+ /// void foo() {
+ /// bar();
+ /// bar2();
+ /// }
+ /// \endcode
+ bool AfterFunction;
+ /// Wrap namespace definitions.
+ /// \code
+ /// true:
+ /// namespace
+ /// {
+ /// int foo();
+ /// int bar();
+ /// }
+ ///
+ /// false:
+ /// namespace {
+ /// int foo();
+ /// int bar();
+ /// }
+ /// \endcode
+ bool AfterNamespace;
+ /// Wrap ObjC definitions (interfaces, implementations...).
+ /// \note @autoreleasepool and @synchronized blocks are wrapped
+ /// according to `AfterControlStatement` flag.
+ bool AfterObjCDeclaration;
+ /// Wrap struct definitions.
+ /// \code
+ /// true:
+ /// struct foo
+ /// {
+ /// int x;
+ /// };
+ ///
+ /// false:
+ /// struct foo {
+ /// int x;
+ /// };
+ /// \endcode
+ bool AfterStruct;
+ /// Wrap union definitions.
+ /// \code
+ /// true:
+ /// union foo
+ /// {
+ /// int x;
+ /// }
+ ///
+ /// false:
+ /// union foo {
+ /// int x;
+ /// }
+ /// \endcode
+ bool AfterUnion;
+ /// Wrap extern blocks.
+ /// \code
+ /// true:
+ /// extern "C"
+ /// {
+ /// int foo();
+ /// }
+ ///
+ /// false:
+ /// extern "C" {
+ /// int foo();
+ /// }
+ /// \endcode
+ bool AfterExternBlock; // Partially superseded by IndentExternBlock
+ /// Wrap before ``catch``.
+ /// \code
+ /// true:
+ /// try {
+ /// foo();
+ /// }
+ /// catch () {
+ /// }
+ ///
+ /// false:
+ /// try {
+ /// foo();
+ /// } catch () {
+ /// }
+ /// \endcode
+ bool BeforeCatch;
+ /// Wrap before ``else``.
+ /// \code
+ /// true:
+ /// if (foo()) {
+ /// }
+ /// else {
+ /// }
+ ///
+ /// false:
+ /// if (foo()) {
+ /// } else {
+ /// }
+ /// \endcode
+ bool BeforeElse;
+ /// Wrap lambda block.
+ /// \code
+ /// true:
+ /// connect(
+ /// []()
+ /// {
+ /// foo();
+ /// bar();
+ /// });
+ ///
+ /// false:
+ /// connect([]() {
+ /// foo();
+ /// bar();
+ /// });
+ /// \endcode
+ bool BeforeLambdaBody;
+ /// Wrap before ``while``.
+ /// \code
+ /// true:
+ /// do {
+ /// foo();
+ /// }
+ /// while (1);
+ ///
+ /// false:
+ /// do {
+ /// foo();
+ /// } while (1);
+ /// \endcode
+ bool BeforeWhile;
+ /// Indent the wrapped braces themselves.
+ bool IndentBraces;
+ /// If ``false``, empty function body can be put on a single line.
+ /// This option is used only if the opening brace of the function has
+ /// already been wrapped, i.e. the `AfterFunction` brace wrapping mode is
+ /// set, and the function could/should not be put on a single line (as per
+ /// `AllowShortFunctionsOnASingleLine` and constructor formatting options).
+ /// \code
+ /// false: true:
+ /// int f() vs. int f()
+ /// {} {
+ /// }
+ /// \endcode
+ ///
+ bool SplitEmptyFunction;
+ /// If ``false``, empty record (e.g. class, struct or union) body
+ /// can be put on a single line. This option is used only if the opening
+ /// brace of the record has already been wrapped, i.e. the `AfterClass`
+ /// (for classes) brace wrapping mode is set.
+ /// \code
+ /// false: true:
+ /// class Foo vs. class Foo
+ /// {} {
+ /// }
+ /// \endcode
+ ///
+ bool SplitEmptyRecord;
+ /// If ``false``, empty namespace body can be put on a single line.
+ /// This option is used only if the opening brace of the namespace has
+ /// already been wrapped, i.e. the `AfterNamespace` brace wrapping mode is
+ /// set.
+ /// \code
+ /// false: true:
+ /// namespace Foo vs. namespace Foo
+ /// {} {
+ /// }
+ /// \endcode
+ ///
+ bool SplitEmptyNamespace;
+ };
+
+ /// Control of individual brace wrapping cases.
+ ///
+ /// If ``BreakBeforeBraces`` is set to ``BS_Custom``, use this to specify how
+ /// each individual brace case should be handled. Otherwise, this is ignored.
+ /// \code{.yaml}
+ /// # Example of usage:
+ /// BreakBeforeBraces: Custom
+ /// BraceWrapping:
+ /// AfterEnum: true
+ /// AfterStruct: false
+ /// SplitEmptyFunction: false
+ /// \endcode
+ /// \version 3.8
+ BraceWrappingFlags BraceWrapping;
+
+ /// If ``true``, clang-format will always break after a Json array `[`
+ /// otherwise it will scan until the closing `]` to determine if it should add
+ /// newlines between elements (prettier compatible).
+ ///
+ /// NOTE: This is currently only for formatting JSON.
+ /// \code
+ /// true: false:
+ /// [ vs. [1, 2, 3, 4]
+ /// 1,
+ /// 2,
+ /// 3,
+ /// 4
+ /// ]
+ /// \endcode
+ /// \version 16
+ bool BreakArrays;
+
+ /// The style of wrapping parameters on the same line (bin-packed) or
+ /// on one line each.
+ enum BinPackStyle : int8_t {
+ /// Automatically determine parameter bin-packing behavior.
+ BPS_Auto,
+ /// Always bin-pack parameters.
+ BPS_Always,
+ /// Never bin-pack parameters.
+ BPS_Never,
+ };
+
+ /// The style of breaking before or after binary operators.
+ enum BinaryOperatorStyle : int8_t {
+ /// Break after operators.
+ /// \code
+ /// LooooooooooongType loooooooooooooooooooooongVariable =
+ /// someLooooooooooooooooongFunction();
+ ///
+ /// bool value = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +
+ /// aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ==
+ /// aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa &&
+ /// aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa >
+ /// ccccccccccccccccccccccccccccccccccccccccc;
+ /// \endcode
+ BOS_None,
+ /// Break before operators that aren't assignments.
+ /// \code
+ /// LooooooooooongType loooooooooooooooooooooongVariable =
+ /// someLooooooooooooooooongFunction();
+ ///
+ /// bool value = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ /// + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ /// == aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ /// && aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ /// > ccccccccccccccccccccccccccccccccccccccccc;
+ /// \endcode
+ BOS_NonAssignment,
+ /// Break before operators.
+ /// \code
+ /// LooooooooooongType loooooooooooooooooooooongVariable
+ /// = someLooooooooooooooooongFunction();
+ ///
+ /// bool value = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ /// + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ /// == aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ /// && aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ /// > ccccccccccccccccccccccccccccccccccccccccc;
+ /// \endcode
+ BOS_All,
+ };
+
+ /// The way to wrap binary operators.
+ /// \version 3.6
+ BinaryOperatorStyle BreakBeforeBinaryOperators;
+
+ /// Different ways to attach braces to their surrounding context.
+ enum BraceBreakingStyle : int8_t {
+ /// Always attach braces to surrounding context.
+ /// \code
+ /// namespace N {
+ /// enum E {
+ /// E1,
+ /// E2,
+ /// };
+ ///
+ /// class C {
+ /// public:
+ /// C();
+ /// };
+ ///
+ /// bool baz(int i) {
+ /// try {
+ /// do {
+ /// switch (i) {
+ /// case 1: {
+ /// foobar();
+ /// break;
+ /// }
+ /// default: {
+ /// break;
+ /// }
+ /// }
+ /// } while (--i);
+ /// return true;
+ /// } catch (...) {
+ /// handleError();
+ /// return false;
+ /// }
+ /// }
+ ///
+ /// void foo(bool b) {
+ /// if (b) {
+ /// baz(2);
+ /// } else {
+ /// baz(5);
+ /// }
+ /// }
+ ///
+ /// void bar() { foo(true); }
+ /// } // namespace N
+ /// \endcode
+ BS_Attach,
+ /// Like ``Attach``, but break before braces on function, namespace and
+ /// class definitions.
+ /// \code
+ /// namespace N
+ /// {
+ /// enum E {
+ /// E1,
+ /// E2,
+ /// };
+ ///
+ /// class C
+ /// {
+ /// public:
+ /// C();
+ /// };
+ ///
+ /// bool baz(int i)
+ /// {
+ /// try {
+ /// do {
+ /// switch (i) {
+ /// case 1: {
+ /// foobar();
+ /// break;
+ /// }
+ /// default: {
+ /// break;
+ /// }
+ /// }
+ /// } while (--i);
+ /// return true;
+ /// } catch (...) {
+ /// handleError();
+ /// return false;
+ /// }
+ /// }
+ ///
+ /// void foo(bool b)
+ /// {
+ /// if (b) {
+ /// baz(2);
+ /// } else {
+ /// baz(5);
+ /// }
+ /// }
+ ///
+ /// void bar() { foo(true); }
+ /// } // namespace N
+ /// \endcode
+ BS_Linux,
+ /// Like ``Attach``, but break before braces on enum, function, and record
+ /// definitions.
+ /// \code
+ /// namespace N {
+ /// enum E
+ /// {
+ /// E1,
+ /// E2,
+ /// };
+ ///
+ /// class C
/// {
/// public:
/// C();
@@ -1430,304 +1707,26 @@ struct FormatStyle {
/// }
/// }
///
- /// void foo(bool b)
- /// {
- /// if (b) {
- /// baz(2);
- /// } else {
- /// baz(5);
- /// }
- /// }
- ///
- /// void bar() { foo(true); }
- /// } // namespace N
- /// \endcode
- BS_WebKit,
- /// Configure each individual brace in `BraceWrapping`.
- BS_Custom
- };
-
- /// The brace breaking style to use.
- /// \version 3.7
- BraceBreakingStyle BreakBeforeBraces;
-
- /// Different ways to wrap braces after control statements.
- enum BraceWrappingAfterControlStatementStyle : int8_t {
- /// Never wrap braces after a control statement.
- /// \code
- /// if (foo()) {
- /// } else {
- /// }
- /// for (int i = 0; i < 10; ++i) {
- /// }
- /// \endcode
- BWACS_Never,
- /// Only wrap braces after a multi-line control statement.
- /// \code
- /// if (foo && bar &&
- /// baz)
- /// {
- /// quux();
- /// }
- /// while (foo || bar) {
- /// }
- /// \endcode
- BWACS_MultiLine,
- /// Always wrap braces after a control statement.
- /// \code
- /// if (foo())
- /// {
- /// } else
- /// {}
- /// for (int i = 0; i < 10; ++i)
- /// {}
- /// \endcode
- BWACS_Always
- };
-
- /// Precise control over the wrapping of braces.
- /// \code
- /// # Should be declared this way:
- /// BreakBeforeBraces: Custom
- /// BraceWrapping:
- /// AfterClass: true
- /// \endcode
- struct BraceWrappingFlags {
- /// Wrap case labels.
- /// \code
- /// false: true:
- /// switch (foo) { vs. switch (foo) {
- /// case 1: { case 1:
- /// bar(); {
- /// break; bar();
- /// } break;
- /// default: { }
- /// plop(); default:
- /// } {
- /// } plop();
- /// }
- /// }
- /// \endcode
- bool AfterCaseLabel;
- /// Wrap class definitions.
- /// \code
- /// true:
- /// class foo
- /// {};
- ///
- /// false:
- /// class foo {};
- /// \endcode
- bool AfterClass;
-
- /// Wrap control statements (``if``/``for``/``while``/``switch``/..).
- BraceWrappingAfterControlStatementStyle AfterControlStatement;
- /// Wrap enum definitions.
- /// \code
- /// true:
- /// enum X : int
- /// {
- /// B
- /// };
- ///
- /// false:
- /// enum X : int { B };
- /// \endcode
- bool AfterEnum;
- /// Wrap function definitions.
- /// \code
- /// true:
- /// void foo()
- /// {
- /// bar();
- /// bar2();
- /// }
- ///
- /// false:
- /// void foo() {
- /// bar();
- /// bar2();
- /// }
- /// \endcode
- bool AfterFunction;
- /// Wrap namespace definitions.
- /// \code
- /// true:
- /// namespace
- /// {
- /// int foo();
- /// int bar();
- /// }
- ///
- /// false:
- /// namespace {
- /// int foo();
- /// int bar();
- /// }
- /// \endcode
- bool AfterNamespace;
- /// Wrap ObjC definitions (interfaces, implementations...).
- /// \note @autoreleasepool and @synchronized blocks are wrapped
- /// according to `AfterControlStatement` flag.
- bool AfterObjCDeclaration;
- /// Wrap struct definitions.
- /// \code
- /// true:
- /// struct foo
- /// {
- /// int x;
- /// };
- ///
- /// false:
- /// struct foo {
- /// int x;
- /// };
- /// \endcode
- bool AfterStruct;
- /// Wrap union definitions.
- /// \code
- /// true:
- /// union foo
- /// {
- /// int x;
- /// }
- ///
- /// false:
- /// union foo {
- /// int x;
- /// }
- /// \endcode
- bool AfterUnion;
- /// Wrap extern blocks.
- /// \code
- /// true:
- /// extern "C"
- /// {
- /// int foo();
- /// }
- ///
- /// false:
- /// extern "C" {
- /// int foo();
- /// }
- /// \endcode
- bool AfterExternBlock; // Partially superseded by IndentExternBlock
- /// Wrap before ``catch``.
- /// \code
- /// true:
- /// try {
- /// foo();
- /// }
- /// catch () {
- /// }
- ///
- /// false:
- /// try {
- /// foo();
- /// } catch () {
- /// }
- /// \endcode
- bool BeforeCatch;
- /// Wrap before ``else``.
- /// \code
- /// true:
- /// if (foo()) {
- /// }
- /// else {
- /// }
- ///
- /// false:
- /// if (foo()) {
- /// } else {
- /// }
- /// \endcode
- bool BeforeElse;
- /// Wrap lambda block.
- /// \code
- /// true:
- /// connect(
- /// []()
- /// {
- /// foo();
- /// bar();
- /// });
- ///
- /// false:
- /// connect([]() {
- /// foo();
- /// bar();
- /// });
- /// \endcode
- bool BeforeLambdaBody;
- /// Wrap before ``while``.
- /// \code
- /// true:
- /// do {
- /// foo();
- /// }
- /// while (1);
- ///
- /// false:
- /// do {
- /// foo();
- /// } while (1);
- /// \endcode
- bool BeforeWhile;
- /// Indent the wrapped braces themselves.
- bool IndentBraces;
- /// If ``false``, empty function body can be put on a single line.
- /// This option is used only if the opening brace of the function has
- /// already been wrapped, i.e. the `AfterFunction` brace wrapping mode is
- /// set, and the function could/should not be put on a single line (as per
- /// `AllowShortFunctionsOnASingleLine` and constructor formatting options).
- /// \code
- /// false: true:
- /// int f() vs. int f()
- /// {} {
- /// }
- /// \endcode
- ///
- bool SplitEmptyFunction;
- /// If ``false``, empty record (e.g. class, struct or union) body
- /// can be put on a single line. This option is used only if the opening
- /// brace of the record has already been wrapped, i.e. the `AfterClass`
- /// (for classes) brace wrapping mode is set.
- /// \code
- /// false: true:
- /// class Foo vs. class Foo
- /// {} {
- /// }
- /// \endcode
+ /// void foo(bool b)
+ /// {
+ /// if (b) {
+ /// baz(2);
+ /// } else {
+ /// baz(5);
+ /// }
+ /// }
///
- bool SplitEmptyRecord;
- /// If ``false``, empty namespace body can be put on a single line.
- /// This option is used only if the opening brace of the namespace has
- /// already been wrapped, i.e. the `AfterNamespace` brace wrapping mode is
- /// set.
- /// \code
- /// false: true:
- /// namespace Foo vs. namespace Foo
- /// {} {
- /// }
+ /// void bar() { foo(true); }
+ /// } // namespace N
/// \endcode
- ///
- bool SplitEmptyNamespace;
+ BS_WebKit,
+ /// Configure each individual brace in `BraceWrapping`.
+ BS_Custom
};
- /// Control of individual brace wrapping cases.
- ///
- /// If ``BreakBeforeBraces`` is set to ``BS_Custom``, use this to specify how
- /// each individual brace case should be handled. Otherwise, this is ignored.
- /// \code{.yaml}
- /// # Example of usage:
- /// BreakBeforeBraces: Custom
- /// BraceWrapping:
- /// AfterEnum: true
- /// AfterStruct: false
- /// SplitEmptyFunction: false
- /// \endcode
- /// \version 3.8
- BraceWrappingFlags BraceWrapping;
+ /// The brace breaking style to use.
+ /// \version 3.7
+ BraceBreakingStyle BreakBeforeBraces;
/// Different ways to break before concept declarations.
enum BreakBeforeConceptDeclarationsStyle : int8_t {
@@ -1840,74 +1839,6 @@ struct FormatStyle {
/// \version 3.7
std::string CommentPragmas;
- /// Different specifiers and qualifiers alignment styles.
- enum QualifierAlignmentStyle : int8_t {
- /// Don't change specifiers/qualifiers to either Left or Right alignment
- /// (default).
- /// \code
- /// int const a;
- /// const int *a;
- /// \endcode
- QAS_Leave,
- /// Change specifiers/qualifiers to be left-aligned.
- /// \code
- /// const int a;
- /// const int *a;
- /// \endcode
- QAS_Left,
- /// Change specifiers/qualifiers to be right-aligned.
- /// \code
- /// int const a;
- /// int const *a;
- /// \endcode
- QAS_Right,
- /// Change specifiers/qualifiers to be aligned based on ``QualifierOrder``.
- /// With:
- /// \code{.yaml}
- /// QualifierOrder: ['inline', 'static', 'type', 'const']
- /// \endcode
- ///
- /// \code
- ///
- /// int const a;
- /// int const *a;
- /// \endcode
- QAS_Custom
- };
-
- /// Different ways to arrange specifiers and qualifiers (e.g. const/volatile).
- /// \warning
- /// Setting ``QualifierAlignment`` to something other than `Leave`, COULD
- /// lead to incorrect code formatting due to incorrect decisions made due to
- /// clang-formats lack of complete semantic information.
- /// As such extra care should be taken to review code changes made by the use
- /// of this option.
- /// \endwarning
- /// \version 14
- QualifierAlignmentStyle QualifierAlignment;
-
- /// The order in which the qualifiers appear.
- /// Order is an array that can contain any of the following:
- ///
- /// * const
- /// * inline
- /// * static
- /// * constexpr
- /// * volatile
- /// * restrict
- /// * type
- ///
- /// Note: it MUST contain 'type'.
- /// Items to the left of 'type' will be placed to the left of the type and
- /// aligned in the order supplied. Items to the right of 'type' will be placed
- /// to the right of the type and aligned in the order supplied.
- ///
- /// \code{.yaml}
- /// QualifierOrder: ['inline', 'static', 'type', 'const', 'volatile' ]
- /// \endcode
- /// \version 14
- std::vector<std::string> QualifierOrder;
-
/// Different ways to break inheritance list.
enum BreakInheritanceListStyle : int8_t {
/// Break inheritance list before the colon and after the commas.
@@ -2160,53 +2091,6 @@ struct FormatStyle {
/// \version 3.7
bool ExperimentalAutoDetectBinPacking;
- /// Different ways to try to fit all constructor initializers on a line.
- enum PackConstructorInitializersStyle : int8_t {
- /// Always put each constructor initializer on its own line.
- /// \code
- /// Constructor()
- /// : a(),
- /// b()
- /// \endcode
- PCIS_Never,
- /// Bin-pack constructor initializers.
- /// \code
- /// Constructor()
- /// : aaaaaaaaaaaaaaaaaaaa(), bbbbbbbbbbbbbbbbbbbb(),
- /// cccccccccccccccccccc()
- /// \endcode
- PCIS_BinPack,
- /// Put all constructor initializers on the current line if they fit.
- /// Otherwise, put each one on its own line.
- /// \code
- /// Constructor() : a(), b()
- ///
- /// Constructor()
- /// : aaaaaaaaaaaaaaaaaaaa(),
- /// bbbbbbbbbbbbbbbbbbbb(),
- /// ddddddddddddd()
- /// \endcode
- PCIS_CurrentLine,
- /// Same as ``PCIS_CurrentLine`` except that if all constructor initializers
- /// do not fit on the current line, try to fit them on the next line.
- /// \code
- /// Constructor() : a(), b()
- ///
- /// Constructor()
- /// : aaaaaaaaaaaaaaaaaaaa(), bbbbbbbbbbbbbbbbbbbb(), ddddddddddddd()
- ///
- /// Constructor()
- /// : aaaaaaaaaaaaaaaaaaaa(),
- /// bbbbbbbbbbbbbbbbbbbb(),
- /// cccccccccccccccccccc()
- /// \endcode
- PCIS_NextLine,
- };
-
- /// The pack constructor initializers style to use.
- /// \version 14;
- PackConstructorInitializersStyle PackConstructorInitializers;
-
/// If ``true``, clang-format adds missing namespace end comments for
/// short namespaces and fixes invalid existing ones. Short ones are
/// controlled by "ShortNamespaceLines".
@@ -2229,95 +2113,37 @@ struct FormatStyle {
/// <loop-body>
/// \endcode
///
- /// In the .clang-format configuration file, this can be configured like:
- /// \code{.yaml}
- /// ForEachMacros: ['RANGES_FOR', 'FOREACH']
- /// \endcode
- ///
- /// For example: BOOST_FOREACH.
- /// \version 3.7
- std::vector<std::string> ForEachMacros;
-
- /// A vector of macros that should be interpreted as conditionals
- /// instead of as function calls.
- ///
- /// These are expected to be macros of the form:
- /// \code
- /// IF(...)
- /// <conditional-body>
- /// else IF(...)
- /// <conditional-body>
- /// \endcode
- ///
- /// In the .clang-format configuration file, this can be configured like:
- /// \code{.yaml}
- /// IfMacros: ['IF']
- /// \endcode
- ///
- /// For example: `KJ_IF_MAYBE
- /// <https://github.com/capnproto/capnproto/blob/master/kjdoc/tour.md#maybes>`_
- /// \version 13
- std::vector<std::string> IfMacros;
-
- /// \brief A vector of macros that should be interpreted as type declarations
- /// instead of as function calls.
- ///
- /// These are expected to be macros of the form:
- /// \code
- /// STACK_OF(...)
- /// \endcode
- ///
- /// In the .clang-format configuration file, this can be configured like:
- /// \code{.yaml}
- /// TypenameMacros: ['STACK_OF', 'LIST']
- /// \endcode
- ///
- /// For example: OpenSSL STACK_OF, BSD LIST_ENTRY.
- /// \version 9
- std::vector<std::string> TypenameMacros;
-
- /// A vector of macros that should be interpreted as complete
- /// statements.
- ///
- /// Typical macros are expressions, and require a semi-colon to be
- /// added; sometimes this is not the case, and this allows to make
- /// clang-format aware of such cases.
- ///
- /// For example: Q_UNUSED
- /// \version 8
- std::vector<std::string> StatementMacros;
-
- /// A vector of macros which are used to open namespace blocks.
- ///
- /// These are expected to be macros of the form:
- /// \code
- /// NAMESPACE(<namespace-name>, ...) {
- /// <namespace-content>
- /// }
- /// \endcode
- ///
- /// For example: TESTSUITE
- /// \version 9
- std::vector<std::string> NamespaceMacros;
+ /// In the .clang-format configuration file, this can be configured like:
+ /// \code{.yaml}
+ /// ForEachMacros: ['RANGES_FOR', 'FOREACH']
+ /// \endcode
+ ///
+ /// For example: BOOST_FOREACH.
+ /// \version 3.7
+ std::vector<std::string> ForEachMacros;
- /// A vector of macros which are whitespace-sensitive and should not
- /// be touched.
+ tooling::IncludeStyle IncludeStyle;
+
+ /// A vector of macros that should be interpreted as conditionals
+ /// instead of as function calls.
///
/// These are expected to be macros of the form:
/// \code
- /// STRINGIZE(...)
+ /// IF(...)
+ /// <conditional-body>
+ /// else IF(...)
+ /// <conditional-body>
/// \endcode
///
/// In the .clang-format configuration file, this can be configured like:
/// \code{.yaml}
- /// WhitespaceSensitiveMacros: ['STRINGIZE', 'PP_STRINGIZE']
+ /// IfMacros: ['IF']
/// \endcode
///
- /// For example: BOOST_PP_STRINGIZE
- /// \version 11
- std::vector<std::string> WhitespaceSensitiveMacros;
-
- tooling::IncludeStyle IncludeStyle;
+ /// For example: `KJ_IF_MAYBE
+ /// <https://github.com/capnproto/capnproto/blob/master/kjdoc/tour.md#maybes>`_
+ /// \version 13
+ std::vector<std::string> IfMacros;
/// Specify whether access modifiers should have their own indentation level.
///
@@ -2346,25 +2172,6 @@ struct FormatStyle {
/// \version 13
bool IndentAccessModifiers;
- /// Indent case labels one level from the switch statement.
- ///
- /// When ``false``, use the same indentation level as for the switch
- /// statement. Switch statement body is always indented one level more than
- /// case labels (except the first block following the case label, which
- /// itself indents the code - unless IndentCaseBlocks is enabled).
- /// \code
- /// false: true:
- /// switch (fool) { vs. switch (fool) {
- /// case 1: case 1:
- /// bar(); bar();
- /// break; break;
- /// default: default:
- /// plop(); plop();
- /// } }
- /// \endcode
- /// \version 3.3
- bool IndentCaseLabels;
-
/// Indent case label blocks one level from the case label.
///
/// When ``false``, the block following the case label uses the same
@@ -2388,6 +2195,25 @@ struct FormatStyle {
/// \version 11
bool IndentCaseBlocks;
+ /// Indent case labels one level from the switch statement.
+ ///
+ /// When ``false``, use the same indentation level as for the switch
+ /// statement. Switch statement body is always indented one level more than
+ /// case labels (except the first block following the case label, which
+ /// itself indents the code - unless IndentCaseBlocks is enabled).
+ /// \code
+ /// false: true:
+ /// switch (fool) { vs. switch (fool) {
+ /// case 1: case 1:
+ /// bar(); bar();
+ /// break; break;
+ /// default: default:
+ /// plop(); plop();
+ /// } }
+ /// \endcode
+ /// \version 3.3
+ bool IndentCaseLabels;
+
/// Indent goto labels.
///
/// When ``false``, goto labels are flushed left.
@@ -2405,41 +2231,6 @@ struct FormatStyle {
/// \version 10
bool IndentGotoLabels;
- /// Options for indenting preprocessor directives.
- enum PPDirectiveIndentStyle : int8_t {
- /// Does not indent any directives.
- /// \code
- /// #if FOO
- /// #if BAR
- /// #include <foo>
- /// #endif
- /// #endif
- /// \endcode
- PPDIS_None,
- /// Indents directives after the hash.
- /// \code
- /// #if FOO
- /// # if BAR
- /// # include <foo>
- /// # endif
- /// #endif
- /// \endcode
- PPDIS_AfterHash,
- /// Indents directives before the hash.
- /// \code
- /// #if FOO
- /// #if BAR
- /// #include <foo>
- /// #endif
- /// #endif
- /// \endcode
- PPDIS_BeforeHash
- };
-
- /// The preprocessor directive indenting style to use.
- /// \version 6
- PPDirectiveIndentStyle IndentPPDirectives;
-
/// Indents extern blocks
enum IndentExternBlockStyle : int8_t {
/// Backwards compatible with AfterExternBlock's indenting.
@@ -2480,6 +2271,41 @@ struct FormatStyle {
/// \version 11
IndentExternBlockStyle IndentExternBlock;
+ /// Options for indenting preprocessor directives.
+ enum PPDirectiveIndentStyle : int8_t {
+ /// Does not indent any directives.
+ /// \code
+ /// #if FOO
+ /// #if BAR
+ /// #include <foo>
+ /// #endif
+ /// #endif
+ /// \endcode
+ PPDIS_None,
+ /// Indents directives after the hash.
+ /// \code
+ /// #if FOO
+ /// # if BAR
+ /// # include <foo>
+ /// # endif
+ /// #endif
+ /// \endcode
+ PPDIS_AfterHash,
+ /// Indents directives before the hash.
+ /// \code
+ /// #if FOO
+ /// #if BAR
+ /// #include <foo>
+ /// #endif
+ /// #endif
+ /// \endcode
+ PPDIS_BeforeHash
+ };
+
+ /// The preprocessor directive indenting style to use.
+ /// \version 6
+ PPDirectiveIndentStyle IndentPPDirectives;
+
/// Indent the requires clause in a template. This only applies when
/// ``RequiresClausePosition`` is ``OwnLine``, or ``WithFollowing``.
///
@@ -2562,6 +2388,36 @@ struct FormatStyle {
/// \version 15
bool InsertBraces;
+ /// The style of inserting trailing commas into container literals.
+ enum TrailingCommaStyle : int8_t {
+ /// Do not insert trailing commas.
+ TCS_None,
+ /// Insert trailing commas in container literals that were wrapped over
+ /// multiple lines. Note that this is conceptually incompatible with
+ /// bin-packing, because the trailing comma is used as an indicator
+ /// that a container should be formatted one-per-line (i.e. not bin-packed).
+ /// So inserting a trailing comma counteracts bin-packing.
+ TCS_Wrapped,
+ };
+
+ /// If set to ``TCS_Wrapped`` will insert trailing commas in container
+ /// literals (arrays and objects) that wrap across multiple lines.
+ /// It is currently only available for JavaScript
+ /// and disabled by default ``TCS_None``.
+ /// ``InsertTrailingCommas`` cannot be used together with ``BinPackArguments``
+ /// as inserting the comma disables bin-packing.
+ /// \code
+ /// TSC_Wrapped:
+ /// const someArray = [
+ /// aaaaaaaaaaaaaaaaaaaaaaaaaa,
+ /// aaaaaaaaaaaaaaaaaaaaaaaaaa,
+ /// aaaaaaaaaaaaaaaaaaaaaaaaaa,
+ /// // ^ inserted
+ /// ]
+ /// \endcode
+ /// \version 11
+ TrailingCommaStyle InsertTrailingCommas;
+
/// A vector of prefixes ordered by the desired groups for Java imports.
///
/// One group's prefix can be a subset of another - the longest prefix is
@@ -2651,6 +2507,39 @@ struct FormatStyle {
/// \version 3.7
bool KeepEmptyLinesAtTheStartOfBlocks;
+ /// Indentation logic for lambda bodies.
+ enum LambdaBodyIndentationKind : int8_t {
+ /// Align lambda body relative to the lambda signature. This is the default.
+ /// \code
+ /// someMethod(
+ /// [](SomeReallyLongLambdaSignatureArgument foo) {
+ /// return;
+ /// });
+ /// \endcode
+ LBI_Signature,
+ /// Align lambda body relative to the indentation level of the outer scope
+ /// the lambda signature resides in.
+ /// \code
+ /// someMethod(
+ /// [](SomeReallyLongLambdaSignatureArgument foo) {
+ /// return;
+ /// });
+ /// \endcode
+ LBI_OuterScope,
+ };
+
+ /// The indentation style of lambda bodies. ``Signature`` (the default)
+ /// causes the lambda body to be indented one additional level relative to
+ /// the indentation level of the signature. ``OuterScope`` forces the lambda
+ /// body to be indented one additional level relative to the parent scope
+ /// containing the lambda signature. For callback-heavy code, it may improve
+ /// readability to have the signature indented two levels and to use
+ /// ``OuterScope``. The KJ style guide requires ``OuterScope``.
+ /// `KJ style guide
+ /// <https://github.com/capnproto/capnproto/blob/master/style-guide.md>`_
+ /// \version 13
+ LambdaBodyIndentationKind LambdaBodyIndentation;
+
/// Supported languages.
///
/// When stored in a configuration file, specifies the language, that the
@@ -2695,47 +2584,14 @@ struct FormatStyle {
/// \version 3.5
LanguageKind Language;
- /// Indentation logic for lambda bodies.
- enum LambdaBodyIndentationKind : int8_t {
- /// Align lambda body relative to the lambda signature. This is the default.
- /// \code
- /// someMethod(
- /// [](SomeReallyLongLambdaSignatureArgument foo) {
- /// return;
- /// });
- /// \endcode
- LBI_Signature,
- /// Align lambda body relative to the indentation level of the outer scope
- /// the lambda signature resides in.
- /// \code
- /// someMethod(
- /// [](SomeReallyLongLambdaSignatureArgument foo) {
- /// return;
- /// });
- /// \endcode
- LBI_OuterScope,
- };
-
- /// The indentation style of lambda bodies. ``Signature`` (the default)
- /// causes the lambda body to be indented one additional level relative to
- /// the indentation level of the signature. ``OuterScope`` forces the lambda
- /// body to be indented one additional level relative to the parent scope
- /// containing the lambda signature. For callback-heavy code, it may improve
- /// readability to have the signature indented two levels and to use
- /// ``OuterScope``. The KJ style guide requires ``OuterScope``.
- /// `KJ style guide
- /// <https://github.com/capnproto/capnproto/blob/master/style-guide.md>`_
- /// \version 13
- LambdaBodyIndentationKind LambdaBodyIndentation;
-
/// A regular expression matching macros that start a block.
/// \code
/// # With:
/// MacroBlockBegin: "^NS_MAP_BEGIN|\
- /// NS_TABLE_HEAD$"
+ /// NS_TABLE_HEAD$"
/// MacroBlockEnd: "^\
- /// NS_MAP_END|\
- /// NS_TABLE_.*_END$"
+ /// NS_MAP_END|\
+ /// NS_TABLE_.*_END$"
///
/// NS_MAP_BEGIN
/// foo();
@@ -2813,6 +2669,19 @@ struct FormatStyle {
/// \version 3.7
NamespaceIndentationKind NamespaceIndentation;
+ /// A vector of macros which are used to open namespace blocks.
+ ///
+ /// These are expected to be macros of the form:
+ /// \code
+ /// NAMESPACE(<namespace-name>, ...) {
+ /// <namespace-content>
+ /// }
+ /// \endcode
+ ///
+ /// For example: TESTSUITE
+ /// \version 9
+ std::vector<std::string> NamespaceMacros;
+
/// Controls bin-packing Objective-C protocol conformance list
/// items into as few lines as possible when they go over ``ColumnLimit``.
///
@@ -2853,14 +2722,9 @@ struct FormatStyle {
/// [operation setCompletionBlock:^{
/// [self onOperationDone];
/// }];
- /// \endcode
- /// \version 3.7
- unsigned ObjCBlockIndentWidth;
-
- /// Add a space after ``@property`` in Objective-C, i.e. use
- /// ``@property (readonly)`` instead of ``@property(readonly)``.
+ /// \endcode
/// \version 3.7
- bool ObjCSpaceAfterProperty;
+ unsigned ObjCBlockIndentWidth;
/// Break parameters list into lines when there is nested block
/// parameters in a function call.
@@ -2886,11 +2750,63 @@ struct FormatStyle {
/// \version 11
bool ObjCBreakBeforeNestedBlockParam;
+ /// Add a space after ``@property`` in Objective-C, i.e. use
+ /// ``@property (readonly)`` instead of ``@property(readonly)``.
+ /// \version 3.7
+ bool ObjCSpaceAfterProperty;
+
/// Add a space in front of an Objective-C protocol list, i.e. use
/// ``Foo <Protocol>`` instead of ``Foo<Protocol>``.
/// \version 3.7
bool ObjCSpaceBeforeProtocolList;
+ /// Different ways to try to fit all constructor initializers on a line.
+ enum PackConstructorInitializersStyle : int8_t {
+ /// Always put each constructor initializer on its own line.
+ /// \code
+ /// Constructor()
+ /// : a(),
+ /// b()
+ /// \endcode
+ PCIS_Never,
+ /// Bin-pack constructor initializers.
+ /// \code
+ /// Constructor()
+ /// : aaaaaaaaaaaaaaaaaaaa(), bbbbbbbbbbbbbbbbbbbb(),
+ /// cccccccccccccccccccc()
+ /// \endcode
+ PCIS_BinPack,
+ /// Put all constructor initializers on the current line if they fit.
+ /// Otherwise, put each one on its own line.
+ /// \code
+ /// Constructor() : a(), b()
+ ///
+ /// Constructor()
+ /// : aaaaaaaaaaaaaaaaaaaa(),
+ /// bbbbbbbbbbbbbbbbbbbb(),
+ /// ddddddddddddd()
+ /// \endcode
+ PCIS_CurrentLine,
+ /// Same as ``PCIS_CurrentLine`` except that if all constructor initializers
+ /// do not fit on the current line, try to fit them on the next line.
+ /// \code
+ /// Constructor() : a(), b()
+ ///
+ /// Constructor()
+ /// : aaaaaaaaaaaaaaaaaaaa(), bbbbbbbbbbbbbbbbbbbb(), ddddddddddddd()
+ ///
+ /// Constructor()
+ /// : aaaaaaaaaaaaaaaaaaaa(),
+ /// bbbbbbbbbbbbbbbbbbbb(),
+ /// cccccccccccccccccccc()
+ /// \endcode
+ PCIS_NextLine,
+ };
+
+ /// The pack constructor initializers style to use.
+ /// \version 14;
+ PackConstructorInitializersStyle PackConstructorInitializers;
+
/// The penalty for breaking around an assignment operator.
/// \version 5
unsigned PenaltyBreakAssignment;
@@ -2923,16 +2839,15 @@ struct FormatStyle {
/// \version 3.7
unsigned PenaltyExcessCharacter;
- /// Penalty for putting the return type of a function onto its own
- /// line.
- /// \version 3.7
- unsigned PenaltyReturnTypeOnItsOwnLine;
-
/// Penalty for each character of whitespace indentation
/// (counted relative to leading non-whitespace column).
/// \version 12
unsigned PenaltyIndentedWhitespace;
+ /// Penalty for putting the return type of a function onto its own line.
+ /// \version 3.7
+ unsigned PenaltyReturnTypeOnItsOwnLine;
+
/// The ``&``, ``&&`` and ``*`` alignment style.
enum PointerAlignmentStyle : int8_t {
/// Align pointer to the left.
@@ -2971,6 +2886,74 @@ struct FormatStyle {
/// \version 13
int PPIndentWidth;
+ /// Different specifiers and qualifiers alignment styles.
+ enum QualifierAlignmentStyle : int8_t {
+ /// Don't change specifiers/qualifiers to either Left or Right alignment
+ /// (default).
+ /// \code
+ /// int const a;
+ /// const int *a;
+ /// \endcode
+ QAS_Leave,
+ /// Change specifiers/qualifiers to be left-aligned.
+ /// \code
+ /// const int a;
+ /// const int *a;
+ /// \endcode
+ QAS_Left,
+ /// Change specifiers/qualifiers to be right-aligned.
+ /// \code
+ /// int const a;
+ /// int const *a;
+ /// \endcode
+ QAS_Right,
+ /// Change specifiers/qualifiers to be aligned based on ``QualifierOrder``.
+ /// With:
+ /// \code{.yaml}
+ /// QualifierOrder: ['inline', 'static', 'type', 'const']
+ /// \endcode
+ ///
+ /// \code
+ ///
+ /// int const a;
+ /// int const *a;
+ /// \endcode
+ QAS_Custom
+ };
+
+ /// Different ways to arrange specifiers and qualifiers (e.g. const/volatile).
+ /// \warning
+ /// Setting ``QualifierAlignment`` to something other than `Leave`, COULD
+ /// lead to incorrect code formatting due to incorrect decisions made due to
+ /// clang-formats lack of complete semantic information.
+ /// As such extra care should be taken to review code changes made by the use
+ /// of this option.
+ /// \endwarning
+ /// \version 14
+ QualifierAlignmentStyle QualifierAlignment;
+
+ /// The order in which the qualifiers appear.
+ /// Order is an array that can contain any of the following:
+ ///
+ /// * const
+ /// * inline
+ /// * static
+ /// * constexpr
+ /// * volatile
+ /// * restrict
+ /// * type
+ ///
+ /// Note: it MUST contain 'type'.
+ /// Items to the left of 'type' will be placed to the left of the type and
+ /// aligned in the order supplied. Items to the right of 'type' will be placed
+ /// to the right of the type and aligned in the order supplied.
+ ///
+ /// \code{.yaml}
+ /// QualifierOrder: ['inline', 'static', 'type', 'const', 'volatile' ]
+ /// \endcode
+ /// \version 14
+ std::vector<std::string> QualifierOrder;
+
/// See documentation of ``RawStringFormats``.
struct RawStringFormat {
/// The language of this raw string.
@@ -3700,6 +3683,16 @@ struct FormatStyle {
/// \version 14
SpaceBeforeParensCustom SpaceBeforeParensOptions;
+ /// If ``true``, spaces will be before ``[``.
+ /// Lambdas will not be affected. Only the first ``[`` will get a space added.
+ /// \code
+ /// true: false:
+ /// int a [5]; vs. int a[5];
+ /// int a [5][5]; vs. int a[5][5];
+ /// \endcode
+ /// \version 10
+ bool SpaceBeforeSquareBrackets;
+
/// If ``false``, spaces will be removed before range-based for loop
/// colon.
/// \code
@@ -3858,45 +3851,6 @@ struct FormatStyle {
/// \version 3.7
bool SpacesInSquareBrackets;
- /// If ``true``, spaces will be before ``[``.
- /// Lambdas will not be affected. Only the first ``[`` will get a space added.
- /// \code
- /// true: false:
- /// int a [5]; vs. int a[5];
- /// int a [5][5]; vs. int a[5][5];
- /// \endcode
- /// \version 10
- bool SpaceBeforeSquareBrackets;
-
- /// Styles for adding spacing around ``:`` in bitfield definitions.
- enum BitFieldColonSpacingStyle : int8_t {
- /// Add one space on each side of the ``:``
- /// \code
- /// unsigned bf : 2;
- /// \endcode
- BFCS_Both,
- /// Add no space around the ``:`` (except when needed for
- /// ``AlignConsecutiveBitFields``).
- /// \code
- /// unsigned bf:2;
- /// \endcode
- BFCS_None,
- /// Add space before the ``:`` only
- /// \code
- /// unsigned bf :2;
- /// \endcode
- BFCS_Before,
- /// Add space after the ``:`` only (space may be added before if
- /// needed for ``AlignConsecutiveBitFields``).
- /// \code
- /// unsigned bf: 2;
- /// \endcode
- BFCS_After
- };
- /// The BitFieldColonSpacingStyle to use for bitfields.
- /// \version 12
- BitFieldColonSpacingStyle BitFieldColonSpacing;
-
/// Supported language standards for parsing and formatting C++ constructs.
/// \code
/// Latest: vector<set<int>>
@@ -3949,10 +3903,43 @@ struct FormatStyle {
/// \version 12
std::vector<std::string> StatementAttributeLikeMacros;
+ /// A vector of macros that should be interpreted as complete
+ /// statements.
+ ///
+ /// Typical macros are expressions, and require a semi-colon to be
+ /// added; sometimes this is not the case, and this allows to make
+ /// clang-format aware of such cases.
+ ///
+ /// For example: Q_UNUSED
+ /// \version 8
+ std::vector<std::string> StatementMacros;
+
/// The number of columns used for tab stops.
/// \version 3.7
unsigned TabWidth;
+ /// \brief A vector of macros that should be interpreted as type declarations
+ /// instead of as function calls.
+ ///
+ /// These are expected to be macros of the form:
+ /// \code
+ /// STACK_OF(...)
+ /// \endcode
+ ///
+ /// In the .clang-format configuration file, this can be configured like:
+ /// \code{.yaml}
+ /// TypenameMacros: ['STACK_OF', 'LIST']
+ /// \endcode
+ ///
+ /// For example: OpenSSL STACK_OF, BSD LIST_ENTRY.
+ /// \version 9
+ std::vector<std::string> TypenameMacros;
+
+ /// \brief Use ``\r\n`` instead of ``\n`` for line breaks.
+ /// Also used as fallback if ``DeriveLineEnding`` is true.
+ /// \version 10
+ bool UseCRLF;
+
/// Different ways to use tab in formatting.
enum UseTabStyle : int8_t {
/// Never use tab.
@@ -3970,15 +3957,27 @@ struct FormatStyle {
UT_Always
};
- /// \brief Use ``\r\n`` instead of ``\n`` for line breaks.
- /// Also used as fallback if ``DeriveLineEnding`` is true.
- /// \version 10
- bool UseCRLF;
-
/// The way to use tab characters in the resulting file.
/// \version 3.7
UseTabStyle UseTab;
+ /// A vector of macros which are whitespace-sensitive and should not
+ /// be touched.
+ ///
+ /// These are expected to be macros of the form:
+ /// \code
+ /// STRINGIZE(...)
+ /// \endcode
+ ///
+ /// In the .clang-format configuration file, this can be configured like:
+ /// \code{.yaml}
+ /// WhitespaceSensitiveMacros: ['STRINGIZE', 'PP_STRINGIZE']
+ /// \endcode
+ ///
+ /// For example: BOOST_PP_STRINGIZE
+ /// \version 11
+ std::vector<std::string> WhitespaceSensitiveMacros;
+
bool operator==(const FormatStyle &R) const {
return AccessModifierOffset == R.AccessModifierOffset &&
AlignAfterOpenBracket == R.AlignAfterOpenBracket &&
@@ -3993,10 +3992,10 @@ struct FormatStyle {
AllowAllArgumentsOnNextLine == R.AllowAllArgumentsOnNextLine &&
AllowAllParametersOfDeclarationOnNextLine ==
R.AllowAllParametersOfDeclarationOnNextLine &&
- AllowShortEnumsOnASingleLine == R.AllowShortEnumsOnASingleLine &&
AllowShortBlocksOnASingleLine == R.AllowShortBlocksOnASingleLine &&
AllowShortCaseLabelsOnASingleLine ==
R.AllowShortCaseLabelsOnASingleLine &&
+ AllowShortEnumsOnASingleLine == R.AllowShortEnumsOnASingleLine &&
AllowShortFunctionsOnASingleLine ==
R.AllowShortFunctionsOnASingleLine &&
AllowShortIfStatementsOnASingleLine ==
@@ -4011,17 +4010,18 @@ struct FormatStyle {
AttributeMacros == R.AttributeMacros &&
BinPackArguments == R.BinPackArguments &&
BinPackParameters == R.BinPackParameters &&
+ BitFieldColonSpacing == R.BitFieldColonSpacing &&
+ BreakAfterJavaFieldAnnotations == R.BreakAfterJavaFieldAnnotations &&
BreakArrays == R.BreakArrays &&
BreakBeforeBinaryOperators == R.BreakBeforeBinaryOperators &&
BreakBeforeBraces == R.BreakBeforeBraces &&
BreakBeforeConceptDeclarations == R.BreakBeforeConceptDeclarations &&
BreakBeforeTernaryOperators == R.BreakBeforeTernaryOperators &&
BreakConstructorInitializers == R.BreakConstructorInitializers &&
- CompactNamespaces == R.CompactNamespaces &&
- BreakAfterJavaFieldAnnotations == R.BreakAfterJavaFieldAnnotations &&
+ BreakInheritanceList == R.BreakInheritanceList &&
BreakStringLiterals == R.BreakStringLiterals &&
ColumnLimit == R.ColumnLimit && CommentPragmas == R.CommentPragmas &&
- BreakInheritanceList == R.BreakInheritanceList &&
+ CompactNamespaces == R.CompactNamespaces &&
ConstructorInitializerIndentWidth ==
R.ConstructorInitializerIndentWidth &&
ContinuationIndentWidth == R.ContinuationIndentWidth &&
@@ -4033,7 +4033,6 @@ struct FormatStyle {
EmptyLineBeforeAccessModifier == R.EmptyLineBeforeAccessModifier &&
ExperimentalAutoDetectBinPacking ==
R.ExperimentalAutoDetectBinPacking &&
- PackConstructorInitializers == R.PackConstructorInitializers &&
FixNamespaceComments == R.FixNamespaceComments &&
ForEachMacros == R.ForEachMacros &&
IncludeStyle.IncludeBlocks == R.IncludeStyle.IncludeBlocks &&
@@ -4043,19 +4042,20 @@ struct FormatStyle {
IncludeStyle.IncludeIsMainSourceRegex ==
R.IncludeStyle.IncludeIsMainSourceRegex &&
IndentAccessModifiers == R.IndentAccessModifiers &&
- IndentCaseLabels == R.IndentCaseLabels &&
IndentCaseBlocks == R.IndentCaseBlocks &&
+ IndentCaseLabels == R.IndentCaseLabels &&
+ IndentExternBlock == R.IndentExternBlock &&
IndentGotoLabels == R.IndentGotoLabels &&
IndentPPDirectives == R.IndentPPDirectives &&
- IndentExternBlock == R.IndentExternBlock &&
IndentRequiresClause == R.IndentRequiresClause &&
- IndentWidth == R.IndentWidth && Language == R.Language &&
+ IndentWidth == R.IndentWidth &&
IndentWrappedFunctionNames == R.IndentWrappedFunctionNames &&
JavaImportGroups == R.JavaImportGroups &&
JavaScriptQuotes == R.JavaScriptQuotes &&
JavaScriptWrapImports == R.JavaScriptWrapImports &&
KeepEmptyLinesAtTheStartOfBlocks ==
R.KeepEmptyLinesAtTheStartOfBlocks &&
+ Language == R.Language &&
LambdaBodyIndentation == R.LambdaBodyIndentation &&
MacroBlockBegin == R.MacroBlockBegin &&
MacroBlockEnd == R.MacroBlockEnd &&
@@ -4068,6 +4068,7 @@ struct FormatStyle {
R.ObjCBreakBeforeNestedBlockParam &&
ObjCSpaceAfterProperty == R.ObjCSpaceAfterProperty &&
ObjCSpaceBeforeProtocolList == R.ObjCSpaceBeforeProtocolList &&
+ PackConstructorInitializers == R.PackConstructorInitializers &&
PenaltyBreakAssignment == R.PenaltyBreakAssignment &&
PenaltyBreakBeforeFirstCallParameter ==
R.PenaltyBreakBeforeFirstCallParameter &&
@@ -4075,10 +4076,10 @@ struct FormatStyle {
PenaltyBreakFirstLessLess == R.PenaltyBreakFirstLessLess &&
PenaltyBreakOpenParenthesis == R.PenaltyBreakOpenParenthesis &&
PenaltyBreakString == R.PenaltyBreakString &&
- PenaltyExcessCharacter == R.PenaltyExcessCharacter &&
- PenaltyReturnTypeOnItsOwnLine == R.PenaltyReturnTypeOnItsOwnLine &&
PenaltyBreakTemplateDeclaration ==
R.PenaltyBreakTemplateDeclaration &&
+ PenaltyExcessCharacter == R.PenaltyExcessCharacter &&
+ PenaltyReturnTypeOnItsOwnLine == R.PenaltyReturnTypeOnItsOwnLine &&
PointerAlignment == R.PointerAlignment &&
QualifierAlignment == R.QualifierAlignment &&
QualifierOrder == R.QualifierOrder &&
@@ -4106,6 +4107,7 @@ struct FormatStyle {
SpaceAroundPointerQualifiers == R.SpaceAroundPointerQualifiers &&
SpaceBeforeRangeBasedForLoopColon ==
R.SpaceBeforeRangeBasedForLoopColon &&
+ SpaceBeforeSquareBrackets == R.SpaceBeforeSquareBrackets &&
SpaceInEmptyBlock == R.SpaceInEmptyBlock &&
SpaceInEmptyParentheses == R.SpaceInEmptyParentheses &&
SpacesBeforeTrailingComments == R.SpacesBeforeTrailingComments &&
@@ -4119,13 +4121,12 @@ struct FormatStyle {
R.SpacesInLineCommentPrefix.Maximum &&
SpacesInParentheses == R.SpacesInParentheses &&
SpacesInSquareBrackets == R.SpacesInSquareBrackets &&
- SpaceBeforeSquareBrackets == R.SpaceBeforeSquareBrackets &&
- BitFieldColonSpacing == R.BitFieldColonSpacing &&
Standard == R.Standard &&
StatementAttributeLikeMacros == R.StatementAttributeLikeMacros &&
StatementMacros == R.StatementMacros && TabWidth == R.TabWidth &&
- UseTab == R.UseTab && UseCRLF == R.UseCRLF &&
- TypenameMacros == R.TypenameMacros;
+ TypenameMacros == R.TypenameMacros && UseCRLF == R.UseCRLF &&
+ UseTab == R.UseTab &&
+ WhitespaceSensitiveMacros == R.WhitespaceSensitiveMacros;
}
llvm::Optional<FormatStyle> GetLanguageStyle(LanguageKind Language) const;
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 8405995f05eaa..1d9ffdc1275cf 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -57,110 +57,6 @@ LLVM_YAML_IS_SEQUENCE_VECTOR(clang::format::FormatStyle::RawStringFormat)
namespace llvm {
namespace yaml {
-template <> struct ScalarEnumerationTraits<FormatStyle::LanguageKind> {
- static void enumeration(IO &IO, FormatStyle::LanguageKind &Value) {
- IO.enumCase(Value, "Cpp", FormatStyle::LK_Cpp);
- IO.enumCase(Value, "Java", FormatStyle::LK_Java);
- IO.enumCase(Value, "JavaScript", FormatStyle::LK_JavaScript);
- IO.enumCase(Value, "ObjC", FormatStyle::LK_ObjC);
- IO.enumCase(Value, "Proto", FormatStyle::LK_Proto);
- IO.enumCase(Value, "TableGen", FormatStyle::LK_TableGen);
- IO.enumCase(Value, "TextProto", FormatStyle::LK_TextProto);
- IO.enumCase(Value, "CSharp", FormatStyle::LK_CSharp);
- IO.enumCase(Value, "Json", FormatStyle::LK_Json);
- }
-};
-
-template <> struct ScalarEnumerationTraits<FormatStyle::LanguageStandard> {
- static void enumeration(IO &IO, FormatStyle::LanguageStandard &Value) {
- IO.enumCase(Value, "c++03", FormatStyle::LS_Cpp03);
- IO.enumCase(Value, "C++03", FormatStyle::LS_Cpp03); // Legacy alias
- IO.enumCase(Value, "Cpp03", FormatStyle::LS_Cpp03); // Legacy alias
-
- IO.enumCase(Value, "c++11", FormatStyle::LS_Cpp11);
- IO.enumCase(Value, "C++11", FormatStyle::LS_Cpp11); // Legacy alias
-
- IO.enumCase(Value, "c++14", FormatStyle::LS_Cpp14);
- IO.enumCase(Value, "c++17", FormatStyle::LS_Cpp17);
- IO.enumCase(Value, "c++20", FormatStyle::LS_Cpp20);
-
- IO.enumCase(Value, "Latest", FormatStyle::LS_Latest);
- IO.enumCase(Value, "Cpp11", FormatStyle::LS_Latest); // Legacy alias
- IO.enumCase(Value, "Auto", FormatStyle::LS_Auto);
- }
-};
-
-template <>
-struct ScalarEnumerationTraits<FormatStyle::LambdaBodyIndentationKind> {
- static void enumeration(IO &IO,
- FormatStyle::LambdaBodyIndentationKind &Value) {
- IO.enumCase(Value, "Signature", FormatStyle::LBI_Signature);
- IO.enumCase(Value, "OuterScope", FormatStyle::LBI_OuterScope);
- }
-};
-
-template <>
-struct ScalarEnumerationTraits<FormatStyle::RequiresExpressionIndentationKind> {
- static void
- enumeration(IO &IO, FormatStyle::RequiresExpressionIndentationKind &Value) {
- IO.enumCase(Value, "Keyword", FormatStyle::REI_Keyword);
- IO.enumCase(Value, "OuterScope", FormatStyle::REI_OuterScope);
- }
-};
-
-template <> struct ScalarEnumerationTraits<FormatStyle::UseTabStyle> {
- static void enumeration(IO &IO, FormatStyle::UseTabStyle &Value) {
- IO.enumCase(Value, "Never", FormatStyle::UT_Never);
- IO.enumCase(Value, "false", FormatStyle::UT_Never);
- IO.enumCase(Value, "Always", FormatStyle::UT_Always);
- IO.enumCase(Value, "true", FormatStyle::UT_Always);
- IO.enumCase(Value, "ForIndentation", FormatStyle::UT_ForIndentation);
- IO.enumCase(Value, "ForContinuationAndIndentation",
- FormatStyle::UT_ForContinuationAndIndentation);
- IO.enumCase(Value, "AlignWithSpaces", FormatStyle::UT_AlignWithSpaces);
- }
-};
-
-template <> struct ScalarEnumerationTraits<FormatStyle::JavaScriptQuoteStyle> {
- static void enumeration(IO &IO, FormatStyle::JavaScriptQuoteStyle &Value) {
- IO.enumCase(Value, "Leave", FormatStyle::JSQS_Leave);
- IO.enumCase(Value, "Single", FormatStyle::JSQS_Single);
- IO.enumCase(Value, "Double", FormatStyle::JSQS_Double);
- }
-};
-
-template <> struct ScalarEnumerationTraits<FormatStyle::ShortBlockStyle> {
- static void enumeration(IO &IO, FormatStyle::ShortBlockStyle &Value) {
- IO.enumCase(Value, "Never", FormatStyle::SBS_Never);
- IO.enumCase(Value, "false", FormatStyle::SBS_Never);
- IO.enumCase(Value, "Always", FormatStyle::SBS_Always);
- IO.enumCase(Value, "true", FormatStyle::SBS_Always);
- IO.enumCase(Value, "Empty", FormatStyle::SBS_Empty);
- }
-};
-
-template <>
-struct ScalarEnumerationTraits<FormatStyle::QualifierAlignmentStyle> {
- static void enumeration(IO &IO, FormatStyle::QualifierAlignmentStyle &Value) {
- IO.enumCase(Value, "Leave", FormatStyle::QAS_Leave);
- IO.enumCase(Value, "Left", FormatStyle::QAS_Left);
- IO.enumCase(Value, "Right", FormatStyle::QAS_Right);
- IO.enumCase(Value, "Custom", FormatStyle::QAS_Custom);
- }
-};
-
-template <> struct ScalarEnumerationTraits<FormatStyle::ShortFunctionStyle> {
- static void enumeration(IO &IO, FormatStyle::ShortFunctionStyle &Value) {
- IO.enumCase(Value, "None", FormatStyle::SFS_None);
- IO.enumCase(Value, "false", FormatStyle::SFS_None);
- IO.enumCase(Value, "All", FormatStyle::SFS_All);
- IO.enumCase(Value, "true", FormatStyle::SFS_All);
- IO.enumCase(Value, "Inline", FormatStyle::SFS_Inline);
- IO.enumCase(Value, "InlineOnly", FormatStyle::SFS_InlineOnly);
- IO.enumCase(Value, "Empty", FormatStyle::SFS_Empty);
- }
-};
-
template <> struct MappingTraits<FormatStyle::AlignConsecutiveStyle> {
static void enumInput(IO &IO, FormatStyle::AlignConsecutiveStyle &Value) {
IO.enumCase(Value, "None",
@@ -213,47 +109,6 @@ template <> struct MappingTraits<FormatStyle::AlignConsecutiveStyle> {
}
};
-template <>
-struct ScalarEnumerationTraits<FormatStyle::TrailingCommentsAlignmentKinds> {
- static void enumeration(IO &IO,
- FormatStyle::TrailingCommentsAlignmentKinds &Value) {
- IO.enumCase(Value, "Leave", FormatStyle::TCAS_Leave);
- IO.enumCase(Value, "Always", FormatStyle::TCAS_Always);
- IO.enumCase(Value, "Never", FormatStyle::TCAS_Never);
- }
-};
-
-template <> struct MappingTraits<FormatStyle::TrailingCommentsAlignmentStyle> {
- static void enumInput(IO &IO,
- FormatStyle::TrailingCommentsAlignmentStyle &Value) {
- IO.enumCase(Value, "Leave",
- FormatStyle::TrailingCommentsAlignmentStyle(
- {FormatStyle::TCAS_Leave, 1}));
-
- IO.enumCase(Value, "Always",
- FormatStyle::TrailingCommentsAlignmentStyle(
- {FormatStyle::TCAS_Always, 1}));
-
- IO.enumCase(Value, "Never",
- FormatStyle::TrailingCommentsAlignmentStyle(
- {FormatStyle::TCAS_Never, 1}));
-
- // For backwards compatibility
- IO.enumCase(Value, "true",
- FormatStyle::TrailingCommentsAlignmentStyle(
- {FormatStyle::TCAS_Always, 1}));
- IO.enumCase(Value, "false",
- FormatStyle::TrailingCommentsAlignmentStyle(
- {FormatStyle::TCAS_Never, 1}));
- }
-
- static void mapping(IO &IO,
- FormatStyle::TrailingCommentsAlignmentStyle &Value) {
- IO.mapOptional("Kind", Value.Kind);
- IO.mapOptional("OverEmptyLines", Value.OverEmptyLines);
- }
-};
-
template <>
struct ScalarEnumerationTraits<FormatStyle::ArrayInitializerAlignmentStyle> {
static void enumeration(IO &IO,
@@ -264,28 +119,13 @@ struct ScalarEnumerationTraits<FormatStyle::ArrayInitializerAlignmentStyle> {
}
};
-template <> struct ScalarEnumerationTraits<FormatStyle::ShortIfStyle> {
- static void enumeration(IO &IO, FormatStyle::ShortIfStyle &Value) {
- IO.enumCase(Value, "Never", FormatStyle::SIS_Never);
- IO.enumCase(Value, "WithoutElse", FormatStyle::SIS_WithoutElse);
- IO.enumCase(Value, "OnlyFirstIf", FormatStyle::SIS_OnlyFirstIf);
- IO.enumCase(Value, "AllIfsAndElse", FormatStyle::SIS_AllIfsAndElse);
-
- // For backward compatibility.
- IO.enumCase(Value, "Always", FormatStyle::SIS_OnlyFirstIf);
- IO.enumCase(Value, "false", FormatStyle::SIS_Never);
- IO.enumCase(Value, "true", FormatStyle::SIS_WithoutElse);
- }
-};
-
-template <> struct ScalarEnumerationTraits<FormatStyle::ShortLambdaStyle> {
- static void enumeration(IO &IO, FormatStyle::ShortLambdaStyle &Value) {
- IO.enumCase(Value, "None", FormatStyle::SLS_None);
- IO.enumCase(Value, "false", FormatStyle::SLS_None);
- IO.enumCase(Value, "Empty", FormatStyle::SLS_Empty);
- IO.enumCase(Value, "Inline", FormatStyle::SLS_Inline);
- IO.enumCase(Value, "All", FormatStyle::SLS_All);
- IO.enumCase(Value, "true", FormatStyle::SLS_All);
+template <> struct ScalarEnumerationTraits<FormatStyle::BinaryOperatorStyle> {
+ static void enumeration(IO &IO, FormatStyle::BinaryOperatorStyle &Value) {
+ IO.enumCase(Value, "All", FormatStyle::BOS_All);
+ IO.enumCase(Value, "true", FormatStyle::BOS_All);
+ IO.enumCase(Value, "None", FormatStyle::BOS_None);
+ IO.enumCase(Value, "false", FormatStyle::BOS_None);
+ IO.enumCase(Value, "NonAssignment", FormatStyle::BOS_NonAssignment);
}
};
@@ -297,20 +137,14 @@ template <> struct ScalarEnumerationTraits<FormatStyle::BinPackStyle> {
}
};
-template <> struct ScalarEnumerationTraits<FormatStyle::TrailingCommaStyle> {
- static void enumeration(IO &IO, FormatStyle::TrailingCommaStyle &Value) {
- IO.enumCase(Value, "None", FormatStyle::TCS_None);
- IO.enumCase(Value, "Wrapped", FormatStyle::TCS_Wrapped);
- }
-};
-
-template <> struct ScalarEnumerationTraits<FormatStyle::BinaryOperatorStyle> {
- static void enumeration(IO &IO, FormatStyle::BinaryOperatorStyle &Value) {
- IO.enumCase(Value, "All", FormatStyle::BOS_All);
- IO.enumCase(Value, "true", FormatStyle::BOS_All);
- IO.enumCase(Value, "None", FormatStyle::BOS_None);
- IO.enumCase(Value, "false", FormatStyle::BOS_None);
- IO.enumCase(Value, "NonAssignment", FormatStyle::BOS_NonAssignment);
+template <>
+struct ScalarEnumerationTraits<FormatStyle::BitFieldColonSpacingStyle> {
+ static void enumeration(IO &IO,
+ FormatStyle::BitFieldColonSpacingStyle &Value) {
+ IO.enumCase(Value, "Both", FormatStyle::BFCS_Both);
+ IO.enumCase(Value, "None", FormatStyle::BFCS_None);
+ IO.enumCase(Value, "Before", FormatStyle::BFCS_Before);
+ IO.enumCase(Value, "After", FormatStyle::BFCS_After);
}
};
@@ -328,6 +162,42 @@ template <> struct ScalarEnumerationTraits<FormatStyle::BraceBreakingStyle> {
}
};
+template <> struct MappingTraits<FormatStyle::BraceWrappingFlags> {
+ static void mapping(IO &IO, FormatStyle::BraceWrappingFlags &Wrapping) {
+ IO.mapOptional("AfterCaseLabel", Wrapping.AfterCaseLabel);
+ IO.mapOptional("AfterClass", Wrapping.AfterClass);
+ IO.mapOptional("AfterControlStatement", Wrapping.AfterControlStatement);
+ IO.mapOptional("AfterEnum", Wrapping.AfterEnum);
+ IO.mapOptional("AfterExternBlock", Wrapping.AfterExternBlock);
+ IO.mapOptional("AfterFunction", Wrapping.AfterFunction);
+ IO.mapOptional("AfterNamespace", Wrapping.AfterNamespace);
+ IO.mapOptional("AfterObjCDeclaration", Wrapping.AfterObjCDeclaration);
+ IO.mapOptional("AfterStruct", Wrapping.AfterStruct);
+ IO.mapOptional("AfterUnion", Wrapping.AfterUnion);
+ IO.mapOptional("BeforeCatch", Wrapping.BeforeCatch);
+ IO.mapOptional("BeforeElse", Wrapping.BeforeElse);
+ IO.mapOptional("BeforeLambdaBody", Wrapping.BeforeLambdaBody);
+ IO.mapOptional("BeforeWhile", Wrapping.BeforeWhile);
+ IO.mapOptional("IndentBraces", Wrapping.IndentBraces);
+ IO.mapOptional("SplitEmptyFunction", Wrapping.SplitEmptyFunction);
+ IO.mapOptional("SplitEmptyRecord", Wrapping.SplitEmptyRecord);
+ IO.mapOptional("SplitEmptyNamespace", Wrapping.SplitEmptyNamespace);
+ }
+};
+
+template <> struct ScalarEnumerationTraits<FormatStyle::BracketAlignmentStyle> {
+ static void enumeration(IO &IO, FormatStyle::BracketAlignmentStyle &Value) {
+ IO.enumCase(Value, "Align", FormatStyle::BAS_Align);
+ IO.enumCase(Value, "DontAlign", FormatStyle::BAS_DontAlign);
+ IO.enumCase(Value, "AlwaysBreak", FormatStyle::BAS_AlwaysBreak);
+ IO.enumCase(Value, "BlockIndent", FormatStyle::BAS_BlockIndent);
+
+ // For backward compatibility.
+ IO.enumCase(Value, "true", FormatStyle::BAS_Align);
+ IO.enumCase(Value, "false", FormatStyle::BAS_DontAlign);
+ }
+};
+
template <>
struct ScalarEnumerationTraits<
FormatStyle::BraceWrappingAfterControlStatementStyle> {
@@ -381,13 +251,44 @@ struct ScalarEnumerationTraits<FormatStyle::BreakInheritanceListStyle> {
};
template <>
-struct ScalarEnumerationTraits<FormatStyle::PackConstructorInitializersStyle> {
+struct ScalarEnumerationTraits<FormatStyle::BreakTemplateDeclarationsStyle> {
+ static void enumeration(IO &IO,
+ FormatStyle::BreakTemplateDeclarationsStyle &Value) {
+ IO.enumCase(Value, "No", FormatStyle::BTDS_No);
+ IO.enumCase(Value, "MultiLine", FormatStyle::BTDS_MultiLine);
+ IO.enumCase(Value, "Yes", FormatStyle::BTDS_Yes);
+
+ // For backward compatibility.
+ IO.enumCase(Value, "false", FormatStyle::BTDS_MultiLine);
+ IO.enumCase(Value, "true", FormatStyle::BTDS_Yes);
+ }
+};
+
+template <>
+struct ScalarEnumerationTraits<FormatStyle::DefinitionReturnTypeBreakingStyle> {
static void
- enumeration(IO &IO, FormatStyle::PackConstructorInitializersStyle &Value) {
- IO.enumCase(Value, "Never", FormatStyle::PCIS_Never);
- IO.enumCase(Value, "BinPack", FormatStyle::PCIS_BinPack);
- IO.enumCase(Value, "CurrentLine", FormatStyle::PCIS_CurrentLine);
- IO.enumCase(Value, "NextLine", FormatStyle::PCIS_NextLine);
+ enumeration(IO &IO, FormatStyle::DefinitionReturnTypeBreakingStyle &Value) {
+ IO.enumCase(Value, "None", FormatStyle::DRTBS_None);
+ IO.enumCase(Value, "All", FormatStyle::DRTBS_All);
+ IO.enumCase(Value, "TopLevel", FormatStyle::DRTBS_TopLevel);
+
+ // For backward compatibility.
+ IO.enumCase(Value, "false", FormatStyle::DRTBS_None);
+ IO.enumCase(Value, "true", FormatStyle::DRTBS_All);
+ }
+};
+
+template <>
+struct ScalarEnumerationTraits<FormatStyle::EscapedNewlineAlignmentStyle> {
+ static void enumeration(IO &IO,
+ FormatStyle::EscapedNewlineAlignmentStyle &Value) {
+ IO.enumCase(Value, "DontAlign", FormatStyle::ENAS_DontAlign);
+ IO.enumCase(Value, "Left", FormatStyle::ENAS_Left);
+ IO.enumCase(Value, "Right", FormatStyle::ENAS_Right);
+
+ // For backward compatibility.
+ IO.enumCase(Value, "true", FormatStyle::ENAS_Left);
+ IO.enumCase(Value, "false", FormatStyle::ENAS_Right);
}
};
@@ -413,15 +314,6 @@ struct ScalarEnumerationTraits<
}
};
-template <>
-struct ScalarEnumerationTraits<FormatStyle::PPDirectiveIndentStyle> {
- static void enumeration(IO &IO, FormatStyle::PPDirectiveIndentStyle &Value) {
- IO.enumCase(Value, "None", FormatStyle::PPDIS_None);
- IO.enumCase(Value, "AfterHash", FormatStyle::PPDIS_AfterHash);
- IO.enumCase(Value, "BeforeHash", FormatStyle::PPDIS_BeforeHash);
- }
-};
-
template <>
struct ScalarEnumerationTraits<FormatStyle::IndentExternBlockStyle> {
static void enumeration(IO &IO, FormatStyle::IndentExternBlockStyle &Value) {
@@ -433,114 +325,247 @@ struct ScalarEnumerationTraits<FormatStyle::IndentExternBlockStyle> {
}
};
+template <> struct ScalarEnumerationTraits<FormatStyle::JavaScriptQuoteStyle> {
+ static void enumeration(IO &IO, FormatStyle::JavaScriptQuoteStyle &Value) {
+ IO.enumCase(Value, "Leave", FormatStyle::JSQS_Leave);
+ IO.enumCase(Value, "Single", FormatStyle::JSQS_Single);
+ IO.enumCase(Value, "Double", FormatStyle::JSQS_Double);
+ }
+};
+
+template <> struct ScalarEnumerationTraits<FormatStyle::LanguageKind> {
+ static void enumeration(IO &IO, FormatStyle::LanguageKind &Value) {
+ IO.enumCase(Value, "Cpp", FormatStyle::LK_Cpp);
+ IO.enumCase(Value, "Java", FormatStyle::LK_Java);
+ IO.enumCase(Value, "JavaScript", FormatStyle::LK_JavaScript);
+ IO.enumCase(Value, "ObjC", FormatStyle::LK_ObjC);
+ IO.enumCase(Value, "Proto", FormatStyle::LK_Proto);
+ IO.enumCase(Value, "TableGen", FormatStyle::LK_TableGen);
+ IO.enumCase(Value, "TextProto", FormatStyle::LK_TextProto);
+ IO.enumCase(Value, "CSharp", FormatStyle::LK_CSharp);
+ IO.enumCase(Value, "Json", FormatStyle::LK_Json);
+ }
+};
+
+template <> struct ScalarEnumerationTraits<FormatStyle::LanguageStandard> {
+ static void enumeration(IO &IO, FormatStyle::LanguageStandard &Value) {
+ IO.enumCase(Value, "c++03", FormatStyle::LS_Cpp03);
+ IO.enumCase(Value, "C++03", FormatStyle::LS_Cpp03); // Legacy alias
+ IO.enumCase(Value, "Cpp03", FormatStyle::LS_Cpp03); // Legacy alias
+
+ IO.enumCase(Value, "c++11", FormatStyle::LS_Cpp11);
+ IO.enumCase(Value, "C++11", FormatStyle::LS_Cpp11); // Legacy alias
+
+ IO.enumCase(Value, "c++14", FormatStyle::LS_Cpp14);
+ IO.enumCase(Value, "c++17", FormatStyle::LS_Cpp17);
+ IO.enumCase(Value, "c++20", FormatStyle::LS_Cpp20);
+
+ IO.enumCase(Value, "Latest", FormatStyle::LS_Latest);
+ IO.enumCase(Value, "Cpp11", FormatStyle::LS_Latest); // Legacy alias
+ IO.enumCase(Value, "Auto", FormatStyle::LS_Auto);
+ }
+};
+
template <>
-struct ScalarEnumerationTraits<FormatStyle::ReturnTypeBreakingStyle> {
- static void enumeration(IO &IO, FormatStyle::ReturnTypeBreakingStyle &Value) {
- IO.enumCase(Value, "None", FormatStyle::RTBS_None);
- IO.enumCase(Value, "All", FormatStyle::RTBS_All);
- IO.enumCase(Value, "TopLevel", FormatStyle::RTBS_TopLevel);
- IO.enumCase(Value, "TopLevelDefinitions",
- FormatStyle::RTBS_TopLevelDefinitions);
- IO.enumCase(Value, "AllDefinitions", FormatStyle::RTBS_AllDefinitions);
+struct ScalarEnumerationTraits<FormatStyle::LambdaBodyIndentationKind> {
+ static void enumeration(IO &IO,
+ FormatStyle::LambdaBodyIndentationKind &Value) {
+ IO.enumCase(Value, "Signature", FormatStyle::LBI_Signature);
+ IO.enumCase(Value, "OuterScope", FormatStyle::LBI_OuterScope);
}
};
template <>
-struct ScalarEnumerationTraits<FormatStyle::BreakTemplateDeclarationsStyle> {
+struct ScalarEnumerationTraits<FormatStyle::NamespaceIndentationKind> {
static void enumeration(IO &IO,
- FormatStyle::BreakTemplateDeclarationsStyle &Value) {
- IO.enumCase(Value, "No", FormatStyle::BTDS_No);
- IO.enumCase(Value, "MultiLine", FormatStyle::BTDS_MultiLine);
- IO.enumCase(Value, "Yes", FormatStyle::BTDS_Yes);
+ FormatStyle::NamespaceIndentationKind &Value) {
+ IO.enumCase(Value, "None", FormatStyle::NI_None);
+ IO.enumCase(Value, "Inner", FormatStyle::NI_Inner);
+ IO.enumCase(Value, "All", FormatStyle::NI_All);
+ }
+};
+
+template <> struct ScalarEnumerationTraits<FormatStyle::OperandAlignmentStyle> {
+ static void enumeration(IO &IO, FormatStyle::OperandAlignmentStyle &Value) {
+ IO.enumCase(Value, "DontAlign", FormatStyle::OAS_DontAlign);
+ IO.enumCase(Value, "Align", FormatStyle::OAS_Align);
+ IO.enumCase(Value, "AlignAfterOperator",
+ FormatStyle::OAS_AlignAfterOperator);
// For backward compatibility.
- IO.enumCase(Value, "false", FormatStyle::BTDS_MultiLine);
- IO.enumCase(Value, "true", FormatStyle::BTDS_Yes);
+ IO.enumCase(Value, "true", FormatStyle::OAS_Align);
+ IO.enumCase(Value, "false", FormatStyle::OAS_DontAlign);
}
};
template <>
-struct ScalarEnumerationTraits<FormatStyle::DefinitionReturnTypeBreakingStyle> {
+struct ScalarEnumerationTraits<FormatStyle::PackConstructorInitializersStyle> {
static void
- enumeration(IO &IO, FormatStyle::DefinitionReturnTypeBreakingStyle &Value) {
- IO.enumCase(Value, "None", FormatStyle::DRTBS_None);
- IO.enumCase(Value, "All", FormatStyle::DRTBS_All);
- IO.enumCase(Value, "TopLevel", FormatStyle::DRTBS_TopLevel);
+ enumeration(IO &IO, FormatStyle::PackConstructorInitializersStyle &Value) {
+ IO.enumCase(Value, "Never", FormatStyle::PCIS_Never);
+ IO.enumCase(Value, "BinPack", FormatStyle::PCIS_BinPack);
+ IO.enumCase(Value, "CurrentLine", FormatStyle::PCIS_CurrentLine);
+ IO.enumCase(Value, "NextLine", FormatStyle::PCIS_NextLine);
+ }
+};
+
+template <> struct ScalarEnumerationTraits<FormatStyle::PointerAlignmentStyle> {
+ static void enumeration(IO &IO, FormatStyle::PointerAlignmentStyle &Value) {
+ IO.enumCase(Value, "Middle", FormatStyle::PAS_Middle);
+ IO.enumCase(Value, "Left", FormatStyle::PAS_Left);
+ IO.enumCase(Value, "Right", FormatStyle::PAS_Right);
// For backward compatibility.
- IO.enumCase(Value, "false", FormatStyle::DRTBS_None);
- IO.enumCase(Value, "true", FormatStyle::DRTBS_All);
+ IO.enumCase(Value, "true", FormatStyle::PAS_Left);
+ IO.enumCase(Value, "false", FormatStyle::PAS_Right);
}
};
template <>
-struct ScalarEnumerationTraits<FormatStyle::NamespaceIndentationKind> {
+struct ScalarEnumerationTraits<FormatStyle::PPDirectiveIndentStyle> {
+ static void enumeration(IO &IO, FormatStyle::PPDirectiveIndentStyle &Value) {
+ IO.enumCase(Value, "None", FormatStyle::PPDIS_None);
+ IO.enumCase(Value, "AfterHash", FormatStyle::PPDIS_AfterHash);
+ IO.enumCase(Value, "BeforeHash", FormatStyle::PPDIS_BeforeHash);
+ }
+};
+
+template <>
+struct ScalarEnumerationTraits<FormatStyle::QualifierAlignmentStyle> {
+ static void enumeration(IO &IO, FormatStyle::QualifierAlignmentStyle &Value) {
+ IO.enumCase(Value, "Leave", FormatStyle::QAS_Leave);
+ IO.enumCase(Value, "Left", FormatStyle::QAS_Left);
+ IO.enumCase(Value, "Right", FormatStyle::QAS_Right);
+ IO.enumCase(Value, "Custom", FormatStyle::QAS_Custom);
+ }
+};
+
+template <> struct MappingTraits<FormatStyle::RawStringFormat> {
+ static void mapping(IO &IO, FormatStyle::RawStringFormat &Format) {
+ IO.mapOptional("Language", Format.Language);
+ IO.mapOptional("Delimiters", Format.Delimiters);
+ IO.mapOptional("EnclosingFunctions", Format.EnclosingFunctions);
+ IO.mapOptional("CanonicalDelimiter", Format.CanonicalDelimiter);
+ IO.mapOptional("BasedOnStyle", Format.BasedOnStyle);
+ }
+};
+
+template <>
+struct ScalarEnumerationTraits<FormatStyle::ReferenceAlignmentStyle> {
+ static void enumeration(IO &IO, FormatStyle::ReferenceAlignmentStyle &Value) {
+ IO.enumCase(Value, "Pointer", FormatStyle::RAS_Pointer);
+ IO.enumCase(Value, "Middle", FormatStyle::RAS_Middle);
+ IO.enumCase(Value, "Left", FormatStyle::RAS_Left);
+ IO.enumCase(Value, "Right", FormatStyle::RAS_Right);
+ }
+};
+
+template <>
+struct ScalarEnumerationTraits<FormatStyle::RequiresClausePositionStyle> {
static void enumeration(IO &IO,
- FormatStyle::NamespaceIndentationKind &Value) {
- IO.enumCase(Value, "None", FormatStyle::NI_None);
- IO.enumCase(Value, "Inner", FormatStyle::NI_Inner);
- IO.enumCase(Value, "All", FormatStyle::NI_All);
+ FormatStyle::RequiresClausePositionStyle &Value) {
+ IO.enumCase(Value, "OwnLine", FormatStyle::RCPS_OwnLine);
+ IO.enumCase(Value, "WithPreceding", FormatStyle::RCPS_WithPreceding);
+ IO.enumCase(Value, "WithFollowing", FormatStyle::RCPS_WithFollowing);
+ IO.enumCase(Value, "SingleLine", FormatStyle::RCPS_SingleLine);
}
};
-template <> struct ScalarEnumerationTraits<FormatStyle::BracketAlignmentStyle> {
- static void enumeration(IO &IO, FormatStyle::BracketAlignmentStyle &Value) {
- IO.enumCase(Value, "Align", FormatStyle::BAS_Align);
- IO.enumCase(Value, "DontAlign", FormatStyle::BAS_DontAlign);
- IO.enumCase(Value, "AlwaysBreak", FormatStyle::BAS_AlwaysBreak);
- IO.enumCase(Value, "BlockIndent", FormatStyle::BAS_BlockIndent);
+template <>
+struct ScalarEnumerationTraits<FormatStyle::RequiresExpressionIndentationKind> {
+ static void
+ enumeration(IO &IO, FormatStyle::RequiresExpressionIndentationKind &Value) {
+ IO.enumCase(Value, "Keyword", FormatStyle::REI_Keyword);
+ IO.enumCase(Value, "OuterScope", FormatStyle::REI_OuterScope);
+ }
+};
+
+template <>
+struct ScalarEnumerationTraits<FormatStyle::ReturnTypeBreakingStyle> {
+ static void enumeration(IO &IO, FormatStyle::ReturnTypeBreakingStyle &Value) {
+ IO.enumCase(Value, "None", FormatStyle::RTBS_None);
+ IO.enumCase(Value, "All", FormatStyle::RTBS_All);
+ IO.enumCase(Value, "TopLevel", FormatStyle::RTBS_TopLevel);
+ IO.enumCase(Value, "TopLevelDefinitions",
+ FormatStyle::RTBS_TopLevelDefinitions);
+ IO.enumCase(Value, "AllDefinitions", FormatStyle::RTBS_AllDefinitions);
+ }
+};
+
+template <>
+struct ScalarEnumerationTraits<FormatStyle::SeparateDefinitionStyle> {
+ static void enumeration(IO &IO, FormatStyle::SeparateDefinitionStyle &Value) {
+ IO.enumCase(Value, "Leave", FormatStyle::SDS_Leave);
+ IO.enumCase(Value, "Always", FormatStyle::SDS_Always);
+ IO.enumCase(Value, "Never", FormatStyle::SDS_Never);
+ }
+};
+
+template <> struct ScalarEnumerationTraits<FormatStyle::ShortBlockStyle> {
+ static void enumeration(IO &IO, FormatStyle::ShortBlockStyle &Value) {
+ IO.enumCase(Value, "Never", FormatStyle::SBS_Never);
+ IO.enumCase(Value, "false", FormatStyle::SBS_Never);
+ IO.enumCase(Value, "Always", FormatStyle::SBS_Always);
+ IO.enumCase(Value, "true", FormatStyle::SBS_Always);
+ IO.enumCase(Value, "Empty", FormatStyle::SBS_Empty);
+ }
+};
- // For backward compatibility.
- IO.enumCase(Value, "true", FormatStyle::BAS_Align);
- IO.enumCase(Value, "false", FormatStyle::BAS_DontAlign);
+template <> struct ScalarEnumerationTraits<FormatStyle::ShortFunctionStyle> {
+ static void enumeration(IO &IO, FormatStyle::ShortFunctionStyle &Value) {
+ IO.enumCase(Value, "None", FormatStyle::SFS_None);
+ IO.enumCase(Value, "false", FormatStyle::SFS_None);
+ IO.enumCase(Value, "All", FormatStyle::SFS_All);
+ IO.enumCase(Value, "true", FormatStyle::SFS_All);
+ IO.enumCase(Value, "Inline", FormatStyle::SFS_Inline);
+ IO.enumCase(Value, "InlineOnly", FormatStyle::SFS_InlineOnly);
+ IO.enumCase(Value, "Empty", FormatStyle::SFS_Empty);
}
};
-template <>
-struct ScalarEnumerationTraits<FormatStyle::EscapedNewlineAlignmentStyle> {
- static void enumeration(IO &IO,
- FormatStyle::EscapedNewlineAlignmentStyle &Value) {
- IO.enumCase(Value, "DontAlign", FormatStyle::ENAS_DontAlign);
- IO.enumCase(Value, "Left", FormatStyle::ENAS_Left);
- IO.enumCase(Value, "Right", FormatStyle::ENAS_Right);
+template <> struct ScalarEnumerationTraits<FormatStyle::ShortIfStyle> {
+ static void enumeration(IO &IO, FormatStyle::ShortIfStyle &Value) {
+ IO.enumCase(Value, "Never", FormatStyle::SIS_Never);
+ IO.enumCase(Value, "WithoutElse", FormatStyle::SIS_WithoutElse);
+ IO.enumCase(Value, "OnlyFirstIf", FormatStyle::SIS_OnlyFirstIf);
+ IO.enumCase(Value, "AllIfsAndElse", FormatStyle::SIS_AllIfsAndElse);
// For backward compatibility.
- IO.enumCase(Value, "true", FormatStyle::ENAS_Left);
- IO.enumCase(Value, "false", FormatStyle::ENAS_Right);
+ IO.enumCase(Value, "Always", FormatStyle::SIS_OnlyFirstIf);
+ IO.enumCase(Value, "false", FormatStyle::SIS_Never);
+ IO.enumCase(Value, "true", FormatStyle::SIS_WithoutElse);
}
};
-template <> struct ScalarEnumerationTraits<FormatStyle::OperandAlignmentStyle> {
- static void enumeration(IO &IO, FormatStyle::OperandAlignmentStyle &Value) {
- IO.enumCase(Value, "DontAlign", FormatStyle::OAS_DontAlign);
- IO.enumCase(Value, "Align", FormatStyle::OAS_Align);
- IO.enumCase(Value, "AlignAfterOperator",
- FormatStyle::OAS_AlignAfterOperator);
-
- // For backward compatibility.
- IO.enumCase(Value, "true", FormatStyle::OAS_Align);
- IO.enumCase(Value, "false", FormatStyle::OAS_DontAlign);
+template <> struct ScalarEnumerationTraits<FormatStyle::ShortLambdaStyle> {
+ static void enumeration(IO &IO, FormatStyle::ShortLambdaStyle &Value) {
+ IO.enumCase(Value, "None", FormatStyle::SLS_None);
+ IO.enumCase(Value, "false", FormatStyle::SLS_None);
+ IO.enumCase(Value, "Empty", FormatStyle::SLS_Empty);
+ IO.enumCase(Value, "Inline", FormatStyle::SLS_Inline);
+ IO.enumCase(Value, "All", FormatStyle::SLS_All);
+ IO.enumCase(Value, "true", FormatStyle::SLS_All);
}
};
-template <> struct ScalarEnumerationTraits<FormatStyle::PointerAlignmentStyle> {
- static void enumeration(IO &IO, FormatStyle::PointerAlignmentStyle &Value) {
- IO.enumCase(Value, "Middle", FormatStyle::PAS_Middle);
- IO.enumCase(Value, "Left", FormatStyle::PAS_Left);
- IO.enumCase(Value, "Right", FormatStyle::PAS_Right);
+template <> struct ScalarEnumerationTraits<FormatStyle::SortIncludesOptions> {
+ static void enumeration(IO &IO, FormatStyle::SortIncludesOptions &Value) {
+ IO.enumCase(Value, "Never", FormatStyle::SI_Never);
+ IO.enumCase(Value, "CaseInsensitive", FormatStyle::SI_CaseInsensitive);
+ IO.enumCase(Value, "CaseSensitive", FormatStyle::SI_CaseSensitive);
// For backward compatibility.
- IO.enumCase(Value, "true", FormatStyle::PAS_Left);
- IO.enumCase(Value, "false", FormatStyle::PAS_Right);
+ IO.enumCase(Value, "false", FormatStyle::SI_Never);
+ IO.enumCase(Value, "true", FormatStyle::SI_CaseSensitive);
}
};
template <>
-struct ScalarEnumerationTraits<FormatStyle::SeparateDefinitionStyle> {
- static void enumeration(IO &IO, FormatStyle::SeparateDefinitionStyle &Value) {
- IO.enumCase(Value, "Leave", FormatStyle::SDS_Leave);
- IO.enumCase(Value, "Always", FormatStyle::SDS_Always);
- IO.enumCase(Value, "Never", FormatStyle::SDS_Never);
+struct ScalarEnumerationTraits<FormatStyle::SortJavaStaticImportOptions> {
+ static void enumeration(IO &IO,
+ FormatStyle::SortJavaStaticImportOptions &Value) {
+ IO.enumCase(Value, "Before", FormatStyle::SJSIO_Before);
+ IO.enumCase(Value, "After", FormatStyle::SJSIO_After);
}
};
@@ -555,24 +580,21 @@ struct ScalarEnumerationTraits<FormatStyle::SpaceAroundPointerQualifiersStyle> {
}
};
-template <>
-struct ScalarEnumerationTraits<FormatStyle::ReferenceAlignmentStyle> {
- static void enumeration(IO &IO, FormatStyle::ReferenceAlignmentStyle &Value) {
- IO.enumCase(Value, "Pointer", FormatStyle::RAS_Pointer);
- IO.enumCase(Value, "Middle", FormatStyle::RAS_Middle);
- IO.enumCase(Value, "Left", FormatStyle::RAS_Left);
- IO.enumCase(Value, "Right", FormatStyle::RAS_Right);
- }
-};
-
-template <>
-struct ScalarEnumerationTraits<FormatStyle::RequiresClausePositionStyle> {
- static void enumeration(IO &IO,
- FormatStyle::RequiresClausePositionStyle &Value) {
- IO.enumCase(Value, "OwnLine", FormatStyle::RCPS_OwnLine);
- IO.enumCase(Value, "WithPreceding", FormatStyle::RCPS_WithPreceding);
- IO.enumCase(Value, "WithFollowing", FormatStyle::RCPS_WithFollowing);
- IO.enumCase(Value, "SingleLine", FormatStyle::RCPS_SingleLine);
+template <> struct MappingTraits<FormatStyle::SpaceBeforeParensCustom> {
+ static void mapping(IO &IO, FormatStyle::SpaceBeforeParensCustom &Spacing) {
+ IO.mapOptional("AfterControlStatements", Spacing.AfterControlStatements);
+ IO.mapOptional("AfterForeachMacros", Spacing.AfterForeachMacros);
+ IO.mapOptional("AfterFunctionDefinitionName",
+ Spacing.AfterFunctionDefinitionName);
+ IO.mapOptional("AfterFunctionDeclarationName",
+ Spacing.AfterFunctionDeclarationName);
+ IO.mapOptional("AfterIfMacros", Spacing.AfterIfMacros);
+ IO.mapOptional("AfterOverloadedOperator", Spacing.AfterOverloadedOperator);
+ IO.mapOptional("AfterRequiresInClause", Spacing.AfterRequiresInClause);
+ IO.mapOptional("AfterRequiresInExpression",
+ Spacing.AfterRequiresInExpression);
+ IO.mapOptional("BeforeNonEmptyParentheses",
+ Spacing.BeforeNonEmptyParentheses);
}
};
@@ -597,47 +619,89 @@ struct ScalarEnumerationTraits<FormatStyle::SpaceBeforeParensStyle> {
}
};
-template <>
-struct ScalarEnumerationTraits<FormatStyle::BitFieldColonSpacingStyle> {
- static void enumeration(IO &IO,
- FormatStyle::BitFieldColonSpacingStyle &Value) {
- IO.enumCase(Value, "Both", FormatStyle::BFCS_Both);
- IO.enumCase(Value, "None", FormatStyle::BFCS_None);
- IO.enumCase(Value, "Before", FormatStyle::BFCS_Before);
- IO.enumCase(Value, "After", FormatStyle::BFCS_After);
+template <> struct ScalarEnumerationTraits<FormatStyle::SpacesInAnglesStyle> {
+ static void enumeration(IO &IO, FormatStyle::SpacesInAnglesStyle &Value) {
+ IO.enumCase(Value, "Never", FormatStyle::SIAS_Never);
+ IO.enumCase(Value, "Always", FormatStyle::SIAS_Always);
+ IO.enumCase(Value, "Leave", FormatStyle::SIAS_Leave);
+
+ // For backward compatibility.
+ IO.enumCase(Value, "false", FormatStyle::SIAS_Never);
+ IO.enumCase(Value, "true", FormatStyle::SIAS_Always);
}
};
-template <> struct ScalarEnumerationTraits<FormatStyle::SortIncludesOptions> {
- static void enumeration(IO &IO, FormatStyle::SortIncludesOptions &Value) {
- IO.enumCase(Value, "Never", FormatStyle::SI_Never);
- IO.enumCase(Value, "CaseInsensitive", FormatStyle::SI_CaseInsensitive);
- IO.enumCase(Value, "CaseSensitive", FormatStyle::SI_CaseSensitive);
+template <> struct MappingTraits<FormatStyle::SpacesInLineComment> {
+ static void mapping(IO &IO, FormatStyle::SpacesInLineComment &Space) {
+ // Transform the maximum to signed, to parse "-1" correctly
+ int signedMaximum = static_cast<int>(Space.Maximum);
+ IO.mapOptional("Minimum", Space.Minimum);
+ IO.mapOptional("Maximum", signedMaximum);
+ Space.Maximum = static_cast<unsigned>(signedMaximum);
- // For backward compatibility.
- IO.enumCase(Value, "false", FormatStyle::SI_Never);
- IO.enumCase(Value, "true", FormatStyle::SI_CaseSensitive);
+ if (Space.Maximum != -1u)
+ Space.Minimum = std::min(Space.Minimum, Space.Maximum);
+ }
+};
+
+template <> struct ScalarEnumerationTraits<FormatStyle::TrailingCommaStyle> {
+ static void enumeration(IO &IO, FormatStyle::TrailingCommaStyle &Value) {
+ IO.enumCase(Value, "None", FormatStyle::TCS_None);
+ IO.enumCase(Value, "Wrapped", FormatStyle::TCS_Wrapped);
}
};
template <>
-struct ScalarEnumerationTraits<FormatStyle::SortJavaStaticImportOptions> {
+struct ScalarEnumerationTraits<FormatStyle::TrailingCommentsAlignmentKinds> {
static void enumeration(IO &IO,
- FormatStyle::SortJavaStaticImportOptions &Value) {
- IO.enumCase(Value, "Before", FormatStyle::SJSIO_Before);
- IO.enumCase(Value, "After", FormatStyle::SJSIO_After);
+ FormatStyle::TrailingCommentsAlignmentKinds &Value) {
+ IO.enumCase(Value, "Leave", FormatStyle::TCAS_Leave);
+ IO.enumCase(Value, "Always", FormatStyle::TCAS_Always);
+ IO.enumCase(Value, "Never", FormatStyle::TCAS_Never);
}
};
-template <> struct ScalarEnumerationTraits<FormatStyle::SpacesInAnglesStyle> {
- static void enumeration(IO &IO, FormatStyle::SpacesInAnglesStyle &Value) {
- IO.enumCase(Value, "Never", FormatStyle::SIAS_Never);
- IO.enumCase(Value, "Always", FormatStyle::SIAS_Always);
- IO.enumCase(Value, "Leave", FormatStyle::SIAS_Leave);
+template <> struct MappingTraits<FormatStyle::TrailingCommentsAlignmentStyle> {
+ static void enumInput(IO &IO,
+ FormatStyle::TrailingCommentsAlignmentStyle &Value) {
+ IO.enumCase(Value, "Leave",
+ FormatStyle::TrailingCommentsAlignmentStyle(
+ {FormatStyle::TCAS_Leave, 1}));
- // For backward compatibility.
- IO.enumCase(Value, "false", FormatStyle::SIAS_Never);
- IO.enumCase(Value, "true", FormatStyle::SIAS_Always);
+ IO.enumCase(Value, "Always",
+ FormatStyle::TrailingCommentsAlignmentStyle(
+ {FormatStyle::TCAS_Always, 1}));
+
+ IO.enumCase(Value, "Never",
+ FormatStyle::TrailingCommentsAlignmentStyle(
+ {FormatStyle::TCAS_Never, 1}));
+
+ // For backwards compatibility
+ IO.enumCase(Value, "true",
+ FormatStyle::TrailingCommentsAlignmentStyle(
+ {FormatStyle::TCAS_Always, 1}));
+ IO.enumCase(Value, "false",
+ FormatStyle::TrailingCommentsAlignmentStyle(
+ {FormatStyle::TCAS_Never, 1}));
+ }
+
+ static void mapping(IO &IO,
+ FormatStyle::TrailingCommentsAlignmentStyle &Value) {
+ IO.mapOptional("Kind", Value.Kind);
+ IO.mapOptional("OverEmptyLines", Value.OverEmptyLines);
+ }
+};
+
+template <> struct ScalarEnumerationTraits<FormatStyle::UseTabStyle> {
+ static void enumeration(IO &IO, FormatStyle::UseTabStyle &Value) {
+ IO.enumCase(Value, "Never", FormatStyle::UT_Never);
+ IO.enumCase(Value, "false", FormatStyle::UT_Never);
+ IO.enumCase(Value, "Always", FormatStyle::UT_Always);
+ IO.enumCase(Value, "true", FormatStyle::UT_Always);
+ IO.enumCase(Value, "ForIndentation", FormatStyle::UT_ForIndentation);
+ IO.enumCase(Value, "ForContinuationAndIndentation",
+ FormatStyle::UT_ForContinuationAndIndentation);
+ IO.enumCase(Value, "AlignWithSpaces", FormatStyle::UT_AlignWithSpaces);
}
};
@@ -646,6 +710,7 @@ template <> struct MappingTraits<FormatStyle> {
// When reading, read the language first, we need it for getPredefinedStyle.
IO.mapOptional("Language", Style.Language);
+ StringRef BasedOnStyle;
if (IO.outputting()) {
StringRef Styles[] = {"LLVM", "Google", "Chromium", "Mozilla",
"WebKit", "GNU", "Microsoft"};
@@ -654,11 +719,11 @@ template <> struct MappingTraits<FormatStyle> {
if (getPredefinedStyle(StyleName, Style.Language, &PredefinedStyle) &&
Style == PredefinedStyle) {
IO.mapOptional("# BasedOnStyle", StyleName);
+ BasedOnStyle = StyleName;
break;
}
}
} else {
- StringRef BasedOnStyle;
IO.mapOptional("BasedOnStyle", BasedOnStyle);
if (!BasedOnStyle.empty()) {
FormatStyle::LanguageKind OldLanguage = Style.Language;
@@ -672,9 +737,35 @@ template <> struct MappingTraits<FormatStyle> {
}
}
+ // Initialize some variables used in the parsing. The using logic is at the
+ // end.
+
+ // For backward compatibility:
+ // The default value of ConstructorInitializerAllOnOneLineOrOnePerLine was
+ // false unless BasedOnStyle was Google or Chromium whereas that of
+ // AllowAllConstructorInitializersOnNextLine was always true, so the
+ // equivalent default value of PackConstructorInitializers is PCIS_NextLine
+ // for Google/Chromium or PCIS_BinPack otherwise. If the deprecated options
+ // had a non-default value while PackConstructorInitializers has a default
+ // value, set the latter to an equivalent non-default value if needed.
+ const bool IsGoogleOrChromium = BasedOnStyle.equals_insensitive("google") ||
+ BasedOnStyle.equals_insensitive("chromium");
+ bool OnCurrentLine = IsGoogleOrChromium;
+ bool OnNextLine = true;
+
+ bool BreakBeforeInheritanceComma = false;
+ bool BreakConstructorInitializersBeforeComma = false;
+
// For backward compatibility.
if (!IO.outputting()) {
IO.mapOptional("AlignEscapedNewlinesLeft", Style.AlignEscapedNewlines);
+ IO.mapOptional("AllowAllConstructorInitializersOnNextLine", OnNextLine);
+ IO.mapOptional("BreakBeforeInheritanceComma",
+ BreakBeforeInheritanceComma);
+ IO.mapOptional("BreakConstructorInitializersBeforeComma",
+ BreakConstructorInitializersBeforeComma);
+ IO.mapOptional("ConstructorInitializerAllOnOneLineOrOnePerLine",
+ OnCurrentLine);
IO.mapOptional("DerivePointerBinding", Style.DerivePointerAlignment);
IO.mapOptional("IndentFunctionDeclarationAfterType",
Style.IndentWrappedFunctionNames);
@@ -701,40 +792,24 @@ template <> struct MappingTraits<FormatStyle> {
Style.AllowAllArgumentsOnNextLine);
IO.mapOptional("AllowAllParametersOfDeclarationOnNextLine",
Style.AllowAllParametersOfDeclarationOnNextLine);
- IO.mapOptional("AllowShortEnumsOnASingleLine",
- Style.AllowShortEnumsOnASingleLine);
IO.mapOptional("AllowShortBlocksOnASingleLine",
Style.AllowShortBlocksOnASingleLine);
IO.mapOptional("AllowShortCaseLabelsOnASingleLine",
Style.AllowShortCaseLabelsOnASingleLine);
+ IO.mapOptional("AllowShortEnumsOnASingleLine",
+ Style.AllowShortEnumsOnASingleLine);
IO.mapOptional("AllowShortFunctionsOnASingleLine",
Style.AllowShortFunctionsOnASingleLine);
- IO.mapOptional("AllowShortLambdasOnASingleLine",
- Style.AllowShortLambdasOnASingleLine);
IO.mapOptional("AllowShortIfStatementsOnASingleLine",
Style.AllowShortIfStatementsOnASingleLine);
+ IO.mapOptional("AllowShortLambdasOnASingleLine",
+ Style.AllowShortLambdasOnASingleLine);
IO.mapOptional("AllowShortLoopsOnASingleLine",
Style.AllowShortLoopsOnASingleLine);
IO.mapOptional("AlwaysBreakAfterDefinitionReturnType",
Style.AlwaysBreakAfterDefinitionReturnType);
IO.mapOptional("AlwaysBreakAfterReturnType",
Style.AlwaysBreakAfterReturnType);
-
- // If AlwaysBreakAfterDefinitionReturnType was specified but
- // AlwaysBreakAfterReturnType was not, initialize the latter from the
- // former for backwards compatibility.
- if (Style.AlwaysBreakAfterDefinitionReturnType != FormatStyle::DRTBS_None &&
- Style.AlwaysBreakAfterReturnType == FormatStyle::RTBS_None) {
- if (Style.AlwaysBreakAfterDefinitionReturnType ==
- FormatStyle::DRTBS_All) {
- Style.AlwaysBreakAfterReturnType = FormatStyle::RTBS_AllDefinitions;
- } else if (Style.AlwaysBreakAfterDefinitionReturnType ==
- FormatStyle::DRTBS_TopLevel) {
- Style.AlwaysBreakAfterReturnType =
- FormatStyle::RTBS_TopLevelDefinitions;
- }
- }
-
IO.mapOptional("AlwaysBreakBeforeMultilineStrings",
Style.AlwaysBreakBeforeMultilineStrings);
IO.mapOptional("AlwaysBreakTemplateDeclarations",
@@ -742,56 +817,24 @@ template <> struct MappingTraits<FormatStyle> {
IO.mapOptional("AttributeMacros", Style.AttributeMacros);
IO.mapOptional("BinPackArguments", Style.BinPackArguments);
IO.mapOptional("BinPackParameters", Style.BinPackParameters);
+ IO.mapOptional("BitFieldColonSpacing", Style.BitFieldColonSpacing);
IO.mapOptional("BraceWrapping", Style.BraceWrapping);
+ IO.mapOptional("BreakAfterJavaFieldAnnotations",
+ Style.BreakAfterJavaFieldAnnotations);
+ IO.mapOptional("BreakArrays", Style.BreakArrays);
IO.mapOptional("BreakBeforeBinaryOperators",
Style.BreakBeforeBinaryOperators);
IO.mapOptional("BreakBeforeConceptDeclarations",
Style.BreakBeforeConceptDeclarations);
IO.mapOptional("BreakBeforeBraces", Style.BreakBeforeBraces);
-
- bool BreakBeforeInheritanceComma = false;
- IO.mapOptional("BreakBeforeInheritanceComma", BreakBeforeInheritanceComma);
- IO.mapOptional("BreakInheritanceList", Style.BreakInheritanceList);
- // If BreakBeforeInheritanceComma was specified but
- // BreakInheritance was not, initialize the latter from the
- // former for backwards compatibility.
- if (BreakBeforeInheritanceComma &&
- Style.BreakInheritanceList == FormatStyle::BILS_BeforeColon) {
- Style.BreakInheritanceList = FormatStyle::BILS_BeforeComma;
- }
-
IO.mapOptional("BreakBeforeTernaryOperators",
Style.BreakBeforeTernaryOperators);
-
- bool BreakConstructorInitializersBeforeComma = false;
- IO.mapOptional("BreakConstructorInitializersBeforeComma",
- BreakConstructorInitializersBeforeComma);
IO.mapOptional("BreakConstructorInitializers",
Style.BreakConstructorInitializers);
- // If BreakConstructorInitializersBeforeComma was specified but
- // BreakConstructorInitializers was not, initialize the latter from the
- // former for backwards compatibility.
- if (BreakConstructorInitializersBeforeComma &&
- Style.BreakConstructorInitializers == FormatStyle::BCIS_BeforeColon) {
- Style.BreakConstructorInitializers = FormatStyle::BCIS_BeforeComma;
- }
-
- IO.mapOptional("BreakAfterJavaFieldAnnotations",
- Style.BreakAfterJavaFieldAnnotations);
- IO.mapOptional("BreakArrays", Style.BreakArrays);
+ IO.mapOptional("BreakInheritanceList", Style.BreakInheritanceList);
IO.mapOptional("BreakStringLiterals", Style.BreakStringLiterals);
IO.mapOptional("ColumnLimit", Style.ColumnLimit);
IO.mapOptional("CommentPragmas", Style.CommentPragmas);
- IO.mapOptional("QualifierAlignment", Style.QualifierAlignment);
-
- // Default Order for Left/Right based Qualifier alignment.
- if (Style.QualifierAlignment == FormatStyle::QAS_Right)
- Style.QualifierOrder = {"type", "const", "volatile"};
- else if (Style.QualifierAlignment == FormatStyle::QAS_Left)
- Style.QualifierOrder = {"const", "volatile", "type"};
- else if (Style.QualifierAlignment == FormatStyle::QAS_Custom)
- IO.mapOptional("QualifierOrder", Style.QualifierOrder);
-
IO.mapOptional("CompactNamespaces", Style.CompactNamespaces);
IO.mapOptional("ConstructorInitializerIndentWidth",
Style.ConstructorInitializerIndentWidth);
@@ -806,56 +849,20 @@ template <> struct MappingTraits<FormatStyle> {
Style.EmptyLineBeforeAccessModifier);
IO.mapOptional("ExperimentalAutoDetectBinPacking",
Style.ExperimentalAutoDetectBinPacking);
-
- IO.mapOptional("PackConstructorInitializers",
- Style.PackConstructorInitializers);
- // For backward compatibility:
- // The default value of ConstructorInitializerAllOnOneLineOrOnePerLine was
- // false unless BasedOnStyle was Google or Chromium whereas that of
- // AllowAllConstructorInitializersOnNextLine was always true, so the
- // equivalent default value of PackConstructorInitializers is PCIS_NextLine
- // for Google/Chromium or PCIS_BinPack otherwise. If the deprecated options
- // had a non-default value while PackConstructorInitializers has a default
- // value, set the latter to an equivalent non-default value if needed.
- StringRef BasedOn;
- IO.mapOptional("BasedOnStyle", BasedOn);
- const bool IsGoogleOrChromium = BasedOn.equals_insensitive("google") ||
- BasedOn.equals_insensitive("chromium");
- bool OnCurrentLine = IsGoogleOrChromium;
- bool OnNextLine = true;
- IO.mapOptional("ConstructorInitializerAllOnOneLineOrOnePerLine",
- OnCurrentLine);
- IO.mapOptional("AllowAllConstructorInitializersOnNextLine", OnNextLine);
- if (!IsGoogleOrChromium) {
- if (Style.PackConstructorInitializers == FormatStyle::PCIS_BinPack &&
- OnCurrentLine) {
- Style.PackConstructorInitializers = OnNextLine
- ? FormatStyle::PCIS_NextLine
- : FormatStyle::PCIS_CurrentLine;
- }
- } else if (Style.PackConstructorInitializers ==
- FormatStyle::PCIS_NextLine) {
- if (!OnCurrentLine)
- Style.PackConstructorInitializers = FormatStyle::PCIS_BinPack;
- else if (!OnNextLine)
- Style.PackConstructorInitializers = FormatStyle::PCIS_CurrentLine;
- }
-
IO.mapOptional("FixNamespaceComments", Style.FixNamespaceComments);
IO.mapOptional("ForEachMacros", Style.ForEachMacros);
IO.mapOptional("IfMacros", Style.IfMacros);
-
IO.mapOptional("IncludeBlocks", Style.IncludeStyle.IncludeBlocks);
IO.mapOptional("IncludeCategories", Style.IncludeStyle.IncludeCategories);
IO.mapOptional("IncludeIsMainRegex", Style.IncludeStyle.IncludeIsMainRegex);
IO.mapOptional("IncludeIsMainSourceRegex",
Style.IncludeStyle.IncludeIsMainSourceRegex);
IO.mapOptional("IndentAccessModifiers", Style.IndentAccessModifiers);
- IO.mapOptional("IndentCaseLabels", Style.IndentCaseLabels);
IO.mapOptional("IndentCaseBlocks", Style.IndentCaseBlocks);
+ IO.mapOptional("IndentCaseLabels", Style.IndentCaseLabels);
+ IO.mapOptional("IndentExternBlock", Style.IndentExternBlock);
IO.mapOptional("IndentGotoLabels", Style.IndentGotoLabels);
IO.mapOptional("IndentPPDirectives", Style.IndentPPDirectives);
- IO.mapOptional("IndentExternBlock", Style.IndentExternBlock);
IO.mapOptional("IndentRequiresClause", Style.IndentRequiresClause);
IO.mapOptional("IndentWidth", Style.IndentWidth);
IO.mapOptional("IndentWrappedFunctionNames",
@@ -880,6 +887,8 @@ template <> struct MappingTraits<FormatStyle> {
IO.mapOptional("ObjCSpaceAfterProperty", Style.ObjCSpaceAfterProperty);
IO.mapOptional("ObjCSpaceBeforeProtocolList",
Style.ObjCSpaceBeforeProtocolList);
+ IO.mapOptional("PackConstructorInitializers",
+ Style.PackConstructorInitializers);
IO.mapOptional("PenaltyBreakAssignment", Style.PenaltyBreakAssignment);
IO.mapOptional("PenaltyBreakBeforeFirstCallParameter",
Style.PenaltyBreakBeforeFirstCallParameter);
@@ -892,12 +901,20 @@ template <> struct MappingTraits<FormatStyle> {
IO.mapOptional("PenaltyBreakTemplateDeclaration",
Style.PenaltyBreakTemplateDeclaration);
IO.mapOptional("PenaltyExcessCharacter", Style.PenaltyExcessCharacter);
- IO.mapOptional("PenaltyReturnTypeOnItsOwnLine",
- Style.PenaltyReturnTypeOnItsOwnLine);
IO.mapOptional("PenaltyIndentedWhitespace",
Style.PenaltyIndentedWhitespace);
+ IO.mapOptional("PenaltyReturnTypeOnItsOwnLine",
+ Style.PenaltyReturnTypeOnItsOwnLine);
IO.mapOptional("PointerAlignment", Style.PointerAlignment);
IO.mapOptional("PPIndentWidth", Style.PPIndentWidth);
+ IO.mapOptional("QualifierAlignment", Style.QualifierAlignment);
+ // Default Order for Left/Right based Qualifier alignment.
+ if (Style.QualifierAlignment == FormatStyle::QAS_Right)
+ Style.QualifierOrder = {"type", "const", "volatile"};
+ else if (Style.QualifierAlignment == FormatStyle::QAS_Left)
+ Style.QualifierOrder = {"const", "volatile", "type"};
+ else if (Style.QualifierAlignment == FormatStyle::QAS_Custom)
+ IO.mapOptional("QualifierOrder", Style.QualifierOrder);
IO.mapOptional("RawStringFormats", Style.RawStringFormats);
IO.mapOptional("ReferenceAlignment", Style.ReferenceAlignment);
IO.mapOptional("ReflowComments", Style.ReflowComments);
@@ -915,6 +932,8 @@ template <> struct MappingTraits<FormatStyle> {
IO.mapOptional("SpaceAfterLogicalNot", Style.SpaceAfterLogicalNot);
IO.mapOptional("SpaceAfterTemplateKeyword",
Style.SpaceAfterTemplateKeyword);
+ IO.mapOptional("SpaceAroundPointerQualifiers",
+ Style.SpaceAroundPointerQualifiers);
IO.mapOptional("SpaceBeforeAssignmentOperators",
Style.SpaceBeforeAssignmentOperators);
IO.mapOptional("SpaceBeforeCaseColon", Style.SpaceBeforeCaseColon);
@@ -926,10 +945,10 @@ template <> struct MappingTraits<FormatStyle> {
Style.SpaceBeforeInheritanceColon);
IO.mapOptional("SpaceBeforeParens", Style.SpaceBeforeParens);
IO.mapOptional("SpaceBeforeParensOptions", Style.SpaceBeforeParensOptions);
- IO.mapOptional("SpaceAroundPointerQualifiers",
- Style.SpaceAroundPointerQualifiers);
IO.mapOptional("SpaceBeforeRangeBasedForLoopColon",
Style.SpaceBeforeRangeBasedForLoopColon);
+ IO.mapOptional("SpaceBeforeSquareBrackets",
+ Style.SpaceBeforeSquareBrackets);
IO.mapOptional("SpaceInEmptyBlock", Style.SpaceInEmptyBlock);
IO.mapOptional("SpaceInEmptyParentheses", Style.SpaceInEmptyParentheses);
IO.mapOptional("SpacesBeforeTrailingComments",
@@ -945,9 +964,6 @@ template <> struct MappingTraits<FormatStyle> {
Style.SpacesInLineCommentPrefix);
IO.mapOptional("SpacesInParentheses", Style.SpacesInParentheses);
IO.mapOptional("SpacesInSquareBrackets", Style.SpacesInSquareBrackets);
- IO.mapOptional("SpaceBeforeSquareBrackets",
- Style.SpaceBeforeSquareBrackets);
- IO.mapOptional("BitFieldColonSpacing", Style.BitFieldColonSpacing);
IO.mapOptional("Standard", Style.Standard);
IO.mapOptional("StatementAttributeLikeMacros",
Style.StatementAttributeLikeMacros);
@@ -958,70 +974,51 @@ template <> struct MappingTraits<FormatStyle> {
IO.mapOptional("UseTab", Style.UseTab);
IO.mapOptional("WhitespaceSensitiveMacros",
Style.WhitespaceSensitiveMacros);
- }
-};
-
-template <> struct MappingTraits<FormatStyle::BraceWrappingFlags> {
- static void mapping(IO &IO, FormatStyle::BraceWrappingFlags &Wrapping) {
- IO.mapOptional("AfterCaseLabel", Wrapping.AfterCaseLabel);
- IO.mapOptional("AfterClass", Wrapping.AfterClass);
- IO.mapOptional("AfterControlStatement", Wrapping.AfterControlStatement);
- IO.mapOptional("AfterEnum", Wrapping.AfterEnum);
- IO.mapOptional("AfterFunction", Wrapping.AfterFunction);
- IO.mapOptional("AfterNamespace", Wrapping.AfterNamespace);
- IO.mapOptional("AfterObjCDeclaration", Wrapping.AfterObjCDeclaration);
- IO.mapOptional("AfterStruct", Wrapping.AfterStruct);
- IO.mapOptional("AfterUnion", Wrapping.AfterUnion);
- IO.mapOptional("AfterExternBlock", Wrapping.AfterExternBlock);
- IO.mapOptional("BeforeCatch", Wrapping.BeforeCatch);
- IO.mapOptional("BeforeElse", Wrapping.BeforeElse);
- IO.mapOptional("BeforeLambdaBody", Wrapping.BeforeLambdaBody);
- IO.mapOptional("BeforeWhile", Wrapping.BeforeWhile);
- IO.mapOptional("IndentBraces", Wrapping.IndentBraces);
- IO.mapOptional("SplitEmptyFunction", Wrapping.SplitEmptyFunction);
- IO.mapOptional("SplitEmptyRecord", Wrapping.SplitEmptyRecord);
- IO.mapOptional("SplitEmptyNamespace", Wrapping.SplitEmptyNamespace);
- }
-};
-template <> struct MappingTraits<FormatStyle::SpaceBeforeParensCustom> {
- static void mapping(IO &IO, FormatStyle::SpaceBeforeParensCustom &Spacing) {
- IO.mapOptional("AfterControlStatements", Spacing.AfterControlStatements);
- IO.mapOptional("AfterForeachMacros", Spacing.AfterForeachMacros);
- IO.mapOptional("AfterFunctionDefinitionName",
- Spacing.AfterFunctionDefinitionName);
- IO.mapOptional("AfterFunctionDeclarationName",
- Spacing.AfterFunctionDeclarationName);
- IO.mapOptional("AfterIfMacros", Spacing.AfterIfMacros);
- IO.mapOptional("AfterOverloadedOperator", Spacing.AfterOverloadedOperator);
- IO.mapOptional("AfterRequiresInClause", Spacing.AfterRequiresInClause);
- IO.mapOptional("AfterRequiresInExpression",
- Spacing.AfterRequiresInExpression);
- IO.mapOptional("BeforeNonEmptyParentheses",
- Spacing.BeforeNonEmptyParentheses);
- }
-};
+ // If AlwaysBreakAfterDefinitionReturnType was specified but
+ // AlwaysBreakAfterReturnType was not, initialize the latter from the
+ // former for backwards compatibility.
+ if (Style.AlwaysBreakAfterDefinitionReturnType != FormatStyle::DRTBS_None &&
+ Style.AlwaysBreakAfterReturnType == FormatStyle::RTBS_None) {
+ if (Style.AlwaysBreakAfterDefinitionReturnType ==
+ FormatStyle::DRTBS_All) {
+ Style.AlwaysBreakAfterReturnType = FormatStyle::RTBS_AllDefinitions;
+ } else if (Style.AlwaysBreakAfterDefinitionReturnType ==
+ FormatStyle::DRTBS_TopLevel) {
+ Style.AlwaysBreakAfterReturnType =
+ FormatStyle::RTBS_TopLevelDefinitions;
+ }
+ }
-template <> struct MappingTraits<FormatStyle::RawStringFormat> {
- static void mapping(IO &IO, FormatStyle::RawStringFormat &Format) {
- IO.mapOptional("Language", Format.Language);
- IO.mapOptional("Delimiters", Format.Delimiters);
- IO.mapOptional("EnclosingFunctions", Format.EnclosingFunctions);
- IO.mapOptional("CanonicalDelimiter", Format.CanonicalDelimiter);
- IO.mapOptional("BasedOnStyle", Format.BasedOnStyle);
- }
-};
+ // If BreakBeforeInheritanceComma was specified but BreakInheritance was
+ // not, initialize the latter from the former for backwards compatibility.
+ if (BreakBeforeInheritanceComma &&
+ Style.BreakInheritanceList == FormatStyle::BILS_BeforeColon) {
+ Style.BreakInheritanceList = FormatStyle::BILS_BeforeComma;
+ }
-template <> struct MappingTraits<FormatStyle::SpacesInLineComment> {
- static void mapping(IO &IO, FormatStyle::SpacesInLineComment &Space) {
- // Transform the maximum to signed, to parse "-1" correctly
- int signedMaximum = static_cast<int>(Space.Maximum);
- IO.mapOptional("Minimum", Space.Minimum);
- IO.mapOptional("Maximum", signedMaximum);
- Space.Maximum = static_cast<unsigned>(signedMaximum);
+ // If BreakConstructorInitializersBeforeComma was specified but
+ // BreakConstructorInitializers was not, initialize the latter from the
+ // former for backwards compatibility.
+ if (BreakConstructorInitializersBeforeComma &&
+ Style.BreakConstructorInitializers == FormatStyle::BCIS_BeforeColon) {
+ Style.BreakConstructorInitializers = FormatStyle::BCIS_BeforeComma;
+ }
- if (Space.Maximum != -1u)
- Space.Minimum = std::min(Space.Minimum, Space.Maximum);
+ if (!IsGoogleOrChromium) {
+ if (Style.PackConstructorInitializers == FormatStyle::PCIS_BinPack &&
+ OnCurrentLine) {
+ Style.PackConstructorInitializers = OnNextLine
+ ? FormatStyle::PCIS_NextLine
+ : FormatStyle::PCIS_CurrentLine;
+ }
+ } else if (Style.PackConstructorInitializers ==
+ FormatStyle::PCIS_NextLine) {
+ if (!OnCurrentLine)
+ Style.PackConstructorInitializers = FormatStyle::PCIS_BinPack;
+ else if (!OnNextLine)
+ Style.PackConstructorInitializers = FormatStyle::PCIS_CurrentLine;
+ }
}
};
@@ -1249,10 +1246,10 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind Language) {
LLVMStyle.AlignTrailingComments.OverEmptyLines = 0;
LLVMStyle.AllowAllArgumentsOnNextLine = true;
LLVMStyle.AllowAllParametersOfDeclarationOnNextLine = true;
- LLVMStyle.AllowShortEnumsOnASingleLine = true;
- LLVMStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_All;
LLVMStyle.AllowShortBlocksOnASingleLine = FormatStyle::SBS_Never;
LLVMStyle.AllowShortCaseLabelsOnASingleLine = false;
+ LLVMStyle.AllowShortEnumsOnASingleLine = true;
+ LLVMStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_All;
LLVMStyle.AllowShortIfStatementsOnASingleLine = FormatStyle::SIS_Never;
LLVMStyle.AllowShortLambdasOnASingleLine = FormatStyle::SLS_All;
LLVMStyle.AllowShortLoopsOnASingleLine = false;
@@ -1263,6 +1260,7 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind Language) {
LLVMStyle.AttributeMacros.push_back("__capability");
LLVMStyle.BinPackArguments = true;
LLVMStyle.BinPackParameters = true;
+ LLVMStyle.BreakArrays = true;
LLVMStyle.BreakBeforeBinaryOperators = FormatStyle::BOS_None;
LLVMStyle.BreakBeforeConceptDeclarations = FormatStyle::BBCDS_Always;
LLVMStyle.BreakBeforeTernaryOperators = true;
@@ -1285,7 +1283,7 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind Language) {
/*SplitEmptyFunction=*/true,
/*SplitEmptyRecord=*/true,
/*SplitEmptyNamespace=*/true};
- LLVMStyle.IndentExternBlock = FormatStyle::IEBS_AfterExternBlock;
+ LLVMStyle.BitFieldColonSpacing = FormatStyle::BFCS_Both;
LLVMStyle.BreakAfterJavaFieldAnnotations = false;
LLVMStyle.BreakConstructorInitializers = FormatStyle::BCIS_BeforeColon;
LLVMStyle.BreakInheritanceList = FormatStyle::BILS_BeforeColon;
@@ -1296,17 +1294,12 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind Language) {
LLVMStyle.ConstructorInitializerIndentWidth = 4;
LLVMStyle.ContinuationIndentWidth = 4;
LLVMStyle.Cpp11BracedListStyle = true;
-
- // Off by default Qualifier ordering
- LLVMStyle.QualifierAlignment = FormatStyle::QAS_Leave;
-
LLVMStyle.DeriveLineEnding = true;
LLVMStyle.DerivePointerAlignment = false;
+ LLVMStyle.DisableFormat = false;
LLVMStyle.EmptyLineAfterAccessModifier = FormatStyle::ELAAMS_Never;
LLVMStyle.EmptyLineBeforeAccessModifier = FormatStyle::ELBAMS_LogicalBlock;
LLVMStyle.ExperimentalAutoDetectBinPacking = false;
- LLVMStyle.BreakArrays = true;
- LLVMStyle.PackConstructorInitializers = FormatStyle::PCIS_BinPack;
LLVMStyle.FixNamespaceComments = true;
LLVMStyle.ForEachMacros.push_back("foreach");
LLVMStyle.ForEachMacros.push_back("Q_FOREACH");
@@ -1321,46 +1314,40 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind Language) {
LLVMStyle.IndentAccessModifiers = false;
LLVMStyle.IndentCaseLabels = false;
LLVMStyle.IndentCaseBlocks = false;
+ LLVMStyle.IndentExternBlock = FormatStyle::IEBS_AfterExternBlock;
LLVMStyle.IndentGotoLabels = true;
LLVMStyle.IndentPPDirectives = FormatStyle::PPDIS_None;
LLVMStyle.IndentRequiresClause = true;
- LLVMStyle.IndentWrappedFunctionNames = false;
LLVMStyle.IndentWidth = 2;
- LLVMStyle.PPIndentWidth = -1;
+ LLVMStyle.IndentWrappedFunctionNames = false;
LLVMStyle.InsertBraces = false;
LLVMStyle.InsertTrailingCommas = FormatStyle::TCS_None;
LLVMStyle.JavaScriptQuotes = FormatStyle::JSQS_Leave;
LLVMStyle.JavaScriptWrapImports = true;
- LLVMStyle.TabWidth = 8;
+ LLVMStyle.KeepEmptyLinesAtTheStartOfBlocks = true;
LLVMStyle.LambdaBodyIndentation = FormatStyle::LBI_Signature;
LLVMStyle.MaxEmptyLinesToKeep = 1;
- LLVMStyle.KeepEmptyLinesAtTheStartOfBlocks = true;
LLVMStyle.NamespaceIndentation = FormatStyle::NI_None;
LLVMStyle.ObjCBinPackProtocolList = FormatStyle::BPS_Auto;
LLVMStyle.ObjCBlockIndentWidth = 2;
LLVMStyle.ObjCBreakBeforeNestedBlockParam = true;
LLVMStyle.ObjCSpaceAfterProperty = false;
LLVMStyle.ObjCSpaceBeforeProtocolList = true;
+ LLVMStyle.PackConstructorInitializers = FormatStyle::PCIS_BinPack;
LLVMStyle.PointerAlignment = FormatStyle::PAS_Right;
+ LLVMStyle.PPIndentWidth = -1;
+ LLVMStyle.QualifierAlignment = FormatStyle::QAS_Leave;
LLVMStyle.ReferenceAlignment = FormatStyle::RAS_Pointer;
+ LLVMStyle.ReflowComments = true;
+ LLVMStyle.RemoveBracesLLVM = false;
+ LLVMStyle.RemoveSemicolon = false;
LLVMStyle.RequiresClausePosition = FormatStyle::RCPS_OwnLine;
LLVMStyle.RequiresExpressionIndentation = FormatStyle::REI_OuterScope;
LLVMStyle.SeparateDefinitionBlocks = FormatStyle::SDS_Leave;
LLVMStyle.ShortNamespaceLines = 1;
- LLVMStyle.SpacesBeforeTrailingComments = 1;
- LLVMStyle.Standard = FormatStyle::LS_Latest;
- LLVMStyle.UseCRLF = false;
- LLVMStyle.UseTab = FormatStyle::UT_Never;
- LLVMStyle.ReflowComments = true;
- LLVMStyle.RemoveBracesLLVM = false;
- LLVMStyle.RemoveSemicolon = false;
- LLVMStyle.SpacesInParentheses = false;
- LLVMStyle.SpacesInSquareBrackets = false;
- LLVMStyle.SpaceInEmptyBlock = false;
- LLVMStyle.SpaceInEmptyParentheses = false;
- LLVMStyle.SpacesInContainerLiterals = true;
- LLVMStyle.SpacesInCStyleCastParentheses = false;
- LLVMStyle.SpacesInLineCommentPrefix = {/*Minimum=*/1, /*Maximum=*/-1u};
+ LLVMStyle.SortIncludes = FormatStyle::SI_CaseSensitive;
+ LLVMStyle.SortJavaStaticImport = FormatStyle::SJSIO_Before;
+ LLVMStyle.SortUsingDeclarations = true;
LLVMStyle.SpaceAfterCStyleCast = false;
LLVMStyle.SpaceAfterLogicalNot = false;
LLVMStyle.SpaceAfterTemplateKeyword = true;
@@ -1377,9 +1364,28 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind Language) {
LLVMStyle.SpaceBeforeAssignmentOperators = true;
LLVMStyle.SpaceBeforeCpp11BracedList = false;
LLVMStyle.SpaceBeforeSquareBrackets = false;
- LLVMStyle.BitFieldColonSpacing = FormatStyle::BFCS_Both;
+ LLVMStyle.SpaceInEmptyBlock = false;
+ LLVMStyle.SpaceInEmptyParentheses = false;
+ LLVMStyle.SpacesBeforeTrailingComments = 1;
LLVMStyle.SpacesInAngles = FormatStyle::SIAS_Never;
+ LLVMStyle.SpacesInContainerLiterals = true;
+ LLVMStyle.SpacesInCStyleCastParentheses = false;
+ LLVMStyle.SpacesInLineCommentPrefix = {/*Minimum=*/1, /*Maximum=*/-1u};
+ LLVMStyle.SpacesInParentheses = false;
+ LLVMStyle.SpacesInSquareBrackets = false;
LLVMStyle.SpacesInConditionalStatement = false;
+ LLVMStyle.Standard = FormatStyle::LS_Latest;
+ LLVMStyle.StatementAttributeLikeMacros.push_back("Q_EMIT");
+ LLVMStyle.StatementMacros.push_back("Q_UNUSED");
+ LLVMStyle.StatementMacros.push_back("QT_REQUIRE_VERSION");
+ LLVMStyle.TabWidth = 8;
+ LLVMStyle.UseCRLF = false;
+ LLVMStyle.UseTab = FormatStyle::UT_Never;
+ LLVMStyle.WhitespaceSensitiveMacros.push_back("BOOST_PP_STRINGIZE");
+ LLVMStyle.WhitespaceSensitiveMacros.push_back("CF_SWIFT_NAME");
+ LLVMStyle.WhitespaceSensitiveMacros.push_back("NS_SWIFT_NAME");
+ LLVMStyle.WhitespaceSensitiveMacros.push_back("PP_STRINGIZE");
+ LLVMStyle.WhitespaceSensitiveMacros.push_back("STRINGIZE");
LLVMStyle.PenaltyBreakAssignment = prec::Assignment;
LLVMStyle.PenaltyBreakComment = 300;
@@ -1392,19 +1398,6 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind Language) {
LLVMStyle.PenaltyBreakTemplateDeclaration = prec::Relational;
LLVMStyle.PenaltyIndentedWhitespace = 0;
- LLVMStyle.DisableFormat = false;
- LLVMStyle.SortIncludes = FormatStyle::SI_CaseSensitive;
- LLVMStyle.SortJavaStaticImport = FormatStyle::SJSIO_Before;
- LLVMStyle.SortUsingDeclarations = true;
- LLVMStyle.StatementAttributeLikeMacros.push_back("Q_EMIT");
- LLVMStyle.StatementMacros.push_back("Q_UNUSED");
- LLVMStyle.StatementMacros.push_back("QT_REQUIRE_VERSION");
- LLVMStyle.WhitespaceSensitiveMacros.push_back("STRINGIZE");
- LLVMStyle.WhitespaceSensitiveMacros.push_back("PP_STRINGIZE");
- LLVMStyle.WhitespaceSensitiveMacros.push_back("BOOST_PP_STRINGIZE");
- LLVMStyle.WhitespaceSensitiveMacros.push_back("NS_SWIFT_NAME");
- LLVMStyle.WhitespaceSensitiveMacros.push_back("CF_SWIFT_NAME");
-
// Defaults that
diff er when not C++.
switch (Language) {
case FormatStyle::LK_TableGen:
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index acf172ea98d9d..5979c31777339 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -23320,7 +23320,10 @@ TEST(FormatStyle, GetStyleOfFile) {
llvm::MemoryBuffer::getMemBuffer(
"BasedOnStyle: InheritParentConfig\n"
"WhitespaceSensitiveMacros: ['FOO', 'BAR']")));
- std::vector<std::string> NonDefaultWhiteSpaceMacros{"FOO", "BAR"};
+ std::vector<std::string> NonDefaultWhiteSpaceMacros =
+ Style9->WhitespaceSensitiveMacros;
+ NonDefaultWhiteSpaceMacros[0] = "FOO";
+ NonDefaultWhiteSpaceMacros[1] = "BAR";
ASSERT_NE(Style9->WhitespaceSensitiveMacros, NonDefaultWhiteSpaceMacros);
Style9 = getStyle("file", "/e/sub/sub/code.cpp", "none", "", &FS);
@@ -23376,8 +23379,8 @@ TEST(FormatStyle, GetStyleOfFile) {
ASSERT_EQ(*Style9, SubSubStyle);
// Test 9.6: use command line style with inheritance
- Style9 = getStyle("{BasedOnStyle: InheritParentConfig}", "/e/sub/code.cpp",
- "none", "", &FS);
+ Style9 = getStyle("{BasedOnStyle: InheritParentConfig}",
+ "/e/sub/sub/code.cpp", "none", "", &FS);
ASSERT_TRUE(static_cast<bool>(Style9));
ASSERT_EQ(*Style9, SubSubStyle);
More information about the cfe-commits
mailing list