Skip to content

Commit f7528c4

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

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

clang/lib/Format/ContinuationIndenter.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1475,6 +1475,8 @@ unsigned ContinuationIndenter::getNewLineColumn(const LineState &State) {
14751475
(PreviousNonComment->ClosesTemplateDeclaration ||
14761476
PreviousNonComment->ClosesRequiresClause ||
14771477
(PreviousNonComment->is(TT_AttributeMacro) &&
1478+
!Current.endsSequence(TT_StartOfName, TT_AttributeMacro,
1479+
TT_PointerOrReference) &&
14781480
Current.isNot(tok::l_paren)) ||
14791481
PreviousNonComment->isOneOf(
14801482
TT_AttributeRParen, TT_AttributeSquare, TT_FunctionAnnotationRParen,

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)