diff options
author | rmarker <37921131+rmarker@users.noreply.github.com> | 2024-02-05 06:56:32 +1030 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-04 12:26:32 -0800 |
commit | 256200732111afd03bb7437564f3a3d77c0ec3f5 (patch) | |
tree | b4beee78935f7d40cb6e91123788d07232baa1f6 /clang/unittests/Format/ConfigParseTest.cpp | |
parent | 9ff83f12fe406f9c3c6b2cd0ee96660a7485f29f (diff) | |
download | llvm-256200732111afd03bb7437564f3a3d77c0ec3f5.zip llvm-256200732111afd03bb7437564f3a3d77c0ec3f5.tar.gz llvm-256200732111afd03bb7437564f3a3d77c0ec3f5.tar.bz2 |
[clang-format] Add Automatic and ExceptShortType options for AlwaysBreakAfterReturnType. (#78011)
The RTBS_None option in Clang-format avoids breaking after a short
return type.
However, there was an issue with the behaviour in that it wouldn't take
the leading indentation of the line into account.
This meant that the behaviour wasn't applying when intended.
In order to address this situation without breaking the existing
formatting, RTBS_None has been deprecated.
In its place are two new options for AlwaysBreakAfterReturnType.
The option RTBS_Automatic will break after the return type based on
PenaltyReturnTypeOnItsOwnLine.
The option RTBS_ExceptShortType will take the leading indentation into
account and prevent breaking after short return types.
This allows the inconsistent behaviour of RTBS_None to be avoided and
users to decide whether they want to allow breaking after short return
types or not.
Resolves #78010
Diffstat (limited to 'clang/unittests/Format/ConfigParseTest.cpp')
-rw-r--r-- | clang/unittests/Format/ConfigParseTest.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/clang/unittests/Format/ConfigParseTest.cpp b/clang/unittests/Format/ConfigParseTest.cpp index 6436581..3f1fc893 100644 --- a/clang/unittests/Format/ConfigParseTest.cpp +++ b/clang/unittests/Format/ConfigParseTest.cpp @@ -680,6 +680,10 @@ TEST(ConfigParseTest, ParsesConfiguration) { Style.AlwaysBreakAfterReturnType = FormatStyle::RTBS_All; CHECK_PARSE("AlwaysBreakAfterReturnType: None", AlwaysBreakAfterReturnType, FormatStyle::RTBS_None); + CHECK_PARSE("AlwaysBreakAfterReturnType: Automatic", + AlwaysBreakAfterReturnType, FormatStyle::RTBS_Automatic); + CHECK_PARSE("AlwaysBreakAfterReturnType: ExceptShortType", + AlwaysBreakAfterReturnType, FormatStyle::RTBS_ExceptShortType); CHECK_PARSE("AlwaysBreakAfterReturnType: All", AlwaysBreakAfterReturnType, FormatStyle::RTBS_All); CHECK_PARSE("AlwaysBreakAfterReturnType: TopLevel", |