r174500 - Fix an issue with the formatting of stars in default values.
Daniel Jasper
djasper at google.com
Wed Feb 6 02:57:43 PST 2013
Author: djasper
Date: Wed Feb 6 04:57:42 2013
New Revision: 174500
URL: http://llvm.org/viewvc/llvm-project?rev=174500&view=rev
Log:
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);
Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=174500&r1=174499&r2=174500&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Wed Feb 6 04:57:42 2013
@@ -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;
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=174500&r1=174499&r2=174500&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Wed Feb 6 04:57:42 2013
@@ -1549,6 +1549,7 @@ TEST_F(FormatTest, UnderstandsUsesOfStar
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"
More information about the cfe-commits
mailing list