alandefreitas / clang-unformat

A simple tool to infer a .clang-format file from existing code
Boost Software License 1.0
58 stars 13 forks source link

Something went wrong when uploading a .clang-foramt file #18

Open tonyho opened 8 months ago

tonyho commented 8 months ago

I use clang 16.0.0 with this master code, and built it locally.

When I upload a .clang-format file(this one), the front UI shows :

Something went wrong:
Clang-format returned non zero code
<command-line>:18:7: error: unknown key '10'
      "10": 'e',
      ^~~~
Error parsing -style: Invalid argument

The server has the following log:

DEBU[502286] Start formatting
version:16.0.0
filenameExt: .cpp
Code:
 #include <iostream>
// IndentPPDirectives
#ifdef WIN32
#include <windows.h>
#endif
// SortIncludes
#include "AnotherHeader.h"
#include "MyHeader.h"
#include <boost/asio/io_context.hpp>
#include <boost/asio/ip/tcp.hpp>
#include <boost/asio/signal_set.hpp>
#include <boost/asio/write.hpp>
#include <map>
#include <string>
#include <vector>

// AlignConsecutiveMacros
#define SHORT_NAME 42
#define LONGER_NAME 0x007f
#define EVEN_LONGER_NAME (2)
#define fooo(x) (x * x)
#define baar(y, z) (y + z)

// AlignEscapedNewlines
#define PPP                                                                    \
  int aaaa;                                                                    \
  int b;                                                                       \
  int dddddddddd;

namespace LevelOneNamespace {
namespace LevelTwoNamespace {

struct AAAAAAAAAAAAAAAAAAAA {
  // AlignConsecutiveDeclarations
  int a;
  int bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb;
  std::string cccccccccccccccccc;
};

// AlwaysBreakTemplateDeclarations
template <typename T> T foo() {}

template <typename T>
T foo(int aaaaaaaaaaaaaaaaaaaaa, int bbbbbbbbbbbbbbbbbbbbb) {}

// AllowShortEnumsOnASingleLine
enum : unsigned int { AA = 0, BB } myEnum;

// SpaceBeforeInheritanceColon
class B : public E {
private:
  // AlignArrayOfStructures
  struct AAAAAAAAAAAAAAAAAAAA test[3] = {
      {56, 23, "hello"}, {-1, 93463, "world"}, {7, 5, "!!"}};

  // AlignTrailingComments, AlignConsecutiveDeclarations, QualifierOrder,
  // QualifierAlignment, AlignTrailingComments
  static char const *variable; // very important variable
  void *const *x = nullptr;    // not so important variable
  char const *anotherVariable; // another comment
  int a = 1;                   // another variable
  // used for this, this, and that
  int longComplicatedName = 4;
  int b = 3;

protected:
  // AlwaysBreakAfterReturnType, QualifierAlignment
  constexpr static inline int function(int a, int b) { return (a + b) / 2; }

  // AllowShortFunctionsOnASingleLine
  static bool shortFilter(AAAAAAAAAAAAAAAAAAAA v) { return v.a != 4; }

  void empty() {}

  // IndentWrappedFunctionNames
  std::map<std::basic_string<wchar_t>, std::vector<std::pair<char, int>>>
  func(AAAAAAAAAAAAAAAAAAAA *v);

public:
  // SpaceBeforeCtorInitializerColon
  explicit B() : a(9){};

  // PackConstructorInitializers
  explicit B(int _a, int _b, int _c, std::vector<std::string> str)
      : a(_a), b(_b), longComplicatedName(_c), anotherVariable(str[0].c_str()) {
    // AllowShortIfStatementsOnASingleLine, SpaceBeforeParens
    if (_c)
      anotherVariable = nullptr;
    if (_a)
      anotherVariable = "baz";
    else
      anotherVariable = "bar";
  }

  // AllowAllParametersOfDeclarationOnNextLine BinPackParameters
  int myFunction(int aaaaaaaaaaaaa, int bbbbbbbbbbbbbbbbbbbbbbb,
                 int ccccccccccccc, int d, int e) {
    int myvar = aaaaaaaaaaaaa / 10;
    long anothervaw = d % 2;
    // comment
    char *msg = "Hello all";

    // AlignOperands
    myvar = bbbbbbbbbbbbbbbbbbbbbbb + ccccccccccccc + aaaaaaaaaaaaa;

    // AllowShortCaseLabelsOnASingleLine, SpaceBeforeParens
    switch (e) {
    case 1:
      return e;
    case 2:
      return 2;
    };

    // AllowShortBlocksOnASingleLine, SpaceBeforeParens
    while (true) {
    }
    while (true) {
      continue;
    }
  }

  // AlignAfterOpenBracket, BinPackParameters,
  void loooonFunctionIsVeryLongButNotAsLongAsJavaTypeNames(
      std::vector<AAAAAAAAAAAAAAAAAAAA> const &inputVector,
      std::map<int, std::string> *outputMap) {
    std::vector<AAAAAAAAAAAAAAAAAAAA> bar;
    std::copy_if(inputVector.begin(), inputVector.end(),
                 std::back_inserter(bar), &shortFilter);
    // AllowShortLambdasOnASingleLine
    std::sort(inputVector.begin(), inputVector.end(),
              [](auto v) { return v.a < v.b; });
    std::transform(inputVector.begin(), inputVector.end(),
                   std::inserter(*outputMap, outputMap->end()),
                   [](const AAAAAAAAAAAAAAAAAAAA &element) {
                     // LambdaBodyIndentation
                     return std::make_pair(
                         element.bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
                         element.cccccccccccccccccc);
                   });
  };
  int notInline(AAAAAAAAAAAAAAAAAAAA *v);
};

// AllowShortFunctionsOnASingleLine
int notInline(AAAAAAAAAAAAAAAAAAAA *v) { return v->a + 1; }

} // namespace LevelTwoNamespace
} // namespace LevelOneNamespace

int main() {
  // ReflowComments
  // veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of
  // information
  /* second veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty
   * of information */

  // SortUsingDeclarations
  using std::cin;
  using std::cout;

  int aaaaaaaaaaaaaaaaaaa, bbbbbbbbbbb, ppppppppppp, eeeee;
  // AlignConsecutiveAssignments
  aaaaaaaaaaaaaaaaaaa = 6;
  bbbbbbbbbbb = 5;
  ppppppppppp = 10;
  LevelOneNamespace::LevelTwoNamespace::B b{
      1, 3, 4,
      // SpaceBeforeCpp11BracedList
      std::vector<std::string>{"aaaaaaaaaaaaaaaa", "bbbbbbbbbbbbbbbbbbbbbb",
                               "cccccccccccccccccccccccccccc"}};
  // AllowShortLoopsOnASingleLine
  for (int i = 0; i < 10; i++)
    cout << i;
  LevelOneNamespace::LevelTwoNamespace::AAAAAAAAAAAAAAAAAAAA
      ddddddddddddddddddddddddd{5, 5, "ff"};
  b.notInline(ddddddddddddddddddddddddd);
  // SpaceAfterCStyleCast, AllowAllArgumentsOnNextLine
  cout << (bool)b.myFunction(aaaaaaaaaaaaaaaaaaa, bbbbbbbbbbb, ppppppppppp,
                             eeeee, 0);

  return 0;
}

