Skip to content

clang-format regression formatting immediately invoked lambda #170573

@aaron-skydio

Description

@aaron-skydio

I have an example (this file) that I've trimmed down to this minimal example:

void foo() {
  const double _tmp327 = 1.0;
  const double _tmp59 = 2.0;
  const double _tmp339 = _tmp327 * [&]() {
    const double base = _tmp59;
    return base * base * base;
  }();
}

Starting from LLVM 21.1.3 through LLVM 21.1.7, clang-format wants to format this as:

void foo() {
  const double _tmp327 = 1.0;
  const double _tmp59 = 2.0;
  const double _tmp339 = _tmp327* [&]() {
    const double base = _tmp59;
    return base * base * base;
  }
  ();
}

which seems wrong.

Config is here.

Can reproduce by downloading the LLVM release binaries and running, for example,

❯ docker run --rm -it -v /home/aaron/symforce:/symforce ubuntu:noble /symforce/LLVM-21.1.3-Linux-X64/bin/clang-format 
/symforce/gen/cpp/sym/factors/inverse_range_landmark_spherical_gnc_factor.h

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions