[cfe-commits] r169746 - in /cfe/trunk: lib/Format/Format.cpp unittests/Format/FormatTest.cpp
Daniel Jasper
djasper at google.com
Mon Dec 10 10:59:13 PST 2012
Author: djasper
Date: Mon Dec 10 12:59:13 2012
New Revision: 169746
URL: http://llvm.org/viewvc/llvm-project?rev=169746&view=rev
Log:
Addi formatting tests for pointer template parameters.
Fix spacing before ",".
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=169746&r1=169745&r2=169746&view=diff
==============================================================================
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Mon Dec 10 12:59:13 2012
@@ -689,6 +689,8 @@
}
bool spaceRequiredBetween(Token Left, Token Right) {
+ if (Right.is(tok::r_paren) || Right.is(tok::semi) || Right.is(tok::comma))
+ return false;
if (Left.is(tok::kw_template) && Right.is(tok::less))
return true;
if (Left.is(tok::arrow) || Right.is(tok::arrow))
@@ -725,8 +727,6 @@
return false;
if (Left.is(tok::hash))
return false;
- if (Right.is(tok::r_paren) || Right.is(tok::semi) || Right.is(tok::comma))
- return false;
if (Right.is(tok::l_paren)) {
return !Left.isAnyIdentifier() || isIfForOrWhile(Left);
}
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=169746&r1=169745&r2=169746&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Mon Dec 10 12:59:13 2012
@@ -478,7 +478,17 @@
verifyFormat("int a = b * *c;");
verifyFormat("int main(int argc, char **argv) {\n}");
+ // FIXME: Is this desired for LLVM? Fix if not.
+ verifyFormat("A<int *> a;");
+ verifyFormat("A<int **> a;");
+ verifyFormat("A<int *, int *> a;");
+ verifyFormat("A<int **, int **> a;");
+
verifyGoogleFormat("int main(int argc, char** argv) {\n}");
+ verifyGoogleFormat("A<int*> a;");
+ verifyGoogleFormat("A<int**> a;");
+ verifyGoogleFormat("A<int*, int*> a;");
+ verifyGoogleFormat("A<int**, int**> a;");
}
TEST_F(FormatTest, LineStartsWithSpecialCharacter) {
More information about the cfe-commits
mailing list