Skip to content

Commit 7664ddf

Browse files
committed
[clang-format][NFC] Drop "Always" in "AlwaysBreakTemplateDeclarations"
1 parent c5cbfc5 commit 7664ddf

File tree

6 files changed

+37
-40
lines changed

6 files changed

+37
-40
lines changed

clang/include/clang/Format/Format.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,7 +1078,7 @@ struct FormatStyle {
10781078
/// This option is renamed to ``BreakTemplateDeclarations``.
10791079
/// \version 3.4
10801080
/// @deprecated
1081-
BreakTemplateDeclarationsStyle AlwaysBreakTemplateDeclarations;
1081+
// BreakTemplateDeclarationsStyle AlwaysBreakTemplateDeclarations;
10821082

10831083
/// A vector of strings that should be interpreted as attributes/qualifiers
10841084
/// instead of identifiers. This can be useful for language extensions or
@@ -2296,7 +2296,7 @@ struct FormatStyle {
22962296

22972297
/// The template declaration breaking style to use.
22982298
/// \version 19
2299-
// BreakTemplateDeclarationsStyle BreakTemplateDeclarations;
2299+
BreakTemplateDeclarationsStyle BreakTemplateDeclarations;
23002300

23012301
/// If ``true``, consecutive namespace declarations will be on the same
23022302
/// line. If ``false``, each namespace is declared on a new line.
@@ -4822,8 +4822,7 @@ struct FormatStyle {
48224822
AlwaysBreakAfterReturnType == R.AlwaysBreakAfterReturnType &&
48234823
AlwaysBreakBeforeMultilineStrings ==
48244824
R.AlwaysBreakBeforeMultilineStrings &&
4825-
AlwaysBreakTemplateDeclarations ==
4826-
R.AlwaysBreakTemplateDeclarations &&
4825+
BreakTemplateDeclarations == R.BreakTemplateDeclarations &&
48274826
AttributeMacros == R.AttributeMacros &&
48284827
BinPackArguments == R.BinPackArguments &&
48294828
BinPackParameters == R.BinPackParameters &&

clang/lib/Format/ContinuationIndenter.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -569,9 +569,8 @@ bool ContinuationIndenter::mustBreak(const LineState &State) {
569569
return true;
570570
}
571571
}
572-
return Style.AlwaysBreakTemplateDeclarations != FormatStyle::BTDS_No &&
573-
(Style.AlwaysBreakTemplateDeclarations !=
574-
FormatStyle::BTDS_Leave ||
572+
return Style.BreakTemplateDeclarations != FormatStyle::BTDS_No &&
573+
(Style.BreakTemplateDeclarations != FormatStyle::BTDS_Leave ||
575574
Current.NewlinesBefore > 0);
576575
}
577576
if (Previous.is(TT_FunctionAnnotationRParen) &&

clang/lib/Format/Format.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,7 @@ template <> struct MappingTraits<FormatStyle> {
878878
IO.mapOptional("AlignEscapedNewlinesLeft", Style.AlignEscapedNewlines);
879879
IO.mapOptional("AllowAllConstructorInitializersOnNextLine", OnNextLine);
880880
IO.mapOptional("AlwaysBreakTemplateDeclarations",
881-
Style.AlwaysBreakTemplateDeclarations);
881+
Style.BreakTemplateDeclarations);
882882
IO.mapOptional("BreakBeforeInheritanceComma",
883883
BreakBeforeInheritanceComma);
884884
IO.mapOptional("BreakConstructorInitializersBeforeComma",
@@ -972,7 +972,7 @@ template <> struct MappingTraits<FormatStyle> {
972972
IO.mapOptional("BreakInheritanceList", Style.BreakInheritanceList);
973973
IO.mapOptional("BreakStringLiterals", Style.BreakStringLiterals);
974974
IO.mapOptional("BreakTemplateDeclarations",
975-
Style.AlwaysBreakTemplateDeclarations);
975+
Style.BreakTemplateDeclarations);
976976
IO.mapOptional("ColumnLimit", Style.ColumnLimit);
977977
IO.mapOptional("CommentPragmas", Style.CommentPragmas);
978978
IO.mapOptional("CompactNamespaces", Style.CompactNamespaces);
@@ -1441,7 +1441,7 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind Language) {
14411441
LLVMStyle.AlwaysBreakAfterReturnType = FormatStyle::RTBS_None;
14421442
LLVMStyle.AlwaysBreakAfterDefinitionReturnType = FormatStyle::DRTBS_None;
14431443
LLVMStyle.AlwaysBreakBeforeMultilineStrings = false;
1444-
LLVMStyle.AlwaysBreakTemplateDeclarations = FormatStyle::BTDS_MultiLine;
1444+
LLVMStyle.BreakTemplateDeclarations = FormatStyle::BTDS_MultiLine;
14451445
LLVMStyle.AttributeMacros.push_back("__capability");
14461446
LLVMStyle.BitFieldColonSpacing = FormatStyle::BFCS_Both;
14471447
LLVMStyle.BinPackArguments = true;
@@ -1631,7 +1631,7 @@ FormatStyle getGoogleStyle(FormatStyle::LanguageKind Language) {
16311631
FormatStyle::SIS_WithoutElse;
16321632
GoogleStyle.AllowShortLoopsOnASingleLine = true;
16331633
GoogleStyle.AlwaysBreakBeforeMultilineStrings = true;
1634-
GoogleStyle.AlwaysBreakTemplateDeclarations = FormatStyle::BTDS_Yes;
1634+
GoogleStyle.BreakTemplateDeclarations = FormatStyle::BTDS_Yes;
16351635
GoogleStyle.DerivePointerAlignment = true;
16361636
GoogleStyle.IncludeStyle.IncludeCategories = {{"^<ext/.*\\.h>", 2, 0, false},
16371637
{"^<.*\\.h>", 1, 0, false},
@@ -1824,7 +1824,7 @@ FormatStyle getMozillaStyle() {
18241824
MozillaStyle.AlwaysBreakAfterReturnType = FormatStyle::RTBS_TopLevel;
18251825
MozillaStyle.AlwaysBreakAfterDefinitionReturnType =
18261826
FormatStyle::DRTBS_TopLevel;
1827-
MozillaStyle.AlwaysBreakTemplateDeclarations = FormatStyle::BTDS_Yes;
1827+
MozillaStyle.BreakTemplateDeclarations = FormatStyle::BTDS_Yes;
18281828
MozillaStyle.BinPackParameters = false;
18291829
MozillaStyle.BinPackArguments = false;
18301830
MozillaStyle.BreakBeforeBraces = FormatStyle::BS_Mozilla;

clang/lib/Format/TokenAnnotator.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5184,8 +5184,8 @@ bool TokenAnnotator::mustBreakBefore(const AnnotatedLine &Line,
51845184
// concept ...
51855185
if (Right.is(tok::kw_concept))
51865186
return Style.BreakBeforeConceptDeclarations == FormatStyle::BBCDS_Always;
5187-
return Style.AlwaysBreakTemplateDeclarations == FormatStyle::BTDS_Yes ||
5188-
(Style.AlwaysBreakTemplateDeclarations == FormatStyle::BTDS_Leave &&
5187+
return Style.BreakTemplateDeclarations == FormatStyle::BTDS_Yes ||
5188+
(Style.BreakTemplateDeclarations == FormatStyle::BTDS_Leave &&
51895189
Right.NewlinesBefore > 0);
51905190
}
51915191
if (Left.ClosesRequiresClause && Right.isNot(tok::semi)) {
@@ -5620,7 +5620,7 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line,
56205620
if (Right.is(TT_RequiresClause))
56215621
return true;
56225622
if (Left.ClosesTemplateDeclaration) {
5623-
return Style.AlwaysBreakTemplateDeclarations != FormatStyle::BTDS_Leave ||
5623+
return Style.BreakTemplateDeclarations != FormatStyle::BTDS_Leave ||
56245624
Right.NewlinesBefore > 0;
56255625
}
56265626
if (Left.is(TT_FunctionAnnotationRParen))

clang/unittests/Format/ConfigParseTest.cpp

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -694,32 +694,32 @@ TEST(ConfigParseTest, ParsesConfiguration) {
694694
AlwaysBreakAfterReturnType,
695695
FormatStyle::RTBS_TopLevelDefinitions);
696696

697-
Style.AlwaysBreakTemplateDeclarations = FormatStyle::BTDS_Yes;
698-
CHECK_PARSE("BreakTemplateDeclarations: Leave",
699-
AlwaysBreakTemplateDeclarations, FormatStyle::BTDS_Leave);
700-
CHECK_PARSE("BreakTemplateDeclarations: No", AlwaysBreakTemplateDeclarations,
697+
Style.BreakTemplateDeclarations = FormatStyle::BTDS_Yes;
698+
CHECK_PARSE("BreakTemplateDeclarations: Leave", BreakTemplateDeclarations,
699+
FormatStyle::BTDS_Leave);
700+
CHECK_PARSE("BreakTemplateDeclarations: No", BreakTemplateDeclarations,
701701
FormatStyle::BTDS_No);
702-
CHECK_PARSE("BreakTemplateDeclarations: MultiLine",
703-
AlwaysBreakTemplateDeclarations, FormatStyle::BTDS_MultiLine);
704-
CHECK_PARSE("BreakTemplateDeclarations: Yes", AlwaysBreakTemplateDeclarations,
702+
CHECK_PARSE("BreakTemplateDeclarations: MultiLine", BreakTemplateDeclarations,
703+
FormatStyle::BTDS_MultiLine);
704+
CHECK_PARSE("BreakTemplateDeclarations: Yes", BreakTemplateDeclarations,
705+
FormatStyle::BTDS_Yes);
706+
CHECK_PARSE("BreakTemplateDeclarations: false", BreakTemplateDeclarations,
707+
FormatStyle::BTDS_MultiLine);
708+
CHECK_PARSE("BreakTemplateDeclarations: true", BreakTemplateDeclarations,
705709
FormatStyle::BTDS_Yes);
706-
CHECK_PARSE("BreakTemplateDeclarations: false",
707-
AlwaysBreakTemplateDeclarations, FormatStyle::BTDS_MultiLine);
708-
CHECK_PARSE("BreakTemplateDeclarations: true",
709-
AlwaysBreakTemplateDeclarations, FormatStyle::BTDS_Yes);
710710
// For backward compatibility:
711711
CHECK_PARSE("AlwaysBreakTemplateDeclarations: Leave",
712-
AlwaysBreakTemplateDeclarations, FormatStyle::BTDS_Leave);
713-
CHECK_PARSE("AlwaysBreakTemplateDeclarations: No",
714-
AlwaysBreakTemplateDeclarations, FormatStyle::BTDS_No);
712+
BreakTemplateDeclarations, FormatStyle::BTDS_Leave);
713+
CHECK_PARSE("AlwaysBreakTemplateDeclarations: No", BreakTemplateDeclarations,
714+
FormatStyle::BTDS_No);
715715
CHECK_PARSE("AlwaysBreakTemplateDeclarations: MultiLine",
716-
AlwaysBreakTemplateDeclarations, FormatStyle::BTDS_MultiLine);
717-
CHECK_PARSE("AlwaysBreakTemplateDeclarations: Yes",
718-
AlwaysBreakTemplateDeclarations, FormatStyle::BTDS_Yes);
716+
BreakTemplateDeclarations, FormatStyle::BTDS_MultiLine);
717+
CHECK_PARSE("AlwaysBreakTemplateDeclarations: Yes", BreakTemplateDeclarations,
718+
FormatStyle::BTDS_Yes);
719719
CHECK_PARSE("AlwaysBreakTemplateDeclarations: false",
720-
AlwaysBreakTemplateDeclarations, FormatStyle::BTDS_MultiLine);
720+
BreakTemplateDeclarations, FormatStyle::BTDS_MultiLine);
721721
CHECK_PARSE("AlwaysBreakTemplateDeclarations: true",
722-
AlwaysBreakTemplateDeclarations, FormatStyle::BTDS_Yes);
722+
BreakTemplateDeclarations, FormatStyle::BTDS_Yes);
723723

724724
Style.AlwaysBreakAfterDefinitionReturnType = FormatStyle::DRTBS_All;
725725
CHECK_PARSE("AlwaysBreakAfterDefinitionReturnType: None",

clang/unittests/Format/FormatTest.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10638,7 +10638,7 @@ TEST_F(FormatTest, WrapsTemplateDeclarations) {
1063810638
" const typename aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaa);");
1063910639

1064010640
FormatStyle AlwaysBreak = getLLVMStyle();
10641-
AlwaysBreak.AlwaysBreakTemplateDeclarations = FormatStyle::BTDS_Yes;
10641+
AlwaysBreak.BreakTemplateDeclarations = FormatStyle::BTDS_Yes;
1064210642
verifyFormat("template <typename T>\nclass C {};", AlwaysBreak);
1064310643
verifyFormat("template <typename T>\nvoid f();", AlwaysBreak);
1064410644
verifyFormat("template <typename T>\nvoid f() {}", AlwaysBreak);
@@ -10667,7 +10667,7 @@ TEST_F(FormatTest, WrapsTemplateDeclarations) {
1066710667
"};");
1066810668

1066910669
FormatStyle NeverBreak = getLLVMStyle();
10670-
NeverBreak.AlwaysBreakTemplateDeclarations = FormatStyle::BTDS_No;
10670+
NeverBreak.BreakTemplateDeclarations = FormatStyle::BTDS_No;
1067110671
verifyFormat("template <typename T> class C {};", NeverBreak);
1067210672
verifyFormat("template <typename T> void f();", NeverBreak);
1067310673
verifyFormat("template <typename T> void f() {}", NeverBreak);
@@ -10699,7 +10699,7 @@ TEST_F(FormatTest, WrapsTemplateDeclarations) {
1069910699
NeverBreak);
1070010700

1070110701
auto Style = getLLVMStyle();
10702-
Style.AlwaysBreakTemplateDeclarations = FormatStyle::BTDS_Leave;
10702+
Style.BreakTemplateDeclarations = FormatStyle::BTDS_Leave;
1070310703

1070410704
verifyNoChange("template <typename T>\n"
1070510705
"class C {};",
@@ -11297,7 +11297,7 @@ TEST_F(FormatTest, UnderstandsFunctionRefQualification) {
1129711297
verifyFormat("SomeType MemberFunction( const Deleted & ) &;", Spaces);
1129811298

1129911299
FormatStyle BreakTemplate = getLLVMStyle();
11300-
BreakTemplate.AlwaysBreakTemplateDeclarations = FormatStyle::BTDS_Yes;
11300+
BreakTemplate.BreakTemplateDeclarations = FormatStyle::BTDS_Yes;
1130111301

1130211302
verifyFormat("struct f {\n"
1130311303
" template <class T>\n"
@@ -11330,8 +11330,7 @@ TEST_F(FormatTest, UnderstandsFunctionRefQualification) {
1133011330
BreakTemplate);
1133111331

1133211332
FormatStyle AlignLeftBreakTemplate = getLLVMStyle();
11333-
AlignLeftBreakTemplate.AlwaysBreakTemplateDeclarations =
11334-
FormatStyle::BTDS_Yes;
11333+
AlignLeftBreakTemplate.BreakTemplateDeclarations = FormatStyle::BTDS_Yes;
1133511334
AlignLeftBreakTemplate.PointerAlignment = FormatStyle::PAS_Left;
1133611335

1133711336
verifyFormat("struct f {\n"

0 commit comments

Comments
 (0)