Page MenuHomePhabricator

D58934.diff
No OneTemporary

File Metadata

Created
Mon, Jul 15, 11:24 AM

D58934.diff

Index: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
===================================================================
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp
@@ -1423,6 +1423,25 @@
case tok::coloncolon:
case tok::kw_mutable:
case tok::kw_noexcept:
+ // Specialization of a template with an integer parameter can contain
+ // arithmetic, logical, comparison and ternary operators.
+ case tok::plus:
+ case tok::minus:
+ case tok::exclaim:
+ case tok::tilde:
+ case tok::slash:
+ case tok::percent:
+ case tok::lessless:
+ case tok::pipe:
+ case tok::pipepipe:
+ case tok::ampamp:
+ case tok::caret:
+ case tok::equalequal:
+ case tok::exclaimequal:
+ case tok::greaterequal:
+ case tok::lessequal:
+ case tok::question:
+ case tok::colon:
nextToken();
break;
case tok::arrow:
Index: cfe/trunk/unittests/Format/FormatTest.cpp
===================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp
+++ cfe/trunk/unittests/Format/FormatTest.cpp
@@ -11846,6 +11846,96 @@
verifyGoogleFormat("auto a = [&b, c](D* d) -> D& {};");
verifyGoogleFormat("auto a = [&b, c](D* d) -> const D* {};");
verifyFormat("[a, a]() -> a<1> {};");
+ verifyFormat("[]() -> foo<5 + 2> { return {}; };");
+ verifyFormat("[]() -> foo<5 - 2> { return {}; };");
+ verifyFormat("[]() -> foo<5 / 2> { return {}; };");
+ verifyFormat("[]() -> foo<5 * 2> { return {}; };");
+ verifyFormat("[]() -> foo<5 % 2> { return {}; };");
+ verifyFormat("[]() -> foo<5 << 2> { return {}; };");
+ verifyFormat("[]() -> foo<!5> { return {}; };");
+ verifyFormat("[]() -> foo<~5> { return {}; };");
+ verifyFormat("[]() -> foo<5 | 2> { return {}; };");
+ verifyFormat("[]() -> foo<5 || 2> { return {}; };");
+ verifyFormat("[]() -> foo<5 & 2> { return {}; };");
+ verifyFormat("[]() -> foo<5 && 2> { return {}; };");
+ verifyFormat("[]() -> foo<5 == 2> { return {}; };");
+ verifyFormat("[]() -> foo<5 != 2> { return {}; };");
+ verifyFormat("[]() -> foo<5 >= 2> { return {}; };");
+ verifyFormat("[]() -> foo<5 <= 2> { return {}; };");
+ verifyFormat("[]() -> foo<5 < 2> { return {}; };");
+ verifyFormat("[]() -> foo<2 ? 1 : 0> { return {}; };");
+ verifyFormat("namespace bar {\n"
+ "// broken:\n"
+ "auto foo{[]() -> foo<5 + 2> { return {}; }};\n"
+ "} // namespace bar");
+ verifyFormat("namespace bar {\n"
+ "// broken:\n"
+ "auto foo{[]() -> foo<5 - 2> { return {}; }};\n"
+ "} // namespace bar");
+ verifyFormat("namespace bar {\n"
+ "// broken:\n"
+ "auto foo{[]() -> foo<5 / 2> { return {}; }};\n"
+ "} // namespace bar");
+ verifyFormat("namespace bar {\n"
+ "// broken:\n"
+ "auto foo{[]() -> foo<5 * 2> { return {}; }};\n"
+ "} // namespace bar");
+ verifyFormat("namespace bar {\n"
+ "// broken:\n"
+ "auto foo{[]() -> foo<5 % 2> { return {}; }};\n"
+ "} // namespace bar");
+ verifyFormat("namespace bar {\n"
+ "// broken:\n"
+ "auto foo{[]() -> foo<5 << 2> { return {}; }};\n"
+ "} // namespace bar");
+ verifyFormat("namespace bar {\n"
+ "// broken:\n"
+ "auto foo{[]() -> foo<!5> { return {}; }};\n"
+ "} // namespace bar");
+ verifyFormat("namespace bar {\n"
+ "// broken:\n"
+ "auto foo{[]() -> foo<~5> { return {}; }};\n"
+ "} // namespace bar");
+ verifyFormat("namespace bar {\n"
+ "// broken:\n"
+ "auto foo{[]() -> foo<5 | 2> { return {}; }};\n"
+ "} // namespace bar");
+ verifyFormat("namespace bar {\n"
+ "// broken:\n"
+ "auto foo{[]() -> foo<5 || 2> { return {}; }};\n"
+ "} // namespace bar");
+ verifyFormat("namespace bar {\n"
+ "// broken:\n"
+ "auto foo{[]() -> foo<5 & 2> { return {}; }};\n"
+ "} // namespace bar");
+ verifyFormat("namespace bar {\n"
+ "// broken:\n"
+ "auto foo{[]() -> foo<5 && 2> { return {}; }};\n"
+ "} // namespace bar");
+ verifyFormat("namespace bar {\n"
+ "// broken:\n"
+ "auto foo{[]() -> foo<5 == 2> { return {}; }};\n"
+ "} // namespace bar");
+ verifyFormat("namespace bar {\n"
+ "// broken:\n"
+ "auto foo{[]() -> foo<5 != 2> { return {}; }};\n"
+ "} // namespace bar");
+ verifyFormat("namespace bar {\n"
+ "// broken:\n"
+ "auto foo{[]() -> foo<5 >= 2> { return {}; }};\n"
+ "} // namespace bar");
+ verifyFormat("namespace bar {\n"
+ "// broken:\n"
+ "auto foo{[]() -> foo<5 <= 2> { return {}; }};\n"
+ "} // namespace bar");
+ verifyFormat("namespace bar {\n"
+ "// broken:\n"
+ "auto foo{[]() -> foo<5 < 2> { return {}; }};\n"
+ "} // namespace bar");
+ verifyFormat("namespace bar {\n"
+ "// broken:\n"
+ "auto foo{[]() -> foo<2 ? 1 : 0> { return {}; }};\n"
+ "} // namespace bar");
verifyFormat("auto aaaaaaaa = [](int i, // break for some reason\n"
" int j) -> int {\n"
" return ffffffffffffffffffffffffffffffffffffffffffff(i * j);\n"

Event Timeline