Style:
{
  BasedOnStyle: 'LLVM',
  AccessModifierOffset: '-8',
  AlignAfterOpenBracket: 'Align',
  AlignArrayOfStructures: 'Right',
  AlignConsecutiveAssignments:
    {
      "0": 'C',
      "1": 'o',
      "2": 'n',
      "3": 's',
      "4": 'e',
      "5": 'c',
      "6": 'u',
      "7": 't',
      "8": 'i',
      "9": 'v',
      "10": 'e',
      Enabled: 'false',
      AcrossEmptyLines: 'false',
      AcrossComments: 'false',
      AlignCompound: 'false',
      PadOperators: 'true'
    },
  AlignConsecutiveBitFields:
    {
      "0": 'C',
      "1": 'o',
      "2": 'n',
      "3": 's',
      "4": 'e',
      "5": 'c',
      "6": 'u',
      "7": 't',
      "8": 'i',
      "9": 'v',
      "10": 'e',
      Enabled: 'false',
      AcrossEmptyLines: 'false',
      AcrossComments: 'false',
      AlignCompound: 'false',
      PadOperators: 'false'
    },
  AlignConsecutiveDeclarations:
    {
      "0": 'C',
      "1": 'o',
      "2": 'n',
      "3": 's',
      "4": 'e',
      "5": 'c',
      "6": 'u',
      "7": 't',
      "8": 'i',
      "9": 'v',
      "10": 'e',
      Enabled: 'false',
      AcrossEmptyLines: 'false',
      AcrossComments: 'false',
      AlignCompound: 'false',
      PadOperators: 'false'
    },
  AlignConsecutiveMacros:
    {
      "0": 'C',
      "1": 'o',
      "2": 'n',
      "3": 's',
      "4": 'e',
      "5": 'c',
      "6": 'u',
      "7": 't',
      "8": 'i',
      "9": 'v',
      "10": 'e',
      Enabled: 'false',
      AcrossEmptyLines: 'false',
      AcrossComments: 'false',
      AlignCompound: 'false',
      PadOperators: 'false'
    },
  AlignEscapedNewlines: 'Right',
  AlignOperands: 'DontAlign',
  AlignTrailingComments: { Kind: 'Always', OverEmptyLines: '0' },
  AllowAllArgumentsOnNextLine: 'true',
  AllowAllParametersOfDeclarationOnNextLine: 'true',
  AllowShortBlocksOnASingleLine: 'Never',
  AllowShortCaseLabelsOnASingleLine: 'true',
  AllowShortEnumsOnASingleLine: 'true',
  AllowShortFunctionsOnASingleLine: 'None',
  AllowShortIfStatementsOnASingleLine: 'Never',
  AllowShortLambdasOnASingleLine: 'None',
  AllowShortLoopsOnASingleLine: 'true',
  AlwaysBreakAfterDefinitionReturnType: 'All',
  AlwaysBreakAfterReturnType: 'All',
  AlwaysBreakBeforeMultilineStrings: 'true',
  AlwaysBreakTemplateDeclarations: 'Yes',
  AttributeMacros: [ '__capability' ],
  BinPackArguments: 'true',
  BinPackParameters: 'true',
  BitFieldColonSpacing: 'Both',
  BraceWrapping:
    {
      AfterCaseLabel: 'true',
      AfterClass: 'true',
      AfterControlStatement: 'Never',
      AfterEnum: 'true',
      AfterFunction: 'true',
      AfterNamespace: 'true',
      AfterObjCDeclaration: 'true',
      AfterStruct: 'true',
      AfterUnion: 'true',
      AfterExternBlock: 'true',
      BeforeCatch: 'true',
      BeforeElse: 'true',
      BeforeLambdaBody: 'true',
      BeforeWhile: 'true',
      IndentBraces: 'true',
      SplitEmptyFunction: 'true',
      SplitEmptyRecord: 'true',
      SplitEmptyNamespace: 'true'
    },
  BreakAfterAttributes: 'Never',
  BreakAfterJavaFieldAnnotations: 'true',
  BreakArrays: 'true',
  BreakBeforeBinaryOperators: 'All',
  BreakBeforeBraces: 'Custom',
  BreakBeforeConceptDeclarations: 'true',
  BreakBeforeInlineASMColon: 'OnlyMultiline',
  BreakBeforeTernaryOperators: 'true',
  BreakConstructorInitializers: 'BeforeColon',
  BreakInheritanceList: 'BeforeColon',
  BreakStringLiterals: 'true',
  ColumnLimit: '40',
  CommentPragmas: '^ IWYU pragma:',
  CompactNamespaces: 'true',
  ConstructorInitializerIndentWidth: '0',
  ContinuationIndentWidth: '0',
  Cpp11BracedListStyle: 'true',
  DerivePointerAlignment: 'true',
  DisableFormat: 'false',
  EmptyLineAfterAccessModifier: 'Always',
  EmptyLineBeforeAccessModifier: 'Always',
  ExperimentalAutoDetectBinPacking: 'true',
  FixNamespaceComments: 'true',
  ForEachMacros: [ 'foreach', 'Q_FOREACH', 'BOOST_FOREACH' ],
  IfMacros: [ 'KJ_IF_MAYBE' ],
  IncludeBlocks: 'Preserve',
  IncludeCategories:
    [
      {
          Regex: '^"(llvm|llvm-c|clang|clang-c)/',
          Priority: '2',
          SortPriority: '0',
          CaseSensitive: 'false'
        },
      {
          Regex: '^(<|"(gtest|gmock|isl|json)/)',
          Priority: '3',
          SortPriority: '0',
          CaseSensitive: 'false'
        },
      {
          Regex: '.*',
          Priority: '1',
          SortPriority: '0',
          CaseSensitive: 'false'
        }
    ],
  IncludeIsMainRegex: '(Test)?$',
  IncludeIsMainSourceRegex: '',
  IndentAccessModifiers: 'true',
  IndentCaseBlocks: 'true',
  IndentCaseLabels: 'true',
  IndentExternBlock: 'AfterExternBlock',
  IndentGotoLabels: 'true',
  IndentPPDirectives: 'None',
  IndentRequiresClause: 'true',
  IndentWidth: '0',
  IndentWrappedFunctionNames: 'true',
  InsertBraces: 'false',
  InsertNewlineAtEOF: 'false',
  InsertTrailingCommas: 'None',
  IntegerLiteralSeparator: { Binary: '0', Decimal: '0', Hex: '0' },
  JavaScriptQuotes: 'Leave',
  JavaScriptWrapImports: 'true',
  KeepEmptyLinesAtTheStartOfBlocks: 'true',
  LambdaBodyIndentation: 'Signature',
  Language: 'Cpp',
  LineEnding: 'DeriveLF', the
  MacroBlockBegin: '',
  MacroBlockEnd: '',
  MaxEmptyLinesToKeep: '0',
  NamespaceIndentation: 'None',
  ObjCBinPackProtocolList: 'Auto',
  ObjCBlockIndentWidth: '2',
  ObjCBreakBeforeNestedBlockParam: 'true',
  ObjCSpaceAfterProperty: 'false',
  ObjCSpaceBeforeProtocolList: 'true',
  PPIndentWidth: '-1',
  PackConstructorInitializers: 'Never',
  PenaltyBreakAssignment: '2',
  PenaltyBreakBeforeFirstCallParameter: '2',
  PenaltyBreakComment: '2',
  PenaltyBreakFirstLessLess: '2',
  PenaltyBreakOpenParenthesis: '2',
  PenaltyBreakString: '2',
  PenaltyBreakTemplateDeclaration: '2',
  PenaltyExcessCharacter: '2',
  PenaltyIndentedWhitespace: '2',
  PenaltyReturnTypeOnItsOwnLine: '2',
  PointerAlignment: 'Left',
  QualifierAlignment: 'Leave',
  ReferenceAlignment: 'Pointer',
  ReflowComments: 'true',
  RemoveBracesLLVM: 'true',
  RemoveSemicolon: 'false',
  RequiresClausePosition: 'OwnLine',
  RequiresExpressionIndentation: 'OuterScope',
  SeparateDefinitionBlocks: 'Leave',
  ShortNamespaceLines: '0',
  SortIncludes: 'Never',
  SortJavaStaticImport: 'Before',
  SortUsingDeclarations: 'true',
  SpaceAfterCStyleCast: 'true',
  SpaceAfterLogicalNot: 'true',
  SpaceAfterTemplateKeyword: 'true',
  SpaceAroundPointerQualifiers: 'Default',
  SpaceBeforeAssignmentOperators: 'true',
  SpaceBeforeCaseColon: 'true',
  SpaceBeforeCpp11BracedList: 'true',
  SpaceBeforeCtorInitializerColon: 'true',
  SpaceBeforeInheritanceColon: 'true',
  SpaceBeforeParens: 'Always',
  SpaceBeforeParensOptions:
    {
      AfterControlStatements: 'true',
      AfterForeachMacros: 'true',
      AfterFunctionDeclarationName: 'true',
      AfterFunctionDefinitionName: 'true',
      AfterIfMacros: 'true',
      AfterOverloadedOperator: 'true',
      AfterRequiresInClause: 'true',
      AfterRequiresInExpression: 'true',
      BeforeNonEmptyParentheses: 'true'
    },
  SpaceBeforeRangeBasedForLoopColon: 'true',
  SpaceBeforeSquareBrackets: 'true',
  SpaceInEmptyBlock: 'true',
  SpaceInEmptyParentheses: 'true',
  SpacesBeforeTrailingComments: '0',
  SpacesInAngles: 'Never',
  SpacesInCStyleCastParentheses: 'true',
  SpacesInConditionalStatement: 'true',
  SpacesInContainerLiterals: 'true',
  SpacesInLineCommentPrefix: { Minimum: '1', Maximum: '-1' },
  SpacesInParentheses: 'true',
  SpacesInSquareBrackets: 'false',
  Standard: 'c++03',
  StatementAttributeLikeMacros: [ 'Q_EMIT' ],
  StatementMacros: [ 'Q_UNUSED', 'QT_REQUIRE_VERSION' ],
  TabWidth: '0',
  UseTab: 'Never',
  WhitespaceSensitiveMacros:
    [
      'BOOST_PP_STRINGIZE',
      'CF_SWIFT_NAME',
      'NS_SWIFT_NAME',
      'PP_STRINGIZE',
      'STRINGIZE'
    ],
  DeriveLineEnding: 'true',
  UseCRLF: 'true'
}

