llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.11k stars 12.01k forks source link

clang-format line breaks second and third argument to the ternary operator differently #57308

Open zmodem opened 2 years ago

zmodem commented 2 years ago

Consider:

$ clang-format /tmp/a.cc
void F() {
  while (true) {
    if (!(address_size == 4 ? sequential_reader->Read(
                                  size,
                                  [this](const void *data, size_t size) {
                                    return ReadTuples<uint32_t>(data, size);
                                  })
                            : sequential_reader->Read(
                                  size, [this](const void *data, size_t size) {
                                    return ReadTuples<uint64_t>(data, size);
                                  }))) {
      return;
    }
  }
}

Note how both sides of the : are identical except for uint32_t vs uint64_t, but one gets formatted as

                                  size,
                                  [this](const void *data, size_t size) {

and the other as

                                  size, [this](const void *data, size_t size) {
llvmbot commented 2 years ago

@llvm/issue-subscribers-clang-format