Skip to content

[clang-format] Regression in formatting of explicit NTTPs with bitwise operators. #109925

@Jhuighuy

Description

@Jhuighuy

Hi everyone,

The latest released clang-format (19.1.0) cannot properly format nested calls, when the inner call contains explicit non-type template parameter expressions, containing bitwise operations. Expressions with arithmetic operations are formatted correctly.

clang-format 18 produces correct results.

The problem can be reproduced regardless of the presence or contents of .clang-format.

Example:

~ » cat a.cpp

void main() {
  // Bitwise operations.
  f(g<flag_1 | flag_2>());
  f(g<flag_1 & flag_2>());
  f(g<flag_1 ^ flag_2>());
  f(g<flag_1 & ~flag_2>());

  // Arithmetic operations.
  f(g<flag_1 + flag_2>());
  f(g<flag_1 - flag_2>());
  f(g<flag_1 * flag_2>());
  f(g<flag_1 / flag_2>());
}

~ » clang-format a.cpp

void main() {
  // Bitwise operations.
  f(g < flag_1 | flag_2 > ());
  f(g < flag_1 & flag_2 > ());
  f(g < flag_1 ^ flag_2 > ());
  f(g < flag_1 & ~flag_2 > ());

  // Arithmetic operations.
  f(g<flag_1 + flag_2>());
  f(g<flag_1 - flag_2>());
  f(g<flag_1 * flag_2>());
  f(g<flag_1 / flag_2>());
}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions