From 6b825c2e1e691deca41c6f979164b5d20c203593 Mon Sep 17 00:00:00 2001 From: Daniel Jasper <djasper@google.com> Date: Wed, 16 Jan 2013 07:19:28 +0000 Subject: [PATCH] Never merge < and ::, as it produces different tokens. Before: vector<::Type> t; After: vector< ::Type> t; git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172601 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Format/Format.cpp | 8 ++++---- unittests/Format/FormatTest.cpp | 4 ++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/Format/Format.cpp b/lib/Format/Format.cpp index 9477f5e014d..939038e2a5f 100644 --- a/lib/Format/Format.cpp +++ b/lib/Format/Format.cpp @@ -1176,6 +1176,10 @@ private: Right.is(tok::l_paren) || Right.is(tok::l_brace) || Right.is(tok::kw_true) || Right.is(tok::kw_false))) return false; + if (Left.is(tok::coloncolon)) + return false; + if (Right.is(tok::coloncolon)) + return Left.isNot(tok::identifier) && Left.isNot(tok::greater); if (Left.is(tok::less) || Right.is(tok::greater) || Right.is(tok::less)) return false; if (Right.is(tok::amp) || Right.is(tok::star)) @@ -1191,10 +1195,6 @@ private: return false; if (Right.is(tok::l_square) && Right.Type != TT_ObjCMethodExpr) return false; - if (Left.is(tok::coloncolon) || - (Right.is(tok::coloncolon) && - (Left.is(tok::identifier) || Left.is(tok::greater)))) - return false; if (Left.is(tok::period) || Right.is(tok::period)) return false; if (Left.is(tok::colon)) diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index ac61af3bfae..ca022a4bbe8 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -131,6 +131,10 @@ TEST_F(FormatTest, FormatsNestedCall) { verifyFormat("Method(f1(f2, (f3())));"); } +TEST_F(FormatTest, ImportantSpaces) { + verifyFormat("vector< ::Type> v;"); +} + //===----------------------------------------------------------------------===// // Tests for control statements. //===----------------------------------------------------------------------===// -- GitLab