WARN[502286] Failed to format: <command-line>:18:7: error: unknown key '10'
      "10": 'e',
      ^~~~
Error parsing -style: Invalid argument

Any tips to fix this?

tonyho commented 8 months ago

If I use v17.0.4, then a new silimilar problem would show:

DEBU[0159] Request successfully served
DEBU[0159] Start formatting
version:17.0.4
filenameExt: .cpp
Code:

Style:
{}

DEBU[0159] Finished formatting. Result:

DEBU[0159] Request successfully served
DEBU[0166] Start formatting
version:17.0.4
filenameExt: .cpp
Code:
 #include <iostream>
// IndentPPDirectives
#ifdef WIN32
#include <windows.h>
#endif
// SortIncludes
#include "AnotherHeader.h"
#include "MyHeader.h"
#include <boost/asio/io_context.hpp>
#include <boost/asio/ip/tcp.hpp>
#include <boost/asio/signal_set.hpp>
#include <boost/asio/write.hpp>
#include <map>
#include <string>
#include <vector>

// AlignConsecutiveMacros
#define SHORT_NAME 42
#define LONGER_NAME 0x007f
#define EVEN_LONGER_NAME (2)
#define fooo(x) (x * x)
#define baar(y, z) (y + z)

// AlignEscapedNewlines
#define PPP                                                                    \
  int aaaa;                                                                    \
  int b;                                                                       \
  int dddddddddd;

