summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Format/TokenAnnotator.cpp6
-rw-r--r--unittests/Format/FormatTest.cpp7
2 files changed, 11 insertions, 2 deletions
diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp
index e0552de01d..21518c6824 100644
--- a/lib/Format/TokenAnnotator.cpp
+++ b/lib/Format/TokenAnnotator.cpp
@@ -101,8 +101,10 @@ private:
return true;
}
if (CurrentToken->isOneOf(tok::r_paren, tok::r_square, tok::r_brace,
- tok::pipepipe, tok::ampamp, tok::question,
- tok::colon))
+ tok::question, tok::colon))
+ return false;
+ if (CurrentToken->isOneOf(tok::pipepipe, tok::ampamp) &&
+ Line.First.isNot(tok::kw_template))
return false;
updateParameterCount(Left, CurrentToken);
if (!consumeToken())
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index 20a32e740e..499388e6ba 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/unittests/Format/FormatTest.cpp
@@ -3077,6 +3077,13 @@ TEST_F(FormatTest, UnderstandContextOfRecordTypeKeywords) {
verifyFormat("class A::B::C {\n} n;");
// Template definitions.
+ verifyFormat(
+ "template <typename F>\n"
+ "Matcher(const Matcher<F> &Other,\n"
+ " typename enable_if_c<is_base_of<F, T>::value &&\n"
+ " !is_same<F, T>::value>::type * = 0)\n"
+ " : Implementation(new ImplicitCastMatcher<F>(Other)) {}");
+
// FIXME: This is still incorrectly handled at the formatter side.
verifyFormat("template <> struct X < 15, i < 3 && 42 < 50 && 33<28> {\n};");