Skip to content

Commit da8f2d5

Browse files
committed
Revert "[clang-format] Allow breaking before kw___attribute (#128623)"
This reverts commit 8fc8a84, which caused a regression. Fixes #136675.
1 parent 1a99f79 commit da8f2d5

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

clang/lib/Format/TokenAnnotator.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -6242,8 +6242,6 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line,
62426242
TT_ClassHeadName, tok::kw_operator)) {
62436243
return true;
62446244
}
6245-
if (Right.isAttribute())
6246-
return true;
62476245
if (Left.is(TT_PointerOrReference))
62486246
return false;
62496247
if (Right.isTrailingComment()) {
@@ -6388,6 +6386,9 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line,
63886386
tok::less, tok::coloncolon);
63896387
}
63906388

6389+
if (Right.isAttribute())
6390+
return true;
6391+
63916392
if (Right.is(tok::l_square) && Right.is(TT_AttributeSquare))
63926393
return Left.isNot(TT_AttributeSquare);
63936394

clang/unittests/Format/FormatTest.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -12645,9 +12645,6 @@ TEST_F(FormatTest, UnderstandsAttributes) {
1264512645
verifyFormat("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa __attribute__((unused))\n"
1264612646
"aaaaaaaaaaaaaaaaaaaaaaa(int i);");
1264712647
verifyFormat("__attribute__((nodebug)) ::qualified_type f();");
12648-
verifyFormat(
12649-
"RenderWidgetHostViewCocoa *\n"
12650-
" __attribute__((objc_precise_lifetime)) keepSelfAlive = self;");
1265112648
FormatStyle AfterType = getLLVMStyle();
1265212649
AfterType.BreakAfterReturnType = FormatStyle::RTBS_All;
1265312650
verifyFormat("__attribute__((nodebug)) void\n"

0 commit comments

Comments
 (0)