]> granicus.if.org Git - clang/commitdiff
Fix an issue with the formatting of stars in default values.
authorDaniel Jasper <djasper@google.com>
Wed, 6 Feb 2013 10:57:42 +0000 (10:57 +0000)
committerDaniel Jasper <djasper@google.com>
Wed, 6 Feb 2013 10:57:42 +0000 (10:57 +0000)
Before: void f(int *a = d *e, int b = 0);
After:  void f(int *a = d * e, int b = 0);

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174500 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Format/TokenAnnotator.cpp
unittests/Format/FormatTest.cpp

index ca8d595df76b09951b34dae4c959a42ec3982c53..1a55985905c3f11f2acd41958d14b9bf822cf446 100644 (file)
@@ -519,7 +519,7 @@ private:
     if (getPrecedence(Current) == prec::Assignment) {
       Contexts.back().IsExpression = true;
       AnnotatedToken *Previous = Current.Parent;
-      while (Previous != NULL) {
+      while (Previous != NULL && Previous->isNot(tok::comma)) {
         if (Previous->Type == TT_BinaryOperator &&
             (Previous->is(tok::star) || Previous->is(tok::amp))) {
           Previous->Type = TT_PointerOrReference;
index 56f39e88a227b22a906c3629a334b4788ddf5d85..f5250bc4df54721e8dd022d8901cab10160f2980 100644 (file)
@@ -1549,6 +1549,7 @@ TEST_F(FormatTest, UnderstandsUsesOfStarAndAmp) {
   verifyIndependentOfContext(
       "const char *const p = reinterpret_cast<const char *const>(q);");
   verifyIndependentOfContext("A<int **, int **> a;");
+  verifyIndependentOfContext("void f(int *a = d * e, int *b = c * d);");
 
   verifyFormat(
       "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n"