summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/Format/TokenAnnotator.cpp4
-rw-r--r--unittests/Format/FormatTest.cpp2
2 files changed, 5 insertions, 1 deletions
diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp
index be4dc88600..ac95f72b60 100644
--- a/lib/Format/TokenAnnotator.cpp
+++ b/lib/Format/TokenAnnotator.cpp
@@ -313,7 +313,9 @@ private:
updateParameterCount(Left, CurrentToken);
if (CurrentToken->isOneOf(tok::colon, tok::l_brace)) {
FormatToken *Previous = CurrentToken->getPreviousNonComment();
- if (Previous->is(tok::identifier))
+ if ((CurrentToken->is(tok::colon) ||
+ Style.Language == FormatStyle::LK_Proto) &&
+ Previous->is(tok::identifier))
Previous->Type = TT_SelectorName;
if (CurrentToken->is(tok::colon))
Left->Type = TT_DictLiteral;
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index bf69d8b55e..7f1cc5a829 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/unittests/Format/FormatTest.cpp
@@ -5466,6 +5466,8 @@ TEST_F(FormatTest, LayoutCxx11BraceInitializers) {
verifyFormat("int foo(int i) { return fo1{}(i); }");
verifyFormat("auto i = decltype(x){};");
verifyFormat("std::vector<int> v = {1, 0 /* comment */};");
+ verifyFormat("Node n{1, Node{1000}, //\n"
+ " 2};");
// In combination with BinPackParameters = false.
FormatStyle NoBinPacking = getLLVMStyle();