Addi formatting tests for pointer template parameters.
authorDaniel Jasper <djasper@google.com>
Mon, 10 Dec 2012 18:59:13 +0000 (18:59 +0000)
committerDaniel Jasper <djasper@google.com>
Mon, 10 Dec 2012 18:59:13 +0000 (18:59 +0000)
Fix spacing before ",".

llvm-svn: 169746

clang/lib/Format/Format.cpp
clang/unittests/Format/FormatTest.cpp

index 7f1131c..e8faa12 100644 (file)
@@ -689,6 +689,8 @@ private:
   }
 
   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 @@ private:
       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);
     }
index 79cefc4..d70442c 100644 (file)
@@ -478,7 +478,17 @@ TEST_F(FormatTest, UnderstandsUsesOfStar) {
   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) {