namespace LevelOneNamespace {
namespace LevelTwoNamespace {

struct AAAAAAAAAAAAAAAAAAAA {
  // AlignConsecutiveDeclarations
  int a;
  int bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb;
  std::string cccccccccccccccccc;
};

// AlwaysBreakTemplateDeclarations
template <typename T> T foo() {}

template <typename T>
T foo(int aaaaaaaaaaaaaaaaaaaaa, int bbbbbbbbbbbbbbbbbbbbb) {}

// AllowShortEnumsOnASingleLine
enum : unsigned int { AA = 0, BB } myEnum;

// SpaceBeforeInheritanceColon
class B : public E {
private:
  // AlignArrayOfStructures
  struct AAAAAAAAAAAAAAAAAAAA test[3] = {
      {56, 23, "hello"}, {-1, 93463, "world"}, {7, 5, "!!"}};

  // AlignTrailingComments, AlignConsecutiveDeclarations, QualifierOrder,
  // QualifierAlignment, AlignTrailingComments
  static char const *variable; // very important variable
  void *const *x = nullptr;    // not so important variable
  char const *anotherVariable; // another comment
  int a = 1;                   // another variable
  // used for this, this, and that
  int longComplicatedName = 4;
  int b = 3;

protected:
  // AlwaysBreakAfterReturnType, QualifierAlignment
  constexpr static inline int function(int a, int b) { return (a + b) / 2; }

  // AllowShortFunctionsOnASingleLine
  static bool shortFilter(AAAAAAAAAAAAAAAAAAAA v) { return v.a != 4; }

  void empty() {}

  // IndentWrappedFunctionNames
  std::map<std::basic_string<wchar_t>, std::vector<std::pair<char, int>>>
  func(AAAAAAAAAAAAAAAAAAAA *v);

public:
  // SpaceBeforeCtorInitializerColon
  explicit B() : a(9){};

  // PackConstructorInitializers
  explicit B(int _a, int _b, int _c, std::vector<std::string> str)
      : a(_a), b(_b), longComplicatedName(_c), anotherVariable(str[0].c_str()) {
    // AllowShortIfStatementsOnASingleLine, SpaceBeforeParens
    if (_c)
      anotherVariable = nullptr;
    if (_a)
      anotherVariable = "baz";
    else
      anotherVariable = "bar";
  }

  // AllowAllParametersOfDeclarationOnNextLine BinPackParameters
  int myFunction(int aaaaaaaaaaaaa, int bbbbbbbbbbbbbbbbbbbbbbb,
                 int ccccccccccccc, int d, int e) {
    int myvar = aaaaaaaaaaaaa / 10;
    long anothervaw = d % 2;
    // comment
    char *msg = "Hello all";

    // AlignOperands
    myvar = bbbbbbbbbbbbbbbbbbbbbbb + ccccccccccccc + aaaaaaaaaaaaa;

    // AllowShortCaseLabelsOnASingleLine, SpaceBeforeParens
    switch (e) {
    case 1:
      return e;
    case 2:
      return 2;
    };

    // AllowShortBlocksOnASingleLine, SpaceBeforeParens
    while (true) {
    }
    while (true) {
      continue;
    }
  }

  // AlignAfterOpenBracket, BinPackParameters,
  void loooonFunctionIsVeryLongButNotAsLongAsJavaTypeNames(
      std::vector<AAAAAAAAAAAAAAAAAAAA> const &inputVector,
      std::map<int, std::string> *outputMap) {
    std::vector<AAAAAAAAAAAAAAAAAAAA> bar;
    std::copy_if(inputVector.begin(), inputVector.end(),
                 std::back_inserter(bar), &shortFilter);
    // AllowShortLambdasOnASingleLine
    std::sort(inputVector.begin(), inputVector.end(),
              [](auto v) { return v.a < v.b; });
    std::transform(inputVector.begin(), inputVector.end(),
                   std::inserter(*outputMap, outputMap->end()),
                   [](const AAAAAAAAAAAAAAAAAAAA &element) {
                     // LambdaBodyIndentation
                     return std::make_pair(
                         element.bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
                         element.cccccccccccccccccc);
                   });
  };
  int notInline(AAAAAAAAAAAAAAAAAAAA *v);
};

// AllowShortFunctionsOnASingleLine
int notInline(AAAAAAAAAAAAAAAAAAAA *v) { return v->a + 1; }

} // namespace LevelTwoNamespace
} // namespace LevelOneNamespace

