diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 67726234a99f4bd9a5429ec737f84e3d6ff94674..5a6d2ddef9fb4605f93aa2179760738a3ba9087a 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -1077,7 +1077,7 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line, return Left.FormatTok->Tok.isLiteral() || ((Left.Type != TT_PointerOrReference) && Left.isNot(tok::l_paren) && !Style.PointerBindsToType); - if (Right.Type == TT_FunctionTypeLParen && + if (Right.Type == TT_FunctionTypeLParen && Left.isNot(tok::l_paren) && (Left.Type != TT_PointerOrReference || Style.PointerBindsToType)) return true; if (Left.Type == TT_PointerOrReference) diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 3bdf59ab9eaa1348070cd8e0ab6b63537ba1415a..96f0ed128b7f47bad64dc1b96035d4c0bb013ae9 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -2981,6 +2981,7 @@ TEST_F(FormatTest, UnderstandsUsesOfStarAndAmp) { verifyIndependentOfContext("return sizeof(int **);"); verifyIndependentOfContext("return sizeof(int ******);"); verifyIndependentOfContext("return (int **&)a;"); + verifyIndependentOfContext("f((*PointerToArray)[10]);"); verifyFormat("void f(Type (*parameter)[10]) {}"); verifyGoogleFormat("return sizeof(int**);"); verifyIndependentOfContext("Type **A = static_cast(P);");