Index: cfe/trunk/lib/Format/TokenAnnotator.cpp =================================================================== --- cfe/trunk/lib/Format/TokenAnnotator.cpp +++ cfe/trunk/lib/Format/TokenAnnotator.cpp @@ -617,7 +617,9 @@ break; case tok::kw_for: if (Style.Language == FormatStyle::LK_JavaScript) { - if (Tok->Previous && Tok->Previous->is(tok::period)) + // x.for and {for: ...} + if ((Tok->Previous && Tok->Previous->is(tok::period)) || + (Tok->Next && Tok->Next->is(tok::colon))) break; // JS' for await ( ... if (CurrentToken && CurrentToken->is(Keywords.kw_await)) Index: cfe/trunk/unittests/Format/FormatTestJS.cpp =================================================================== --- cfe/trunk/unittests/Format/FormatTestJS.cpp +++ cfe/trunk/unittests/Format/FormatTestJS.cpp @@ -323,6 +323,11 @@ " case: string;\n" " default: string;\n" "}\n"); + verifyFormat("const Axis = {\n" + " for: 'for',\n" + " x: 'x'\n" + "};", + "const Axis = {for: 'for', x: 'x'};"); } TEST_F(FormatTestJS, ReservedWordsMethods) {