Skip to content

[clang-format] AlignAfterOpenBracket: BlockIndent fails if bracket starts before ContinuationIndentWidth #161654

@Alunderin

Description

@Alunderin

This is most easily seen on functions with AlwaysBreakAfterReturnType enabled or on constructors with short class names.

Given this config:

AlignAfterOpenBracket: BlockIndent
AlwaysBreakAfterReturnType: TopLevel

This formats as expected:

void
LogE(
    std::string_view message,
    std::source_location loc = std::source_location::current()
) {
  std::println(std::cerr, "{}({}): {}", loc.file_name(), loc.line(), message);
}

With one less character in the function name, it formats like this:

void
Log(std::string_view message,
    std::source_location loc = std::source_location::current()) {
  std::println(std::cerr, "{}({}): {}", loc.file_name(), loc.line(), message);
}

It seemingly falls back to using AlignAfterOpenBracket: DontAlign if the opening bracket starts before the value of ContinuationIndentWidth (4 by default).

Tested with version 18.1.3 (Ubuntu) and 22.0.0git (commit 3c39187)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions