diff --git a/clang/lib/Format/WhitespaceManager.cpp b/clang/lib/Format/WhitespaceManager.cpp --- a/clang/lib/Format/WhitespaceManager.cpp +++ b/clang/lib/Format/WhitespaceManager.cpp @@ -709,6 +709,8 @@ for (FormatToken *Next = C.Tok->Next; Next; Next = Next->Next) { if (Next->is(tok::comment)) continue; + if (Next->is(TT_PointerOrReference)) + return false; if (!Next->Tok.getIdentifierInfo()) break; if (Next->isOneOf(TT_StartOfName, TT_FunctionDeclarationName, diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -13945,6 +13945,10 @@ verifyFormat("int oneTwoThree{0}; // comment\n" "unsigned oneTwo; // comment", Alignment); + verifyFormat("unsigned int * a;\n" + "int * b;\n" + "unsigned int Const *c;", + Alignment); EXPECT_EQ("float const a = 5;\n" "\n" "int oneTwoThree = 123;", @@ -14249,6 +14253,12 @@ EXPECT_EQ("DECOR1 /**/ int8_t /**/ DECOR2 /**/\n" "foo(int a);", format("DECOR1 /**/ int8_t /**/ DECOR2 /**/ foo (int a);", Style)); + + Alignment.PointerAlignment = FormatStyle::PAS_Left; + verifyFormat("unsigned int* a;\n" + "int* b;\n" + "unsigned int Const* c;", + Alignment); } TEST_F(FormatTest, LinuxBraceBreaking) {