diff options
-rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 5 | ||||
-rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 3 |
2 files changed, 7 insertions, 1 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index ef449e44c95..bd4591189f4 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -410,7 +410,10 @@ private: Parent->isUnaryOperator() || // FIXME(bug 36976): ObjC return types shouldn't use TT_CastRParen. Parent->isOneOf(TT_ObjCForIn, TT_CastRParen) || - getBinOpPrecedence(Parent->Tok.getKind(), true, true) > prec::Unknown); + // for (auto && [A,B] : C) && structure binding seen as ObjCMethodExpr + (Parent->isNot(tok::ampamp) && + getBinOpPrecedence(Parent->Tok.getKind(), true, true) > + prec::Unknown)); bool ColonFound = false; unsigned BindingIncrease = 1; diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 09c49b4408e..23ea8a8d8ed 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -12926,6 +12926,9 @@ TEST_F(FormatTest, GuessLanguageWithCpp11AttributeSpecifiers) { guessLanguage("foo.h", "[[using gsl: suppress(\"type\")]];")); EXPECT_EQ( FormatStyle::LK_Cpp, + guessLanguage("foo.h", "for (auto &&[endpoint, stream] : streams_)")); + EXPECT_EQ( + FormatStyle::LK_Cpp, guessLanguage("foo.h", "[[clang::callable_when(\"unconsumed\", \"unknown\")]]")); EXPECT_EQ(FormatStyle::LK_Cpp, guessLanguage("foo.h", "[[foo::bar, ...]]")); |