summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrmarker <37921131+rmarker@users.noreply.github.com>2024-02-15 14:40:56 +1030
committerGitHub <noreply@github.com>2024-02-14 20:10:56 -0800
commitd821650e13145a1acccd337c9853354ad6531507 (patch)
treed3a45fddc0406fc8602b9027579091b68cf095a0
parentde6fad51462bd0784beafef6fd171ad7725205b5 (diff)
[clang-format][NFC] Drop "Always" in "AlwaysBreakAfterReturnType". (#81591)
Complete the switch from "AlwaysBreakAfterReturnType" to "BreakAfterReturnType".
-rw-r--r--clang/include/clang/Format/Format.h6
-rw-r--r--clang/lib/Format/ContinuationIndenter.cpp6
-rw-r--r--clang/lib/Format/Format.cpp24
-rw-r--r--clang/lib/Format/TokenAnnotator.cpp7
-rw-r--r--clang/unittests/Format/ConfigParseTest.cpp40
-rw-r--r--clang/unittests/Format/DefinitionBlockSeparatorTest.cpp2
-rw-r--r--clang/unittests/Format/FormatTest.cpp16
-rw-r--r--clang/unittests/Format/FormatTestCSharp.cpp2
8 files changed, 49 insertions, 54 deletions
diff --git a/clang/include/clang/Format/Format.h b/clang/include/clang/Format/Format.h
index 737cbfced9e9..e9b2160a7b92 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -1013,7 +1013,7 @@ struct FormatStyle {
/// This option is renamed to ``BreakAfterReturnType``.
/// \version 3.8
/// @deprecated
- ReturnTypeBreakingStyle AlwaysBreakAfterReturnType;
+ // ReturnTypeBreakingStyle AlwaysBreakAfterReturnType;
/// If ``true``, always break before multiline string literals.
///
@@ -1579,7 +1579,7 @@ struct FormatStyle {
/// The function declaration return type breaking style to use.
/// \version 19
- // ReturnTypeBreakingStyle BreakAfterReturnType;
+ ReturnTypeBreakingStyle BreakAfterReturnType;
/// If ``true``, clang-format will always break after a Json array ``[``
/// otherwise it will scan until the closing ``]`` to determine if it should
@@ -4824,7 +4824,6 @@ struct FormatStyle {
R.AllowShortIfStatementsOnASingleLine &&
AllowShortLambdasOnASingleLine == R.AllowShortLambdasOnASingleLine &&
AllowShortLoopsOnASingleLine == R.AllowShortLoopsOnASingleLine &&
- AlwaysBreakAfterReturnType == R.AlwaysBreakAfterReturnType &&
AlwaysBreakBeforeMultilineStrings ==
R.AlwaysBreakBeforeMultilineStrings &&
AttributeMacros == R.AttributeMacros &&
@@ -4835,6 +4834,7 @@ struct FormatStyle {
BreakAdjacentStringLiterals == R.BreakAdjacentStringLiterals &&
BreakAfterAttributes == R.BreakAfterAttributes &&
BreakAfterJavaFieldAnnotations == R.BreakAfterJavaFieldAnnotations &&
+ BreakAfterReturnType == R.BreakAfterReturnType &&
BreakArrays == R.BreakArrays &&
BreakBeforeBinaryOperators == R.BreakBeforeBinaryOperators &&
BreakBeforeBraces == R.BreakBeforeBraces &&
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp
index 0b2ef97af44d..159d130cb673 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -329,12 +329,12 @@ bool ContinuationIndenter::canBreak(const LineState &State) {
// Don't break after very short return types (e.g. "void") as that is often
// unexpected.
if (Current.is(TT_FunctionDeclarationName)) {
- if (Style.AlwaysBreakAfterReturnType == FormatStyle::RTBS_None &&
+ if (Style.BreakAfterReturnType == FormatStyle::RTBS_None &&
State.Column < 6) {
return false;
}
- if (Style.AlwaysBreakAfterReturnType == FormatStyle::RTBS_ExceptShortType) {
+ if (Style.BreakAfterReturnType == FormatStyle::RTBS_ExceptShortType) {
assert(State.Column >= State.FirstIndent);
if (State.Column - State.FirstIndent < 6)
return false;
@@ -597,7 +597,7 @@ bool ContinuationIndenter::mustBreak(const LineState &State) {
!State.Line->ReturnTypeWrapped &&
// Don't break before a C# function when no break after return type.
(!Style.isCSharp() ||
- Style.AlwaysBreakAfterReturnType > FormatStyle::RTBS_ExceptShortType) &&
+ Style.BreakAfterReturnType > FormatStyle::RTBS_ExceptShortType) &&
// Don't always break between a JavaScript `function` and the function
// name.
!Style.isJavaScript() && Previous.isNot(tok::kw_template) &&
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 8efc42e0576c..56cd9495920c 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -877,8 +877,7 @@ template <> struct MappingTraits<FormatStyle> {
if (!IO.outputting()) {
IO.mapOptional("AlignEscapedNewlinesLeft", Style.AlignEscapedNewlines);
IO.mapOptional("AllowAllConstructorInitializersOnNextLine", OnNextLine);
- IO.mapOptional("AlwaysBreakAfterReturnType",
- Style.AlwaysBreakAfterReturnType);
+ IO.mapOptional("AlwaysBreakAfterReturnType", Style.BreakAfterReturnType);
IO.mapOptional("AlwaysBreakTemplateDeclarations",
Style.BreakTemplateDeclarations);
IO.mapOptional("BreakBeforeInheritanceComma",
@@ -957,7 +956,7 @@ template <> struct MappingTraits<FormatStyle> {
IO.mapOptional("BreakAfterAttributes", Style.BreakAfterAttributes);
IO.mapOptional("BreakAfterJavaFieldAnnotations",
Style.BreakAfterJavaFieldAnnotations);
- IO.mapOptional("BreakAfterReturnType", Style.AlwaysBreakAfterReturnType);
+ IO.mapOptional("BreakAfterReturnType", Style.BreakAfterReturnType);
IO.mapOptional("BreakArrays", Style.BreakArrays);
IO.mapOptional("BreakBeforeBinaryOperators",
Style.BreakBeforeBinaryOperators);
@@ -1127,17 +1126,16 @@ template <> struct MappingTraits<FormatStyle> {
Style.WhitespaceSensitiveMacros);
// If AlwaysBreakAfterDefinitionReturnType was specified but
- // AlwaysBreakAfterReturnType was not, initialize the latter from the
- // former for backwards compatibility.
+ // BreakAfterReturnType was not, initialize the latter from the former for
+ // backwards compatibility.
if (Style.AlwaysBreakAfterDefinitionReturnType != FormatStyle::DRTBS_None &&
- Style.AlwaysBreakAfterReturnType == FormatStyle::RTBS_None) {
+ Style.BreakAfterReturnType == FormatStyle::RTBS_None) {
if (Style.AlwaysBreakAfterDefinitionReturnType ==
FormatStyle::DRTBS_All) {
- Style.AlwaysBreakAfterReturnType = FormatStyle::RTBS_AllDefinitions;
+ Style.BreakAfterReturnType = FormatStyle::RTBS_AllDefinitions;
} else if (Style.AlwaysBreakAfterDefinitionReturnType ==
FormatStyle::DRTBS_TopLevel) {
- Style.AlwaysBreakAfterReturnType =
- FormatStyle::RTBS_TopLevelDefinitions;
+ Style.BreakAfterReturnType = FormatStyle::RTBS_TopLevelDefinitions;
}
}
@@ -1439,7 +1437,6 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind Language) {
LLVMStyle.AllowShortIfStatementsOnASingleLine = FormatStyle::SIS_Never;
LLVMStyle.AllowShortLambdasOnASingleLine = FormatStyle::SLS_All;
LLVMStyle.AllowShortLoopsOnASingleLine = false;
- LLVMStyle.AlwaysBreakAfterReturnType = FormatStyle::RTBS_None;
LLVMStyle.AlwaysBreakAfterDefinitionReturnType = FormatStyle::DRTBS_None;
LLVMStyle.AlwaysBreakBeforeMultilineStrings = false;
LLVMStyle.BreakTemplateDeclarations = FormatStyle::BTDS_MultiLine;
@@ -1469,6 +1466,7 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind Language) {
LLVMStyle.BreakAdjacentStringLiterals = true;
LLVMStyle.BreakAfterAttributes = FormatStyle::ABS_Leave;
LLVMStyle.BreakAfterJavaFieldAnnotations = false;
+ LLVMStyle.BreakAfterReturnType = FormatStyle::RTBS_None;
LLVMStyle.BreakArrays = true;
LLVMStyle.BreakBeforeBinaryOperators = FormatStyle::BOS_None;
LLVMStyle.BreakBeforeBraces = FormatStyle::BS_Attach;
@@ -1822,12 +1820,12 @@ FormatStyle getMozillaStyle() {
FormatStyle MozillaStyle = getLLVMStyle();
MozillaStyle.AllowAllParametersOfDeclarationOnNextLine = false;
MozillaStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Inline;
- MozillaStyle.AlwaysBreakAfterReturnType = FormatStyle::RTBS_TopLevel;
MozillaStyle.AlwaysBreakAfterDefinitionReturnType =
FormatStyle::DRTBS_TopLevel;
MozillaStyle.BreakTemplateDeclarations = FormatStyle::BTDS_Yes;
MozillaStyle.BinPackParameters = false;
MozillaStyle.BinPackArguments = false;
+ MozillaStyle.BreakAfterReturnType = FormatStyle::RTBS_TopLevel;
MozillaStyle.BreakBeforeBraces = FormatStyle::BS_Mozilla;
MozillaStyle.BreakConstructorInitializers = FormatStyle::BCIS_BeforeComma;
MozillaStyle.BreakInheritanceList = FormatStyle::BILS_BeforeComma;
@@ -1871,7 +1869,7 @@ FormatStyle getWebKitStyle() {
FormatStyle getGNUStyle() {
FormatStyle Style = getLLVMStyle();
Style.AlwaysBreakAfterDefinitionReturnType = FormatStyle::DRTBS_All;
- Style.AlwaysBreakAfterReturnType = FormatStyle::RTBS_AllDefinitions;
+ Style.BreakAfterReturnType = FormatStyle::RTBS_AllDefinitions;
Style.BreakBeforeBinaryOperators = FormatStyle::BOS_All;
Style.BreakBeforeBraces = FormatStyle::BS_GNU;
Style.BreakBeforeTernaryOperators = true;
@@ -1908,7 +1906,7 @@ FormatStyle getMicrosoftStyle(FormatStyle::LanguageKind Language) {
Style.AllowShortIfStatementsOnASingleLine = FormatStyle::SIS_Never;
Style.AllowShortLoopsOnASingleLine = false;
Style.AlwaysBreakAfterDefinitionReturnType = FormatStyle::DRTBS_None;
- Style.AlwaysBreakAfterReturnType = FormatStyle::RTBS_None;
+ Style.BreakAfterReturnType = FormatStyle::RTBS_None;
return Style;
}
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index 08a49bc17f13..ac876bf4442e 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -3728,14 +3728,13 @@ static bool isFunctionDeclarationName(bool IsCpp, const FormatToken &Current,
bool TokenAnnotator::mustBreakForReturnType(const AnnotatedLine &Line) const {
assert(Line.MightBeFunctionDecl);
- if ((Style.AlwaysBreakAfterReturnType == FormatStyle::RTBS_TopLevel ||
- Style.AlwaysBreakAfterReturnType ==
- FormatStyle::RTBS_TopLevelDefinitions) &&
+ if ((Style.BreakAfterReturnType == FormatStyle::RTBS_TopLevel ||
+ Style.BreakAfterReturnType == FormatStyle::RTBS_TopLevelDefinitions) &&
Line.Level > 0) {
return false;
}
- switch (Style.AlwaysBreakAfterReturnType) {
+ switch (Style.BreakAfterReturnType) {
case FormatStyle::RTBS_None:
case FormatStyle::RTBS_Automatic:
case FormatStyle::RTBS_ExceptShortType:
diff --git a/clang/unittests/Format/ConfigParseTest.cpp b/clang/unittests/Format/ConfigParseTest.cpp
index ee8a55680753..8c74ed2d119a 100644
--- a/clang/unittests/Format/ConfigParseTest.cpp
+++ b/clang/unittests/Format/ConfigParseTest.cpp
@@ -677,38 +677,36 @@ TEST(ConfigParseTest, ParsesConfiguration) {
" AfterControlStatement: false",
BraceWrapping.AfterControlStatement, FormatStyle::BWACS_Never);
- Style.AlwaysBreakAfterReturnType = FormatStyle::RTBS_All;
- CHECK_PARSE("BreakAfterReturnType: None", AlwaysBreakAfterReturnType,
+ Style.BreakAfterReturnType = FormatStyle::RTBS_All;
+ CHECK_PARSE("BreakAfterReturnType: None", BreakAfterReturnType,
FormatStyle::RTBS_None);
- CHECK_PARSE("BreakAfterReturnType: Automatic", AlwaysBreakAfterReturnType,
+ CHECK_PARSE("BreakAfterReturnType: Automatic", BreakAfterReturnType,
FormatStyle::RTBS_Automatic);
- CHECK_PARSE("BreakAfterReturnType: ExceptShortType",
- AlwaysBreakAfterReturnType, FormatStyle::RTBS_ExceptShortType);
- CHECK_PARSE("BreakAfterReturnType: All", AlwaysBreakAfterReturnType,
+ CHECK_PARSE("BreakAfterReturnType: ExceptShortType", BreakAfterReturnType,
+ FormatStyle::RTBS_ExceptShortType);
+ CHECK_PARSE("BreakAfterReturnType: All", BreakAfterReturnType,
FormatStyle::RTBS_All);
- CHECK_PARSE("BreakAfterReturnType: TopLevel", AlwaysBreakAfterReturnType,
+ CHECK_PARSE("BreakAfterReturnType: TopLevel", BreakAfterReturnType,
FormatStyle::RTBS_TopLevel);
- CHECK_PARSE("BreakAfterReturnType: AllDefinitions",
- AlwaysBreakAfterReturnType, FormatStyle::RTBS_AllDefinitions);
- CHECK_PARSE("BreakAfterReturnType: TopLevelDefinitions",
- AlwaysBreakAfterReturnType,
+ CHECK_PARSE("BreakAfterReturnType: AllDefinitions", BreakAfterReturnType,
+ FormatStyle::RTBS_AllDefinitions);
+ CHECK_PARSE("BreakAfterReturnType: TopLevelDefinitions", BreakAfterReturnType,
FormatStyle::RTBS_TopLevelDefinitions);
// For backward compatibility:
- CHECK_PARSE("AlwaysBreakAfterReturnType: None", AlwaysBreakAfterReturnType,
+ CHECK_PARSE("AlwaysBreakAfterReturnType: None", BreakAfterReturnType,
FormatStyle::RTBS_None);
- CHECK_PARSE("AlwaysBreakAfterReturnType: Automatic",
- AlwaysBreakAfterReturnType, FormatStyle::RTBS_Automatic);
+ CHECK_PARSE("AlwaysBreakAfterReturnType: Automatic", BreakAfterReturnType,
+ FormatStyle::RTBS_Automatic);
CHECK_PARSE("AlwaysBreakAfterReturnType: ExceptShortType",
- AlwaysBreakAfterReturnType, FormatStyle::RTBS_ExceptShortType);
- CHECK_PARSE("AlwaysBreakAfterReturnType: All", AlwaysBreakAfterReturnType,
+ BreakAfterReturnType, FormatStyle::RTBS_ExceptShortType);
+ CHECK_PARSE("AlwaysBreakAfterReturnType: All", BreakAfterReturnType,
FormatStyle::RTBS_All);
- CHECK_PARSE("AlwaysBreakAfterReturnType: TopLevel",
- AlwaysBreakAfterReturnType, FormatStyle::RTBS_TopLevel);
+ CHECK_PARSE("AlwaysBreakAfterReturnType: TopLevel", BreakAfterReturnType,
+ FormatStyle::RTBS_TopLevel);
CHECK_PARSE("AlwaysBreakAfterReturnType: AllDefinitions",
- AlwaysBreakAfterReturnType, FormatStyle::RTBS_AllDefinitions);
+ BreakAfterReturnType, FormatStyle::RTBS_AllDefinitions);
CHECK_PARSE("AlwaysBreakAfterReturnType: TopLevelDefinitions",
- AlwaysBreakAfterReturnType,
- FormatStyle::RTBS_TopLevelDefinitions);
+ BreakAfterReturnType, FormatStyle::RTBS_TopLevelDefinitions);
Style.BreakTemplateDeclarations = FormatStyle::BTDS_Yes;
CHECK_PARSE("BreakTemplateDeclarations: Leave", BreakTemplateDeclarations,
diff --git a/clang/unittests/Format/DefinitionBlockSeparatorTest.cpp b/clang/unittests/Format/DefinitionBlockSeparatorTest.cpp
index f5489498a93b..7a120935cfa9 100644
--- a/clang/unittests/Format/DefinitionBlockSeparatorTest.cpp
+++ b/clang/unittests/Format/DefinitionBlockSeparatorTest.cpp
@@ -144,7 +144,7 @@ TEST_F(DefinitionBlockSeparatorTest, Basic) {
Style);
FormatStyle BreakAfterReturnTypeStyle = Style;
- BreakAfterReturnTypeStyle.AlwaysBreakAfterReturnType = FormatStyle::RTBS_All;
+ BreakAfterReturnTypeStyle.BreakAfterReturnType = FormatStyle::RTBS_All;
// Test uppercased long typename
verifyFormat("class Foo {\n"
" void\n"
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 79cd521b6a99..b0687eaecb10 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -9870,7 +9870,7 @@ TEST_F(FormatTest, ReturnTypeBreakingStyle) {
Style.ColumnLimit = 60;
// No declarations or definitions should be moved to own line.
- Style.AlwaysBreakAfterReturnType = FormatStyle::RTBS_None;
+ Style.BreakAfterReturnType = FormatStyle::RTBS_None;
verifyFormat("class A {\n"
" int f() { return 1; }\n"
" int g();\n"
@@ -9884,7 +9884,7 @@ TEST_F(FormatTest, ReturnTypeBreakingStyle) {
Style);
// It is now allowed to break after a short return type if necessary.
- Style.AlwaysBreakAfterReturnType = FormatStyle::RTBS_Automatic;
+ Style.BreakAfterReturnType = FormatStyle::RTBS_Automatic;
verifyFormat("class A {\n"
" int f() { return 1; }\n"
" int g();\n"
@@ -9898,7 +9898,7 @@ TEST_F(FormatTest, ReturnTypeBreakingStyle) {
Style);
// It now must never break after a short return type.
- Style.AlwaysBreakAfterReturnType = FormatStyle::RTBS_ExceptShortType;
+ Style.BreakAfterReturnType = FormatStyle::RTBS_ExceptShortType;
verifyFormat("class A {\n"
" int f() { return 1; }\n"
" int g();\n"
@@ -9913,7 +9913,7 @@ TEST_F(FormatTest, ReturnTypeBreakingStyle) {
// All declarations and definitions should have the return type moved to its
// own line.
- Style.AlwaysBreakAfterReturnType = FormatStyle::RTBS_All;
+ Style.BreakAfterReturnType = FormatStyle::RTBS_All;
Style.TypenameMacros = {"LIST"};
verifyFormat("SomeType\n"
"funcdecl(LIST(uint64_t));",
@@ -9940,7 +9940,7 @@ TEST_F(FormatTest, ReturnTypeBreakingStyle) {
// Top-level definitions, and no kinds of declarations should have the
// return type moved to its own line.
- Style.AlwaysBreakAfterReturnType = FormatStyle::RTBS_TopLevelDefinitions;
+ Style.BreakAfterReturnType = FormatStyle::RTBS_TopLevelDefinitions;
verifyFormat("class B {\n"
" int f() { return 1; }\n"
" int g();\n"
@@ -9954,7 +9954,7 @@ TEST_F(FormatTest, ReturnTypeBreakingStyle) {
// Top-level definitions and declarations should have the return type moved
// to its own line.
- Style.AlwaysBreakAfterReturnType = FormatStyle::RTBS_TopLevel;
+ Style.BreakAfterReturnType = FormatStyle::RTBS_TopLevel;
verifyFormat("class C {\n"
" int f() { return 1; }\n"
" int g();\n"
@@ -9971,7 +9971,7 @@ TEST_F(FormatTest, ReturnTypeBreakingStyle) {
// All definitions should have the return type moved to its own line, but no
// kinds of declarations.
- Style.AlwaysBreakAfterReturnType = FormatStyle::RTBS_AllDefinitions;
+ Style.BreakAfterReturnType = FormatStyle::RTBS_AllDefinitions;
verifyFormat("class D {\n"
" int\n"
" f() {\n"
@@ -11939,7 +11939,7 @@ TEST_F(FormatTest, UnderstandsAttributes) {
"aaaaaaaaaaaaaaaaaaaaaaa(int i);");
verifyFormat("__attribute__((nodebug)) ::qualified_type f();");
FormatStyle AfterType = getLLVMStyle();
- AfterType.AlwaysBreakAfterReturnType = FormatStyle::RTBS_All;
+ AfterType.BreakAfterReturnType = FormatStyle::RTBS_All;
verifyFormat("__attribute__((nodebug)) void\n"
"foo() {}",
AfterType);
diff --git a/clang/unittests/Format/FormatTestCSharp.cpp b/clang/unittests/Format/FormatTestCSharp.cpp
index 6f5e1e41ef7e..de261c094830 100644
--- a/clang/unittests/Format/FormatTestCSharp.cpp
+++ b/clang/unittests/Format/FormatTestCSharp.cpp
@@ -505,7 +505,7 @@ TEST_F(FormatTestCSharp, CSharpNullForgiving) {
TEST_F(FormatTestCSharp, AttributesIndentation) {
FormatStyle Style = getMicrosoftStyle(FormatStyle::LK_CSharp);
- Style.AlwaysBreakAfterReturnType = FormatStyle::RTBS_None;
+ Style.BreakAfterReturnType = FormatStyle::RTBS_None;
verifyFormat("[STAThread]\n"
"static void Main(string[] args)\n"