r188153 - This change fixes the formatting of statements such as catch (E& e).
Manuel Klimek
klimek at google.com
Sun Aug 11 20:51:18 PDT 2013
Author: klimek
Date: Sun Aug 11 22:51:17 2013
New Revision: 188153
URL: http://llvm.org/viewvc/llvm-project?rev=188153&view=rev
Log:
This change fixes the formatting of statements such as catch (E& e).
Previously these were formatting as catch (E & e) because the inner parenthesis
was being marked as an expression.
Patch by Thomas Gibson-Robinson.
Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=188153&r1=188152&r2=188153&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Sun Aug 11 22:51:17 2013
@@ -592,7 +592,8 @@ private:
} 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;
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=188153&r1=188152&r2=188153&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Sun Aug 11 22:51:17 2013
@@ -5563,6 +5563,16 @@ TEST_F(FormatTest, AllmanBraceBreaking)
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)");
More information about the cfe-commits
mailing list