Index: clang/lib/Format/FormatTokenLexer.cpp =================================================================== --- clang/lib/Format/FormatTokenLexer.cpp +++ clang/lib/Format/FormatTokenLexer.cpp @@ -401,7 +401,7 @@ if (!Try->is(tok::kw_try)) return false; auto &Next = *(Tokens.end() - 1); - if (Next->isOneOf(tok::l_brace, tok::colon)) + if (Next->isOneOf(tok::l_brace, tok::colon, tok::hash)) return false; if (Tokens.size() > 2) { Index: clang/unittests/Format/FormatTest.cpp =================================================================== --- clang/unittests/Format/FormatTest.cpp +++ clang/unittests/Format/FormatTest.cpp @@ -2743,6 +2743,19 @@ verifyFormat("int catch, size;"); verifyFormat("catch = foo();"); verifyFormat("if (catch < size) {\n return true;\n}"); + + FormatStyle Style = getLLVMStyle(); + Style.BreakBeforeBraces = FormatStyle::BS_Custom; + Style.BraceWrapping.AfterFunction = true; + verifyFormat("#if NO_EX\n" + "try\n" + "#endif\n" + "{\n" + "}\n" + "#if NO_EX\n" + "catch (...) {\n" + "}", + Style); } TEST_F(FormatTest, FormatSEHTryCatch) {