Skip to content

Commit

Permalink
[clang-format] Insert a space between l_paren and ref-qualifier (llvm…
Browse files Browse the repository at this point in the history
  • Loading branch information
owenca authored Oct 9, 2024
1 parent a579782 commit 1809d0f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions clang/lib/Format/TokenAnnotator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5454,6 +5454,10 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line,
}
if ((Left.is(TT_TemplateOpener)) != (Right.is(TT_TemplateCloser)))
return ShouldAddSpacesInAngles();
if (Left.is(tok::r_paren) && Right.is(TT_PointerOrReference) &&
Right.isOneOf(tok::amp, tok::ampamp)) {
return true;
}
// Space before TT_StructuredBindingLSquare.
if (Right.is(TT_StructuredBindingLSquare)) {
return !Left.isOneOf(tok::amp, tok::ampamp) ||
Expand Down
1 change: 1 addition & 0 deletions clang/unittests/Format/FormatTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11519,6 +11519,7 @@ TEST_F(FormatTest, UnderstandsFunctionRefQualification) {
AlignLeft);
verifyFormat("template <typename T> void operator=(T) & {}", AlignLeft);
verifyFormat("template <typename T> void operator=(T) && {}", AlignLeft);
verifyFormat("for (foo<void() &&>& cb : X)", AlignLeft);

FormatStyle AlignMiddle = getLLVMStyle();
AlignMiddle.PointerAlignment = FormatStyle::PAS_Middle;
Expand Down

0 comments on commit 1809d0f

Please sign in to comment.