[cfe-commits] r172619 - in /cfe/trunk: lib/Format/Format.cpp unittests/Format/FormatTest.cpp
Daniel Jasper
djasper at google.com
Wed Jan 16 08:04:06 PST 2013
Author: djasper
Date: Wed Jan 16 10:04:06 2013
New Revision: 172619
URL: http://llvm.org/viewvc/llvm-project?rev=172619&view=rev
Log:
Improve understanding of unary operators.
Before: int x = ** a;
After: int x = **a;
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=172619&r1=172618&r2=172619&view=diff
==============================================================================
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Wed Jan 16 10:04:06 2013
@@ -1180,7 +1180,7 @@
PrevToken->is(tok::l_brace) || PrevToken->is(tok::comma) ||
PrevToken->is(tok::kw_return) || PrevToken->is(tok::colon) ||
PrevToken->Type == TT_BinaryOperator ||
- PrevToken->Type == TT_CastRParen)
+ PrevToken->Type == TT_UnaryOperator || PrevToken->Type == TT_CastRParen)
return TT_UnaryOperator;
if (PrevToken->FormatTok.Tok.isLiteral() || PrevToken->is(tok::r_paren) ||
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=172619&r1=172618&r2=172619&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Wed Jan 16 10:04:06 2013
@@ -1167,6 +1167,11 @@
verifyGoogleFormat("A<int**, int**> a;");
verifyGoogleFormat("f(b ? *c : *d);");
verifyGoogleFormat("int a = b ? *c : *d;");
+ verifyGoogleFormat("Type* t = **x;");
+ verifyGoogleFormat("Type* t = *++*x;");
+ verifyGoogleFormat("*++*x;");
+ verifyGoogleFormat("Type* t = const_cast<T*>(&*x);");
+ verifyGoogleFormat("Type* t = x++ * y;");
verifyFormat("a = *(x + y);");
verifyFormat("a = &(x + y);");
More information about the cfe-commits
mailing list