summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Format/TokenAnnotator.cpp3
-rw-r--r--clang/unittests/Format/FormatTest.cpp9
2 files changed, 11 insertions, 1 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index 9802711834e..e584eec368d 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -2580,7 +2580,8 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
(Style.PointerAlignment != FormatStyle::PAS_Right &&
!Line.IsMultiVariableDeclStmt) &&
Left.Previous &&
- !Left.Previous->isOneOf(tok::l_paren, tok::coloncolon));
+ !Left.Previous->isOneOf(tok::l_paren, tok::coloncolon,
+ tok::l_square));
if (Right.is(tok::star) && Left.is(tok::l_paren))
return false;
const auto SpaceRequiredForArrayInitializerLSquare =
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index dc20faf70c5..0f5040488e4 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -14074,6 +14074,15 @@ TEST_F(FormatTest, TypenameMacros) {
verifyFormat("STACK_OF(int*)* a;", Macros);
}
+TEST_F(FormatTest, AmbersandInLamda) {
+ // Test case reported in https://bugs.llvm.org/show_bug.cgi?id=41899
+ FormatStyle AlignStyle = getLLVMStyle();
+ AlignStyle.PointerAlignment = FormatStyle::PAS_Left;
+ verifyFormat("auto lambda = [&a = a]() { a = 2; };", AlignStyle);
+ AlignStyle.PointerAlignment = FormatStyle::PAS_Right;
+ verifyFormat("auto lambda = [&a = a]() { a = 2; };", AlignStyle);
+}
+
} // end namespace
} // end namespace format
} // end namespace clang
OpenPOWER on IntegriCloud