Author: Owen Pan Date: 2026-03-21T17:10:21-07:00 New Revision: f014202dac325c576addd857b558f7d9d2b28905
URL: https://github.com/llvm/llvm-project/commit/f014202dac325c576addd857b558f7d9d2b28905 DIFF: https://github.com/llvm/llvm-project/commit/f014202dac325c576addd857b558f7d9d2b28905.diff LOG: [clang-format][NFC] Remove redundant parens enclosing braced list Added: Modified: clang/lib/Format/Format.cpp clang/lib/Format/FormatToken.h clang/unittests/Format/ConfigParseTest.cpp clang/unittests/Format/QualifierFixerTest.cpp Removed: ################################################################################ diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index d6bff8e402cf1..2b0aa1735c895 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -56,7 +56,7 @@ struct ScalarEnumerationTraits<FormatStyle::BreakBeforeNoexceptSpecifierStyle> { template <> struct MappingTraits<FormatStyle::AlignConsecutiveStyle> { static void enumInput(IO &IO, FormatStyle::AlignConsecutiveStyle &Value) { - IO.enumCase(Value, "None", FormatStyle::AlignConsecutiveStyle({})); + IO.enumCase(Value, "None", FormatStyle::AlignConsecutiveStyle{}); IO.enumCase(Value, "Consecutive", FormatStyle::AlignConsecutiveStyle( {/*Enabled=*/true, /*AcrossEmptyLines=*/false, @@ -89,7 +89,7 @@ template <> struct MappingTraits<FormatStyle::AlignConsecutiveStyle> { /*AcrossComments=*/false, /*AlignCompound=*/false, /*AlignFunctionDeclarations=*/true, /*AlignFunctionPointers=*/false, /*PadOperators=*/true})); - IO.enumCase(Value, "false", FormatStyle::AlignConsecutiveStyle({})); + IO.enumCase(Value, "false", FormatStyle::AlignConsecutiveStyle{}); } static void mapping(IO &IO, FormatStyle::AlignConsecutiveStyle &Value) { @@ -791,22 +791,22 @@ template <> struct ScalarEnumerationTraits<FormatStyle::ShortRecordStyle> { template <> struct MappingTraits<FormatStyle::SortIncludesOptions> { static void enumInput(IO &IO, FormatStyle::SortIncludesOptions &Value) { - IO.enumCase(Value, "Never", FormatStyle::SortIncludesOptions({})); + IO.enumCase(Value, "Never", FormatStyle::SortIncludesOptions{}); IO.enumCase(Value, "CaseInsensitive", - FormatStyle::SortIncludesOptions({/*Enabled=*/true, - /*IgnoreCase=*/true, - /*IgnoreExtension=*/false})); + FormatStyle::SortIncludesOptions{/*Enabled=*/true, + /*IgnoreCase=*/true, + /*IgnoreExtension=*/false}); IO.enumCase(Value, "CaseSensitive", - FormatStyle::SortIncludesOptions({/*Enabled=*/true, - /*IgnoreCase=*/false, - /*IgnoreExtension=*/false})); + FormatStyle::SortIncludesOptions{/*Enabled=*/true, + /*IgnoreCase=*/false, + /*IgnoreExtension=*/false}); // For backward compatibility. - IO.enumCase(Value, "false", FormatStyle::SortIncludesOptions({})); + IO.enumCase(Value, "false", FormatStyle::SortIncludesOptions{}); IO.enumCase(Value, "true", - FormatStyle::SortIncludesOptions({/*Enabled=*/true, - /*IgnoreCase=*/false, - /*IgnoreExtension=*/false})); + FormatStyle::SortIncludesOptions{/*Enabled=*/true, + /*IgnoreCase=*/false, + /*IgnoreExtension=*/false}); } static void mapping(IO &IO, FormatStyle::SortIncludesOptions &Value) { diff --git a/clang/lib/Format/FormatToken.h b/clang/lib/Format/FormatToken.h index 56abd702aaafe..ba9a95440f0c2 100644 --- a/clang/lib/Format/FormatToken.h +++ b/clang/lib/Format/FormatToken.h @@ -1327,158 +1327,142 @@ struct AdditionalKeywords { // treatment like `showcancelled` or they should be treated as identifiers // like `int` and `logic`. VerilogExtraKeywords = - std::unordered_set<IdentifierInfo *>({kw_always, - kw_always_comb, - kw_always_ff, - kw_always_latch, - kw_assert, - kw_assign, - kw_assume, - kw_automatic, - kw_before, - kw_begin, - kw_bins, - kw_binsof, - kw_casex, - kw_casez, - kw_celldefine, - kw_checker, - kw_clocking, - kw_constraint, - kw_context, - kw_cover, - kw_covergroup, - kw_coverpoint, - kw_disable, - kw_dist, - kw_edge, - kw_end, - kw_endcase, - kw_endchecker, - kw_endclass, - kw_endclocking, - kw_endfunction, - kw_endgenerate, - kw_endgroup, - kw_endinterface, - kw_endmodule, - kw_endpackage, - kw_endprimitive, - kw_endprogram, - kw_endproperty, - kw_endsequence, - kw_endspecify, - kw_endtable, - kw_endtask, - kw_extends, - kw_final, - kw_foreach, - kw_forever, - kw_fork, - kw_function, - kw_generate, - kw_highz0, - kw_highz1, - kw_iff, - kw_ifnone, - kw_ignore_bins, - kw_illegal_bins, - kw_implements, - kw_import, - kw_initial, - kw_inout, - kw_input, - kw_inside, - kw_interconnect, - kw_interface, - kw_intersect, - kw_join, - kw_join_any, - kw_join_none, - kw_large, - kw_let, - kw_local, - kw_localparam, - kw_macromodule, - kw_matches, - kw_medium, - kw_module, - kw_negedge, - kw_output, - kw_package, - kw_packed, - kw_parameter, - kw_posedge, - kw_primitive, - kw_priority, - kw_program, - kw_property, - kw_pull0, - kw_pull1, - kw_pure, - kw_rand, - kw_randc, - kw_randcase, - kw_randsequence, - kw_ref, - kw_repeat, - kw_sample, - kw_scalared, - kw_sequence, - kw_small, - kw_soft, - kw_solve, - kw_specify, - kw_specparam, - kw_strong0, - kw_strong1, - kw_supply0, - kw_supply1, - kw_table, - kw_tagged, - kw_task, - kw_tri, - kw_tri0, - kw_tri1, - kw_triand, - kw_trior, - kw_trireg, - kw_unique, - kw_unique0, - kw_uwire, - kw_var, - kw_vectored, - kw_wait, - kw_wand, - kw_weak0, - kw_weak1, - kw_wildcard, - kw_wire, - kw_with, - kw_wor, - kw_verilogHash, - kw_verilogHashHash}); - - TableGenExtraKeywords = std::unordered_set<IdentifierInfo *>({ - kw_assert, - kw_bit, - kw_bits, - kw_code, - kw_dag, - kw_def, - kw_defm, - kw_defset, - kw_defvar, - kw_dump, - kw_foreach, - kw_in, - kw_include, - kw_let, - kw_list, - kw_multiclass, - kw_string, - kw_then, - }); + std::unordered_set<IdentifierInfo *>{kw_always, + kw_always_comb, + kw_always_ff, + kw_always_latch, + kw_assert, + kw_assign, + kw_assume, + kw_automatic, + kw_before, + kw_begin, + kw_bins, + kw_binsof, + kw_casex, + kw_casez, + kw_celldefine, + kw_checker, + kw_clocking, + kw_constraint, + kw_context, + kw_cover, + kw_covergroup, + kw_coverpoint, + kw_disable, + kw_dist, + kw_edge, + kw_end, + kw_endcase, + kw_endchecker, + kw_endclass, + kw_endclocking, + kw_endfunction, + kw_endgenerate, + kw_endgroup, + kw_endinterface, + kw_endmodule, + kw_endpackage, + kw_endprimitive, + kw_endprogram, + kw_endproperty, + kw_endsequence, + kw_endspecify, + kw_endtable, + kw_endtask, + kw_extends, + kw_final, + kw_foreach, + kw_forever, + kw_fork, + kw_function, + kw_generate, + kw_highz0, + kw_highz1, + kw_iff, + kw_ifnone, + kw_ignore_bins, + kw_illegal_bins, + kw_implements, + kw_import, + kw_initial, + kw_inout, + kw_input, + kw_inside, + kw_interconnect, + kw_interface, + kw_intersect, + kw_join, + kw_join_any, + kw_join_none, + kw_large, + kw_let, + kw_local, + kw_localparam, + kw_macromodule, + kw_matches, + kw_medium, + kw_module, + kw_negedge, + kw_output, + kw_package, + kw_packed, + kw_parameter, + kw_posedge, + kw_primitive, + kw_priority, + kw_program, + kw_property, + kw_pull0, + kw_pull1, + kw_pure, + kw_rand, + kw_randc, + kw_randcase, + kw_randsequence, + kw_ref, + kw_repeat, + kw_sample, + kw_scalared, + kw_sequence, + kw_small, + kw_soft, + kw_solve, + kw_specify, + kw_specparam, + kw_strong0, + kw_strong1, + kw_supply0, + kw_supply1, + kw_table, + kw_tagged, + kw_task, + kw_tri, + kw_tri0, + kw_tri1, + kw_triand, + kw_trior, + kw_trireg, + kw_unique, + kw_unique0, + kw_uwire, + kw_var, + kw_vectored, + kw_wait, + kw_wand, + kw_weak0, + kw_weak1, + kw_wildcard, + kw_wire, + kw_with, + kw_wor, + kw_verilogHash, + kw_verilogHashHash}; + + TableGenExtraKeywords = std::unordered_set<IdentifierInfo *>{ + kw_assert, kw_bit, kw_bits, kw_code, kw_dag, kw_def, + kw_defm, kw_defset, kw_defvar, kw_dump, kw_foreach, kw_in, + kw_include, kw_let, kw_list, kw_multiclass, kw_string, kw_then}; } // Context sensitive keywords. diff --git a/clang/unittests/Format/ConfigParseTest.cpp b/clang/unittests/Format/ConfigParseTest.cpp index a7b410f03abfe..953f57da26cd9 100644 --- a/clang/unittests/Format/ConfigParseTest.cpp +++ b/clang/unittests/Format/ConfigParseTest.cpp @@ -337,8 +337,7 @@ TEST(ConfigParseTest, ParsesConfiguration) { #define CHECK_ALIGN_CONSECUTIVE(FIELD) \ do { \ Style.FIELD.Enabled = true; \ - CHECK_PARSE(#FIELD ": None", FIELD, \ - FormatStyle::AlignConsecutiveStyle({})); \ + CHECK_PARSE(#FIELD ": None", FIELD, FormatStyle::AlignConsecutiveStyle{}); \ CHECK_PARSE( \ #FIELD ": Consecutive", FIELD, \ FormatStyle::AlignConsecutiveStyle( \ @@ -369,7 +368,7 @@ TEST(ConfigParseTest, ParsesConfiguration) { /*AlignFunctionPointers=*/false, /*PadOperators=*/true})); \ /* For backwards compability, false / true should still parse */ \ CHECK_PARSE(#FIELD ": false", FIELD, \ - FormatStyle::AlignConsecutiveStyle({})); \ + FormatStyle::AlignConsecutiveStyle{}); \ CHECK_PARSE( \ #FIELD ": true", FIELD, \ FormatStyle::AlignConsecutiveStyle( \ @@ -1094,7 +1093,7 @@ TEST(ConfigParseTest, ParsesConfiguration) { FormatStyle::SortIncludesOptions( {/*Enabled=*/true, /*IgnoreCase=*/false, /*IgnoreExtension=*/false})); CHECK_PARSE("SortIncludes: false", SortIncludes, - FormatStyle::SortIncludesOptions({})); + FormatStyle::SortIncludesOptions{}); CHECK_PARSE( "SortIncludes: CaseInsensitive", SortIncludes, FormatStyle::SortIncludesOptions( @@ -1104,7 +1103,7 @@ TEST(ConfigParseTest, ParsesConfiguration) { FormatStyle::SortIncludesOptions( {/*Enabled=*/true, /*IgnoreCase=*/false, /*IgnoreExtension=*/false})); CHECK_PARSE("SortIncludes: Never", SortIncludes, - FormatStyle::SortIncludesOptions({})); + FormatStyle::SortIncludesOptions{}); Style.RawStringFormats.clear(); std::vector<FormatStyle::RawStringFormat> ExpectedRawStringFormats = { diff --git a/clang/unittests/Format/QualifierFixerTest.cpp b/clang/unittests/Format/QualifierFixerTest.cpp index 86c69a58da2a2..7ff426d490eab 100644 --- a/clang/unittests/Format/QualifierFixerTest.cpp +++ b/clang/unittests/Format/QualifierFixerTest.cpp @@ -86,7 +86,7 @@ TEST_F(QualifierFixerTest, FailQualifierEmptyOrder) { FormatStyle Style = {}; Style.Language = FormatStyle::LK_Cpp; FAIL_PARSE("QualifierAlignment: Custom\nQualifierOrder: []", QualifierOrder, - std::vector<std::string>({})); + std::vector<std::string>{}); } TEST_F(QualifierFixerTest, FailQualifierMissingOrder) { _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
