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 wrongly removes a space after "delete &&" #78789

Closed
Julien-Elie opened this issue Jan 19, 2024 · 2 comments · Fixed by #89033
Closed

clang-format wrongly removes a space after "delete &&" #78789

Julien-Elie opened this issue Jan 19, 2024 · 2 comments · Fixed by #89033
Assignees

Comments

@Julien-Elie
Copy link

When a variable is named delete in C code, a space is removed in && conditions (but not in || conditions):

int delete = 0;
int num = 0;

if (delete &&num) {
  delete = 1;
}

if (!delete &&num) {
  delete = 1;
}
if (delete || num) {
  delete = 1;
}

Tested with clang-format 16.0.6.

Could it be fixed? Maybe other special variables like delete are also impacted.

@rymiel
Copy link
Member

rymiel commented Jan 20, 2024

Most likely related to #43678
Oops, I meant #56249

@rymiel rymiel self-assigned this Jan 20, 2024
rymiel added a commit to rymiel/llvm-project that referenced this issue Jan 20, 2024
Simply always return false if tok::ampamp is passed into
determineUnaryOperatorByUsage.

I've done a fix earlier regarding ampamp becoming an unary operator,
this would technically supersede that.

I'm not sure why this hasn't been done before, I don't see any
downsides.

Fixes llvm#78789
@Julien-Elie
Copy link
Author

Many thanks for having taken into account the report, and already provided a fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants