Index: unittests/Format/FormatTest.cpp =================================================================== --- unittests/Format/FormatTest.cpp +++ unittests/Format/FormatTest.cpp @@ -8415,9 +8415,12 @@ CHECK_PARSE("ContinuationIndentWidth: 11", ContinuationIndentWidth, 11u); Style.PointerAlignment = FormatStyle::PAS_Middle; - CHECK_PARSE("PointerAlignment: Left", PointerAlignment, FormatStyle::PAS_Left); - CHECK_PARSE("PointerAlignment: Right", PointerAlignment, FormatStyle::PAS_Right); - CHECK_PARSE("PointerAlignment: Middle", PointerAlignment, FormatStyle::PAS_Middle); + CHECK_PARSE("PointerAlignment: Left", PointerAlignment, + FormatStyle::PAS_Left); + CHECK_PARSE("PointerAlignment: Right", PointerAlignment, + FormatStyle::PAS_Right); + CHECK_PARSE("PointerAlignment: Middle", PointerAlignment, + FormatStyle::PAS_Middle); Style.Standard = FormatStyle::LS_Auto; CHECK_PARSE("Standard: Cpp03", Standard, FormatStyle::LS_Cpp03); @@ -8427,17 +8430,11 @@ CHECK_PARSE("Standard: Auto", Standard, FormatStyle::LS_Auto); Style.UseTab = FormatStyle::UT_ForIndentation; - CHECK_PARSE("UseTab: false", UseTab, FormatStyle::UT_Never); - CHECK_PARSE("UseTab: true", UseTab, FormatStyle::UT_Always); CHECK_PARSE("UseTab: Never", UseTab, FormatStyle::UT_Never); CHECK_PARSE("UseTab: ForIndentation", UseTab, FormatStyle::UT_ForIndentation); CHECK_PARSE("UseTab: Always", UseTab, FormatStyle::UT_Always); Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Inline; - CHECK_PARSE("AllowShortFunctionsOnASingleLine: false", - AllowShortFunctionsOnASingleLine, FormatStyle::SFS_None); - CHECK_PARSE("AllowShortFunctionsOnASingleLine: true", - AllowShortFunctionsOnASingleLine, FormatStyle::SFS_All); CHECK_PARSE("AllowShortFunctionsOnASingleLine: None", AllowShortFunctionsOnASingleLine, FormatStyle::SFS_None); CHECK_PARSE("AllowShortFunctionsOnASingleLine: Inline", @@ -8452,11 +8449,6 @@ FormatStyle::SBPO_Always); CHECK_PARSE("SpaceBeforeParens: ControlStatements", SpaceBeforeParens, FormatStyle::SBPO_ControlStatements); - // For backward compatibility: - CHECK_PARSE("SpaceAfterControlStatementKeyword: false", SpaceBeforeParens, - FormatStyle::SBPO_Never); - CHECK_PARSE("SpaceAfterControlStatementKeyword: true", SpaceBeforeParens, - FormatStyle::SBPO_ControlStatements); Style.ColumnLimit = 123; FormatStyle BaseStyle = getLLVMStyle(); @@ -8493,6 +8485,39 @@ BoostAndQForeach); } +TEST_F(FormatTest, ParsesConfigurationBackwardCompatibility) { + FormatStyle Style = {}; + Style.Language = FormatStyle::LK_Cpp; + + Style.DerivePointerAlignment = true; + CHECK_PARSE("DerivePointerBinding: false", DerivePointerAlignment, false); + CHECK_PARSE("DerivePointerBinding: true", DerivePointerAlignment, true); + + Style.PointerAlignment = FormatStyle::PAS_Middle; + CHECK_PARSE("PointerBindsToType: Left", PointerAlignment, + FormatStyle::PAS_Left); + CHECK_PARSE("PointerBindsToType: Right", PointerAlignment, + FormatStyle::PAS_Right); + CHECK_PARSE("PointerBindsToType: Middle", PointerAlignment, + FormatStyle::PAS_Middle); + + Style.UseTab = FormatStyle::UT_ForIndentation; + CHECK_PARSE("UseTab: false", UseTab, FormatStyle::UT_Never); + CHECK_PARSE("UseTab: true", UseTab, FormatStyle::UT_Always); + + Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Inline; + CHECK_PARSE("AllowShortFunctionsOnASingleLine: false", + AllowShortFunctionsOnASingleLine, FormatStyle::SFS_None); + CHECK_PARSE("AllowShortFunctionsOnASingleLine: true", + AllowShortFunctionsOnASingleLine, FormatStyle::SFS_All); + + Style.SpaceBeforeParens = FormatStyle::SBPO_Always; + CHECK_PARSE("SpaceAfterControlStatementKeyword: false", SpaceBeforeParens, + FormatStyle::SBPO_Never); + CHECK_PARSE("SpaceAfterControlStatementKeyword: true", SpaceBeforeParens, + FormatStyle::SBPO_ControlStatements); +} + TEST_F(FormatTest, ParsesConfigurationWithLanguages) { FormatStyle Style = {}; Style.Language = FormatStyle::LK_Cpp; @@ -8768,8 +8793,12 @@ ": aaaaaaaaaaaaa(aaaaaaaaaaaaaa), aaaaaaaaaaaaa(aaaaaaaaaaaaaa),\n" " aaaaaaaaaaaaa(aaaaaaaaaaaaaa) {}", Style); +} +TEST_F(FormatTest, BreakConstructorInitializersBeforeComma) { + FormatStyle Style = getLLVMStyle(); Style.BreakConstructorInitializersBeforeComma = true; + Style.ConstructorInitializerIndentWidth = 4; verifyFormat("SomeClass::Constructor()\n" " : a(a)\n"