summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2015-10-07 01:41:22 +0000
committerDaniel Jasper <djasper@google.com>2015-10-07 01:41:22 +0000
commit4bc013e18c5d9d2d7de2cb9a8df48ffcde51cc9f (patch)
treea9504cc4dc8aed3ac140f6c75a3f8480ffa0edc6
parent0ea4d799e3f196733f69712dfd83129dbd5fabd5 (diff)
downloadbcm5719-llvm-4bc013e18c5d9d2d7de2cb9a8df48ffcde51cc9f.tar.gz
bcm5719-llvm-4bc013e18c5d9d2d7de2cb9a8df48ffcde51cc9f.zip
clang-format: Understand array reference types.
Before: void f(Type(&parameter)[10]) {} void f(Type (*parameter)[10]) {} After: void f(Type (&parameter)[10]) {} void f(Type (*parameter)[10]) {} llvm-svn: 249502
-rw-r--r--clang/lib/Format/TokenAnnotator.cpp2
-rw-r--r--clang/unittests/Format/FormatTest.cpp1
2 files changed, 2 insertions, 1 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index 55a1ddd91c0..e9a78d8f661 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -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 =
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 581b10baafd..6a265f3dd15 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -5423,6 +5423,7 @@ TEST_F(FormatTest, UnderstandsUsesOfStarAndAmp) {
verifyIndependentOfContext("return (int **&)a;");
verifyIndependentOfContext("f((*PointerToArray)[10]);");
verifyFormat("void f(Type (*parameter)[10]) {}");
+ verifyFormat("void f(Type (&parameter)[10]) {}");
verifyGoogleFormat("return sizeof(int**);");
verifyIndependentOfContext("Type **A = static_cast<Type **>(P);");
verifyGoogleFormat("Type** A = static_cast<Type**>(P);");
OpenPOWER on IntegriCloud