From 35a94e87046220fb3470685854b881cc0d19fb63 Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Tue, 8 Apr 2014 13:07:41 +0000 Subject: [PATCH] clang-format: Correctly understand arrays of pointers. Before: A a; After: A a; This fixes llvm.org/PR19360. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@205761 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Format/TokenAnnotator.cpp | 2 +- unittests/Format/FormatTest.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index 0034235c32..f890af33de 100644 --- a/lib/Format/TokenAnnotator.cpp +++ b/lib/Format/TokenAnnotator.cpp @@ -245,7 +245,7 @@ private: StartsObjCMethodExpr = false; Left->Type = TT_Unknown; } - if (StartsObjCMethodExpr) { + if (StartsObjCMethodExpr && CurrentToken->Previous != Left) { CurrentToken->Type = TT_ObjCMethodExpr; // determineStarAmpUsage() thinks that '*' '[' is allocating an // array of pointers, but if '[' starts a selector then '*' is a diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index d59ed6c0af..c7bd44c12d 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -4473,6 +4473,7 @@ TEST_F(FormatTest, UnderstandsUsesOfStarAndAmp) { verifyIndependentOfContext("A a;"); verifyIndependentOfContext("A a;"); verifyIndependentOfContext("A a;"); + verifyIndependentOfContext("A a;"); verifyIndependentOfContext( "const char *const p = reinterpret_cast(q);"); verifyIndependentOfContext("A a;"); -- 2.40.0