[lld] [DRAFT][clang-format][lld] Run clang-format on lld (PR #80461)

Scott Linder via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 2 13:16:51 PST 2024


================
@@ -833,7 +833,8 @@ constexpr std::pair<const char *, unsigned> typeMap[] = {
 // "(TYPE=<value>)".
 // Tok1 and Tok2 are next 2 tokens peeked. See comment for
 // readSectionAddressType below.
-bool ScriptParser::readSectionDirective(OutputSection *cmd, StringRef tok1, StringRef tok2) {
+bool ScriptParser::readSectionDirective(OutputSection *cmd, StringRef tok1,
+                                        StringRef tok2) {
----------------
slinder1 wrote:

This particular case isn't illustrative of it, but I think it is worth considering using some of the "if it doesn't fit on one line, give each element its own line" options in the format. These are at least:

- [BinPackArguments](https://clang.llvm.org/docs/ClangFormatStyleOptions.html#binpackarguments)
- [BinPackParameters](https://clang.llvm.org/docs/ClangFormatStyleOptions.html#binpackparameters)
- [PackConstructorInitializers](https://clang.llvm.org/docs/ClangFormatStyleOptions.html#packconstructorinitializers)
- Several options following the naming pattern [AllowShortXOnASingleLine](https://clang.llvm.org/docs/ClangFormatStyleOptions.html#allowshortblocksonasingleline)

The value is particularly visible when there are  10+ parameters or member initializers: it is easy to lose track of some bin-packed elements, and there is some "write-amplification" which balloons the diff when the bin-packing reflows every line because an element in the middle is changed, added, or removed.

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


More information about the llvm-commits mailing list