Skip to content

Commit 0b1d1c6

Browse files
committed
[clang-format] Fix the indent of StartOfName after AttributeMacro
Fix #139510
1 parent 6a1d3ea commit 0b1d1c6

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

clang/lib/Format/ContinuationIndenter.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1475,7 +1475,9 @@ unsigned ContinuationIndenter::getNewLineColumn(const LineState &State) {
14751475
(PreviousNonComment->ClosesTemplateDeclaration ||
14761476
PreviousNonComment->ClosesRequiresClause ||
14771477
(PreviousNonComment->is(TT_AttributeMacro) &&
1478-
Current.isNot(tok::l_paren)) ||
1478+
Current.isNot(tok::l_paren) &&
1479+
!Current.endsSequence(TT_StartOfName, TT_AttributeMacro,
1480+
TT_PointerOrReference)) ||
14791481
PreviousNonComment->isOneOf(
14801482
TT_AttributeRParen, TT_AttributeSquare, TT_FunctionAnnotationRParen,
14811483
TT_JavaAnnotation, TT_LeadingJavaAnnotation))) ||

clang/unittests/Format/FormatTest.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12714,6 +12714,13 @@ TEST_F(FormatTest, UnderstandsAttributes) {
1271412714
verifyGoogleFormat("SomeType* absl_nullable s{InitValue};");
1271512715
verifyGoogleFormat("SomeType* absl_nullability_unknown s(InitValue);");
1271612716
verifyGoogleFormat("SomeType* absl_nullability_unknown s{InitValue};");
12717+
12718+
auto Style = getLLVMStyleWithColumns(60);
12719+
Style.AttributeMacros.push_back("my_fancy_attr");
12720+
Style.PointerAlignment = FormatStyle::PAS_Left;
12721+
verifyFormat("void foo(const MyLongTypeNameeeeeeeeeeeee* my_fancy_attr\n"
12722+
" testttttttttt);",
12723+
Style);
1271712724
}
1271812725

1271912726
TEST_F(FormatTest, UnderstandsPointerQualifiersInCast) {

0 commit comments

Comments
 (0)