Skip to content

Commit

Permalink
[clang-format] Fix bad indentation with attribute and templated type (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
XDeme1 committed Dec 29, 2023
1 parent ad554d6 commit 41ef6fc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion clang/lib/Format/ContinuationIndenter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ bool ContinuationIndenter::mustBreak(const LineState &State) {
}
if ((startsNextParameter(Current, Style) || Previous.is(tok::semi) ||
(Previous.is(TT_TemplateCloser) && Current.is(TT_StartOfName) &&
Style.isCpp() &&
State.Line->First->isNot(TT_AttributeSquare) && Style.isCpp() &&
// FIXME: This is a temporary workaround for the case where clang-format
// sets BreakBeforeParameter to avoid bin packing and this creates a
// completely unnecessary line break after a template type that isn't
Expand Down
5 changes: 5 additions & 0 deletions clang/unittests/Format/FormatTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26295,6 +26295,8 @@ TEST_F(FormatTest, BreakAfterAttributes) {
constexpr StringRef Code("[[maybe_unused]] const int i;\n"
"[[foo([[]])]] [[maybe_unused]]\n"
"int j;\n"
"[[maybe_unused]]\n"
"foo<int> k;\n"
"[[nodiscard]] inline int f(int &i);\n"
"[[foo([[]])]] [[nodiscard]]\n"
"int g(int &i);\n"
Expand All @@ -26315,6 +26317,7 @@ TEST_F(FormatTest, BreakAfterAttributes) {
Style.BreakAfterAttributes = FormatStyle::ABS_Never;
verifyFormat("[[maybe_unused]] const int i;\n"
"[[foo([[]])]] [[maybe_unused]] int j;\n"
"[[maybe_unused]] foo<int> k;\n"
"[[nodiscard]] inline int f(int &i);\n"
"[[foo([[]])]] [[nodiscard]] int g(int &i);\n"
"[[nodiscard]] inline int f(int &i) {\n"
Expand All @@ -26332,6 +26335,8 @@ TEST_F(FormatTest, BreakAfterAttributes) {
"const int i;\n"
"[[foo([[]])]] [[maybe_unused]]\n"
"int j;\n"
"[[maybe_unused]]\n"
"foo<int> k;\n"
"[[nodiscard]]\n"
"inline int f(int &i);\n"
"[[foo([[]])]] [[nodiscard]]\n"
Expand Down

0 comments on commit 41ef6fc

Please sign in to comment.