int main() {
  // ReflowComments
  // veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of
  // information
  /* second veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty
   * of information */

  // SortUsingDeclarations
  using std::cin;
  using std::cout;

  int aaaaaaaaaaaaaaaaaaa, bbbbbbbbbbb, ppppppppppp, eeeee;
  // AlignConsecutiveAssignments
  aaaaaaaaaaaaaaaaaaa = 6;
  bbbbbbbbbbb = 5;
  ppppppppppp = 10;
  LevelOneNamespace::LevelTwoNamespace::B b{
      1, 3, 4,
      // SpaceBeforeCpp11BracedList
      std::vector<std::string>{"aaaaaaaaaaaaaaaa", "bbbbbbbbbbbbbbbbbbbbbb",
                               "cccccccccccccccccccccccccccc"}};
  // AllowShortLoopsOnASingleLine
  for (int i = 0; i < 10; i++)
    cout << i;
  LevelOneNamespace::LevelTwoNamespace::AAAAAAAAAAAAAAAAAAAA
      ddddddddddddddddddddddddd{5, 5, "ff"};
  b.notInline(ddddddddddddddddddddddddd);
  // SpaceAfterCStyleCast, AllowAllArgumentsOnNextLine
  cout << (bool)b.myFunction(aaaaaaaaaaaaaaaaaaa, bbbbbbbbbbb, ppppppppppp,
                             eeeee, 0);

  return 0;
}

