[clang] [clang-format] add an option to insert a space only for non-code block empty braces, not for empty parentheses (PR #93634)

Kohei Asano via cfe-commits cfe-commits at lists.llvm.org
Wed May 29 19:54:44 PDT 2024


================
@@ -14027,6 +14027,11 @@ TEST_F(FormatTest, LayoutCxx11BraceInitializers) {
   SpaceBetweenBraces.SpacesInParens = FormatStyle::SIPO_Custom;
   SpaceBetweenBraces.SpacesInParensOptions.InEmptyParentheses = true;
   verifyFormat("vector< int > x{ };", SpaceBetweenBraces);
+  SpaceBetweenBraces.SpacesInParens = FormatStyle::SIPO_Custom;
+  SpaceBetweenBraces.SpacesInParensOptions.InEmptyParentheses = false;
+  SpaceBetweenBraces.SpacesInParensOptions.Other = false;
+  SpaceBetweenBraces.SpacesInParensOptions.InEmptyBraces = true;
+  verifyFormat("T x = { };\nf(x, { });\ng();", SpaceBetweenBraces);
 }
----------------
khei4 wrote:

Sounds reasonable, I replace `f(x, { });` with `toImpl(listenerRef)->use({ });\n` and drop a comment, thanks!

https://github.com/llvm/llvm-project/pull/93634


More information about the cfe-commits mailing list