Skip to content

Commit 1809d0f

Browse files
authored
[clang-format] Insert a space between l_paren and ref-qualifier (#111465)
Fixes #111346.
1 parent a579782 commit 1809d0f

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

clang/lib/Format/TokenAnnotator.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5454,6 +5454,10 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line,
54545454
}
54555455
if ((Left.is(TT_TemplateOpener)) != (Right.is(TT_TemplateCloser)))
54565456
return ShouldAddSpacesInAngles();
5457+
if (Left.is(tok::r_paren) && Right.is(TT_PointerOrReference) &&
5458+
Right.isOneOf(tok::amp, tok::ampamp)) {
5459+
return true;
5460+
}
54575461
// Space before TT_StructuredBindingLSquare.
54585462
if (Right.is(TT_StructuredBindingLSquare)) {
54595463
return !Left.isOneOf(tok::amp, tok::ampamp) ||

clang/unittests/Format/FormatTest.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11519,6 +11519,7 @@ TEST_F(FormatTest, UnderstandsFunctionRefQualification) {
1151911519
AlignLeft);
1152011520
verifyFormat("template <typename T> void operator=(T) & {}", AlignLeft);
1152111521
verifyFormat("template <typename T> void operator=(T) && {}", AlignLeft);
11522+
verifyFormat("for (foo<void() &&>& cb : X)", AlignLeft);
1152211523

1152311524
FormatStyle AlignMiddle = getLLVMStyle();
1152411525
AlignMiddle.PointerAlignment = FormatStyle::PAS_Middle;

0 commit comments

Comments
 (0)