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 @@ -12664,6 +12664,12 @@ TEST_F(FormatTest, UnderstandsAttributes) {
12664
12664
verifyFormat("__attr1() ::qualified_type f();", CustomAttrs);
12665
12665
verifyFormat("__attr1(nodebug) ::qualified_type f();", CustomAttrs);
12666
12666
12667
+ CustomAttrs.AttributeMacros.push_back("my_attr_name");
12668
+ verifyFormat("void MyGoodOldFunction(\n"
12669
+ " void *const long_enough = nullptr,\n"
12670
+ " void *my_attr_name even_longeeeeeeeeeeeeeeeeer = nullptr);",
12671
+ CustomAttrs);
12672
+
12667
12673
// Check that these are not parsed as function declarations:
12668
12674
CustomAttrs.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_None;
12669
12675
CustomAttrs.BreakBeforeBraces = FormatStyle::BS_Allman;
You can’t perform that action at this time.
0 commit comments