Style:
{
  BasedOnStyle: 'LLVM',
  AccessModifierOffset: '-8',
  AlignAfterOpenBracket: 'Align',
  AlignArrayOfStructures: 'Right',
  AlignConsecutiveAssignments:
    {
      "0": 'C',
      "1": 'o',
      "2": 'n',
      "3": 's',
      "4": 'e',
      "5": 'c',
      "6": 'u',
      "7": 't',
      "8": 'i',
      "9": 'v',
      "10": 'e',
      Enabled: 'false',
      AcrossEmptyLines: 'false',
      AcrossComments: 'false',
      AlignCompound: 'false',
      PadOperators: 'true'
    },
  AlignConsecutiveBitFields:
    {
      "0": 'C',
      "1": 'o',
      "2": 'n',
      "3": 's',
      "4": 'e',
      "5": 'c',
      "6": 'u',
      "7": 't',
      "8": 'i',
      "9": 'v',
      "10": 'e',
      Enabled: 'false',
      AcrossEmptyLines: 'false',
      AcrossComments: 'false',
      AlignCompound: 'false',
      PadOperators: 'false'
    },
  AlignConsecutiveDeclarations:
    {
      "0": 'C',
      "1": 'o',
      "2": 'n',
      "3": 's',
      "4": 'e',
      "5": 'c',
      "6": 'u',
      "7": 't',
      "8": 'i',
      "9": 'v',
      "10": 'e',
      Enabled: 'false',
      AcrossEmptyLines: 'false',
      AcrossComments: 'false',
      AlignCompound: 'false',
      PadOperators: 'false'
    },
  AlignConsecutiveMacros:
    {
      "0": 'C',
      "1": 'o',
      "2": 'n',
      "3": 's',
      "4": 'e',
      "5": 'c',
      "6": 'u',
      "7": 't',
      "8": 'i',
      "9": 'v',
      "10": 'e',
      Enabled: 'false',
      AcrossEmptyLines: 'false',
      AcrossComments: 'false',
      AlignCompound: 'false',
      PadOperators: 'false'
    },
  AlignConsecutiveShortCaseStatements:
    {
      Enabled: 'false',
      AcrossEmptyLines: 'false',
      AcrossComments: 'false',
      AlignCaseColons: 'false'
    },
  AlignEscapedNewlines: 'Right',
  AlignOperands: 'DontAlign',
  AlignTrailingComments: { Kind: 'Always', OverEmptyLines: '0' },
  AllowAllArgumentsOnNextLine: 'true',
  AllowAllParametersOfDeclarationOnNextLine: 'true',
  AllowShortBlocksOnASingleLine: 'Never',
  AllowShortCaseLabelsOnASingleLine: 'true',
  AllowShortEnumsOnASingleLine: 'true',
  AllowShortFunctionsOnASingleLine: 'None',
  AllowShortIfStatementsOnASingleLine: 'Never',
  AllowShortLambdasOnASingleLine: 'None',
  AllowShortLoopsOnASingleLine: 'true',
  AlwaysBreakAfterDefinitionReturnType: 'All',
  AlwaysBreakAfterReturnType: 'All',
  AlwaysBreakBeforeMultilineStrings: 'true',
  AlwaysBreakTemplateDeclarations: 'Yes',
  AttributeMacros: [ '__capability' ],
  BinPackArguments: 'true',
  BinPackParameters: 'true',
  BitFieldColonSpacing: 'Both',
  BraceWrapping:
    {
      AfterCaseLabel: 'true',
      AfterClass: 'true',
      AfterControlStatement: 'Never',
      AfterEnum: 'true',
      AfterFunction: 'true',
      AfterNamespace: 'true',
      AfterObjCDeclaration: 'true',
      AfterStruct: 'true',
      AfterUnion: 'true',
      AfterExternBlock: 'true',
      BeforeCatch: 'true',
      BeforeElse: 'true',
      BeforeLambdaBody: 'true',
      BeforeWhile: 'true',
      IndentBraces: 'true',
      SplitEmptyFunction: 'true',
      SplitEmptyRecord: 'true',
      SplitEmptyNamespace: 'true'
    },
  BreakAfterAttributes: 'Never',
  BreakAfterJavaFieldAnnotations: 'true',
  BreakArrays: 'true',
  BreakBeforeBinaryOperators: 'All',
  BreakBeforeBraces: 'Custom',
  BreakBeforeConceptDeclarations: 'true',
  BreakBeforeInlineASMColon: 'OnlyMultiline',
  BreakBeforeTernaryOperators: 'true',
  BreakConstructorInitializers: 'BeforeColon',
  BreakInheritanceList: 'BeforeColon',
  BreakStringLiterals: 'true',
  ColumnLimit: '40',
  CommentPragmas: '^ IWYU pragma:',
  CompactNamespaces: 'true',
  ConstructorInitializerIndentWidth: '0',
  ContinuationIndentWidth: '0',
  Cpp11BracedListStyle: 'true',
  DerivePointerAlignment: 'true',
  DisableFormat: 'false',
  EmptyLineAfterAccessModifier: 'Always',
  EmptyLineBeforeAccessModifier: 'Always',
  ExperimentalAutoDetectBinPacking: 'true',
  FixNamespaceComments: 'true',
  ForEachMacros: [ 'foreach', 'Q_FOREACH', 'BOOST_FOREACH' ],
  IfMacros: [ 'KJ_IF_MAYBE' ],
  IncludeBlocks: 'Preserve',
  IncludeCategories:
    [
      {
          Regex: '^"(llvm|llvm-c|clang|clang-c)/',
          Priority: '2',
          SortPriority: '0',
          CaseSensitive: 'false'
        },
      {
          Regex: '^(<|"(gtest|gmock|isl|json)/)',
          Priority: '3',
          SortPriority: '0',
          CaseSensitive: 'false'
        },
      {
          Regex: '.*',
          Priority: '1',
          SortPriority: '0',
          CaseSensitive: 'false'
        }
    ],
  IncludeIsMainRegex: '(Test)?$',
  IncludeIsMainSourceRegex: '',
  IndentAccessModifiers: 'true',
  IndentCaseBlocks: 'true',
  IndentCaseLabels: 'true',
  IndentExternBlock: 'AfterExternBlock',
  IndentGotoLabels: 'true',
  IndentPPDirectives: 'None',
  IndentRequiresClause: 'true',
  IndentWidth: '0',
  IndentWrappedFunctionNames: 'true',
  InsertBraces: 'false',
  InsertNewlineAtEOF: 'false',
  InsertTrailingCommas: 'None',
  IntegerLiteralSeparator:
    {
      Binary: '0',
      BinaryMinDigits: '0',
      Decimal: '0',
      DecimalMinDigits: '0',
      Hex: '0',
      HexMinDigits: '0'
    },
  JavaScriptQuotes: 'Leave',
  JavaScriptWrapImports: 'true',
  KeepEmptyLinesAtEOF: 'false',
  KeepEmptyLinesAtTheStartOfBlocks: 'true',
  LambdaBodyIndentation: 'Signature',
  Language: 'Cpp',
  LineEnding: 'DeriveLF',
  MacroBlockBegin: '',
  MacroBlockEnd: '',
  MaxEmptyLinesToKeep: '0',
  NamespaceIndentation: 'None',
  ObjCBinPackProtocolList: 'Auto',
  ObjCBlockIndentWidth: '2',
  ObjCBreakBeforeNestedBlockParam: 'true',
  ObjCSpaceAfterProperty: 'false',
  ObjCSpaceBeforeProtocolList: 'true',
  PPIndentWidth: '-1',
  PackConstructorInitializers: 'Never',
  PenaltyBreakAssignment: '2',
  PenaltyBreakBeforeFirstCallParameter: '2',
  PenaltyBreakComment: '2',
  PenaltyBreakFirstLessLess: '2',
  PenaltyBreakOpenParenthesis: '2',
  PenaltyBreakString: '2',
  PenaltyBreakTemplateDeclaration: '2',
  PenaltyExcessCharacter: '2',
  PenaltyIndentedWhitespace: '2',
  PenaltyReturnTypeOnItsOwnLine: '2',
  PointerAlignment: 'Left',
  QualifierAlignment: 'Leave',
  ReferenceAlignment: 'Pointer',
  ReflowComments: 'true',
  RemoveBracesLLVM: 'true',
  RemoveParentheses: 'Leave',
  RemoveSemicolon: 'false',
  RequiresClausePosition: 'OwnLine',
  RequiresExpressionIndentation: 'OuterScope',
  SeparateDefinitionBlocks: 'Leave',
  ShortNamespaceLines: '0',
  SortIncludes: 'Never',
  SortJavaStaticImport: 'Before',
  SortUsingDeclarations: 'true',
  SpaceAfterCStyleCast: 'true',
  SpaceAfterLogicalNot: 'true',
  SpaceAfterTemplateKeyword: 'true',
  SpaceAroundPointerQualifiers: 'Default',
  SpaceBeforeAssignmentOperators: 'true',
  SpaceBeforeCaseColon: 'true',
  SpaceBeforeCpp11BracedList: 'true',
  SpaceBeforeCtorInitializerColon: 'true',
  SpaceBeforeInheritanceColon: 'true',
  SpaceBeforeJsonColon: 'false',
  SpaceBeforeParens: 'Always',
  SpaceBeforeParensOptions:
    {
      AfterControlStatements: 'true',
      AfterForeachMacros: 'true',
      AfterFunctionDeclarationName: 'true',
      AfterFunctionDefinitionName: 'true',
      AfterIfMacros: 'true',
      AfterOverloadedOperator: 'true',
      AfterRequiresInClause: 'true',
      AfterRequiresInExpression: 'true',
      BeforeNonEmptyParentheses: 'true'
    },
  SpaceBeforeRangeBasedForLoopColon: 'true',
  SpaceBeforeSquareBrackets: 'true',
  SpaceInEmptyBlock: 'true',
  SpacesBeforeTrailingComments: '0',
  SpacesInAngles: 'Never',
  SpacesInContainerLiterals: 'true',
  SpacesInLineCommentPrefix: { Minimum: '1', Maximum: '-1' },
  SpacesInParens: 'Never',
  SpacesInParensOptions:
    {
      InConditionalStatements: 'false',
      InCStyleCasts: 'false',
      InEmptyParentheses: 'false',
      Other: 'false'
    },
  SpacesInSquareBrackets: 'false',
  Standard: 'c++03',
  StatementAttributeLikeMacros: [ 'Q_EMIT' ],
  StatementMacros: [ 'Q_UNUSED', 'QT_REQUIRE_VERSION' ],
  TabWidth: '0',
  UseTab: 'Never',
  VerilogBreakBetweenInstancePorts: 'true',
  WhitespaceSensitiveMacros:
    [
      'BOOST_PP_STRINGIZE',
      'CF_SWIFT_NAME',
      'NS_SWIFT_NAME',
      'PP_STRINGIZE',
      'STRINGIZE'
    ],
  DeriveLineEnding: 'true',
  SpaceInEmptyParentheses: 'true',
  SpacesInCStyleCastParentheses: 'true',
  SpacesInConditionalStatement: 'true',
  SpacesInParentheses: 'true',
  UseCRLF: 'true'
}

WARN[0166] Failed to format: <command-line>:17:7: error: unknown key '9'
      "9": 'v',
      ^~~
Error parsing -style: Invalid argument
tonyho commented 8 months ago

I found I just made a mistake to create an issue in wrong project. But if this tool can generate the following format of AlignConsecutiveXXXX would be great:

ksnip_0001_20240122-142525

Instead of the following:

AlignConsecutiveAssignments: Consecutive           # Using default value Consecutive
AlignConsecutiveBitFields: Consecutive             # Using default value Consecutive
AlignConsecutiveDeclarations: Consecutive          # Using default value Consecutive
AlignConsecutiveMacros: Consecutive                # Using default value Consecutive
AlignEscapedNewlines: Right                        # Using default value Right

It should be here: https://github.com/Wirena/clang-format-configurator-v2/issues/38