Previously these were formatting as catch (E & e) because the inner parenthesis
was being marked as an expression.
Patch by Thomas Gibson-Robinson.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188153
91177308-0d34-0410-b5e6-
96231b3b80d8
} else if (Current.isOneOf(tok::kw_return, tok::kw_throw) ||
(Current.is(tok::l_paren) && !Line.MustBeDeclaration &&
!Line.InPPDirective &&
- (!Current.Previous || Current.Previous->isNot(tok::kw_for)))) {
+ (!Current.Previous ||
+ !Current.Previous->isOneOf(tok::kw_for, tok::kw_catch)))) {
Contexts.back().IsExpression = true;
} else if (Current.isOneOf(tok::r_paren, tok::greater, tok::comma)) {
for (FormatToken *Previous = Current.Previous;
BreakBeforeBraceShortIfs);
}
+TEST_F(FormatTest, CatchExceptionReferenceBinding) {
+ verifyFormat("void f() {\n"
+ " try {\n"
+ " }\n"
+ " catch (const Exception &e) {\n"
+ " }\n"
+ "}\n",
+ getLLVMStyle());
+}
+
TEST_F(FormatTest, UnderstandsPragmas) {
verifyFormat("#pragma omp reduction(| : var)");
verifyFormat("#pragma omp reduction(+ : var)");