Index: lib/Format/TokenAnnotator.cpp =================================================================== --- lib/Format/TokenAnnotator.cpp +++ lib/Format/TokenAnnotator.cpp @@ -1540,7 +1540,7 @@ Current->MustBreakBefore || mustBreakBefore(Line, *Current); if (!Current->MustBreakBefore && InFunctionDecl && - Current->is(TT_FunctionDeclarationName)) { + Current->isOneOf(tok::kw_operator, TT_FunctionDeclarationName)) { // FIXME: Line.Last points to other characters than tok::semi // and tok::lbrace. bool IsDefinition = !Line.Last->isOneOf(tok::semi, tok::comment); Index: unittests/Format/FormatTest.cpp =================================================================== --- unittests/Format/FormatTest.cpp +++ unittests/Format/FormatTest.cpp @@ -4668,6 +4668,11 @@ "T *\n" "f(T &c);\n", Style); + verifyFormat("void *\n" + "operator new(std::size_t);", + Style); + verifyFormat("void *operator new(std::size_t) {}", + Style); Style.BreakBeforeBraces = FormatStyle::BS_Stroustrup; verifyFormat("const char *f(void) { return \"\"; }\n" "const char *\n" @@ -4716,6 +4721,11 @@ "}\n" "template T *f(T &c);\n", // No break here. Style); + verifyFormat("void *operator new(std::size_t);", // No break here. + Style); + verifyFormat("void *\n" + "operator new(std::size_t) {}", + Style); Style.BreakBeforeBraces = FormatStyle::BS_Stroustrup; verifyFormat("const char *\n" "f(void)\n" // Break here.