Fix an issue with the formatting of stars in default values.
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
diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp
index ca8d595..1a55985 100644
--- a/lib/Format/TokenAnnotator.cpp
+++ b/lib/Format/TokenAnnotator.cpp
@@ -519,7 +519,7 @@
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;
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index 56f39e8..f5250bc 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/unittests/Format/FormatTest.cpp
@@ -1549,6 +1549,7 @@
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"