[cfe-commits] r172601 - in /cfe/trunk: lib/Format/Format.cpp unittests/Format/FormatTest.cpp
Daniel Jasper
djasper at google.com
Tue Jan 15 23:19:28 PST 2013
Author: djasper
Date: Wed Jan 16 01:19:28 2013
New Revision: 172601
URL: http://llvm.org/viewvc/llvm-project?rev=172601&view=rev
Log:
Never merge < and ::, as it produces different tokens.
Before: vector<::Type> t;
After: vector< ::Type> t;
Modified:
cfe/trunk/lib/Format/Format.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
Modified: cfe/trunk/lib/Format/Format.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=172601&r1=172600&r2=172601&view=diff
==============================================================================
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Wed Jan 16 01:19:28 2013
@@ -1176,6 +1176,10 @@
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 @@
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))
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=172601&r1=172600&r2=172601&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Wed Jan 16 01:19:28 2013
@@ -131,6 +131,10 @@
verifyFormat("Method(f1(f2, (f3())));");
}
+TEST_F(FormatTest, ImportantSpaces) {
+ verifyFormat("vector< ::Type> v;");
+}
+
//===----------------------------------------------------------------------===//
// Tests for control statements.
//===----------------------------------------------------------------------===//
More information about the cfe-commits
mailing list