r249502 - clang-format: Understand array reference types.
Daniel Jasper via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 6 18:41:22 PDT 2015
Author: djasper
Date: Tue Oct 6 20:41:22 2015
New Revision: 249502
URL: http://llvm.org/viewvc/llvm-project?rev=249502&view=rev
Log:
clang-format: Understand array reference types.
Before:
void f(Type(¶meter)[10]) {}
void f(Type (*parameter)[10]) {}
After:
void f(Type (¶meter)[10]) {}
void f(Type (*parameter)[10]) {}
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=249502&r1=249501&r2=249502&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Tue Oct 6 20:41:22 2015
@@ -155,7 +155,7 @@ private:
Left->Type = TT_ObjCMethodExpr;
}
- bool MightBeFunctionType = CurrentToken->is(tok::star);
+ bool MightBeFunctionType = CurrentToken->isOneOf(tok::star, tok::amp);
bool HasMultipleLines = false;
bool HasMultipleParametersOnALine = false;
bool MightBeObjCForRangeLoop =
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=249502&r1=249501&r2=249502&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Tue Oct 6 20:41:22 2015
@@ -5423,6 +5423,7 @@ TEST_F(FormatTest, UnderstandsUsesOfStar
verifyIndependentOfContext("return (int **&)a;");
verifyIndependentOfContext("f((*PointerToArray)[10]);");
verifyFormat("void f(Type (*parameter)[10]) {}");
+ verifyFormat("void f(Type (¶meter)[10]) {}");
verifyGoogleFormat("return sizeof(int**);");
verifyIndependentOfContext("Type **A = static_cast<Type **>(P);");
verifyGoogleFormat("Type** A = static_cast<Type**>(P);");
More information about the cfe-commits
mailing list