r208288 - clang-format: Fix binary operator detection before lambdas.
Daniel Jasper
djasper at google.com
Thu May 8 01:50:10 PDT 2014
Author: djasper
Date: Thu May 8 03:50:10 2014
New Revision: 208288
URL: http://llvm.org/viewvc/llvm-project?rev=208288&view=rev
Log:
clang-format: Fix binary operator detection before lambdas.
Before:
bool foo = true&& [] { return false; }();
After:
bool foo = true && [] { return false; }();
Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=208288&r1=208287&r2=208288&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Thu May 8 03:50:10 2014
@@ -904,7 +904,7 @@ private:
PrevToken->Type == TT_UnaryOperator || PrevToken->Type == TT_CastRParen)
return TT_UnaryOperator;
- if (NextToken->is(tok::l_square))
+ if (NextToken->is(tok::l_square) && NextToken->Type != TT_LambdaLSquare)
return TT_PointerOrReference;
if (PrevToken->is(tok::r_paren) && PrevToken->MatchingParen &&
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=208288&r1=208287&r2=208288&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Thu May 8 03:50:10 2014
@@ -4612,6 +4612,7 @@ TEST_F(FormatTest, UnderstandsUsesOfStar
verifyIndependentOfContext("void f(int *a = d * e, int *b = c * d);");
verifyFormat("for (char **a = b; *a; ++a) {\n}");
verifyFormat("for (; a && b;) {\n}");
+ verifyFormat("bool foo = true && [] { return false; }();");
verifyFormat(
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n"
More information about the cfe-commits
mailing list