File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -4078,6 +4078,7 @@ void TokenAnnotator::calculateFormattingInformation(AnnotatedLine &Line) const {
4078
4078
}
4079
4079
4080
4080
bool InFunctionDecl = Line.MightBeFunctionDecl ;
4081
+ bool InParameterList = false ;
4081
4082
for (auto *Current = First->Next ; Current; Current = Current->Next ) {
4082
4083
const FormatToken *Prev = Current->Previous ;
4083
4084
if (Current->is (TT_LineComment)) {
@@ -4132,6 +4133,19 @@ void TokenAnnotator::calculateFormattingInformation(AnnotatedLine &Line) const {
4132
4133
4133
4134
Current->CanBreakBefore =
4134
4135
Current->MustBreakBefore || canBreakBefore (Line, *Current);
4136
+
4137
+ if (Current->is (TT_FunctionDeclarationLParen)) {
4138
+ InParameterList = true ;
4139
+ } else if (Current->is (tok::r_paren)) {
4140
+ const auto *LParen = Current->MatchingParen ;
4141
+ if (LParen && LParen->is (TT_FunctionDeclarationLParen))
4142
+ InParameterList = false ;
4143
+ } else if (InParameterList &&
4144
+ Current->endsSequence (TT_AttributeMacro,
4145
+ TT_PointerOrReference)) {
4146
+ Current->CanBreakBefore = false ;
4147
+ }
4148
+
4135
4149
unsigned ChildSize = 0 ;
4136
4150
if (Prev->Children .size () == 1 ) {
4137
4151
FormatToken &LastOfChild = *Prev->Children [0 ]->Last ;
Original file line number Diff line number Diff line change @@ -12640,6 +12640,12 @@ TEST_F(FormatTest, UnderstandsAttributes) {
12640
12640
AfterType);
12641
12641
12642
12642
FormatStyle CustomAttrs = getLLVMStyle();
12643
+ CustomAttrs.AttributeMacros.push_back("my_attr_name");
12644
+ verifyFormat("void MyGoodOldFunction(\n"
12645
+ " void *const long_enough = nullptr,\n"
12646
+ " void *my_attr_name even_longeeeeeeeeeeeeeeeeer = nullptr);",
12647
+ CustomAttrs);
12648
+
12643
12649
CustomAttrs.AttributeMacros.push_back("__unused");
12644
12650
CustomAttrs.AttributeMacros.push_back("__attr1");
12645
12651
CustomAttrs.AttributeMacros.push_back("__attr2");
You can’t perform that action at this time.
0 commit comments