Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Jhuighuy opened this issue Sep 25, 2024 · 0 comments · Fixed by #110408
Closed

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

Jhuighuy opened this issue Sep 25, 2024 · 0 comments · Fixed by #110408

Comments

@Jhuighuy
Copy link

Jhuighuy commented Sep 25, 2024

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>());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants