Index: lib/Format/Format.cpp =================================================================== --- lib/Format/Format.cpp +++ lib/Format/Format.cpp @@ -1019,6 +1019,8 @@ if (Line->Affected) { cleanupRight(Line->First, tok::comma, tok::comma); cleanupRight(Line->First, TT_CtorInitializerColon, tok::comma); + cleanupRight(Line->First, tok::l_paren, tok::comma); + cleanupLeft(Line->First, tok::comma, tok::r_paren); cleanupLeft(Line->First, TT_CtorInitializerComma, tok::l_brace); cleanupLeft(Line->First, TT_CtorInitializerColon, tok::l_brace); } Index: unittests/Format/CleanupTest.cpp =================================================================== --- unittests/Format/CleanupTest.cpp +++ unittests/Format/CleanupTest.cpp @@ -142,15 +142,16 @@ EXPECT_EQ(Expected, Result); } -TEST_F(CleanupTest, ListSimpleRedundantComma) { - std::string Code = "void f() { std::vector v = {1,2,,,3,{4,5}}; }"; - std::string Expected = "void f() { std::vector v = {1,2,3,{4,5}}; }"; +TEST_F(CleanupTest, ListRedundantComma) { + // Trailing comma in braces is not removed. + std::string Code = "void f() { std::vector v = {1,2,,,3,{4,5,}}; }"; + std::string Expected = "void f() { std::vector v = {1,2,3,{4,5,}}; }"; std::vector Ranges; Ranges.push_back(tooling::Range(40, 0)); std::string Result = cleanup(Code, Ranges); EXPECT_EQ(Expected, Result); - Code = "int main() { f(1,,2,3,,4);}"; + Code = "int main() { f(,1,,2,3,,4,);}"; Expected = "int main() { f(1,2,3,4);}"; Ranges.clear(); Ranges.push_back(tooling::Range(17, 0));