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] Incorrect space for "delete[] *x" #57418

Closed
zzyyyl opened this issue Aug 29, 2022 · 5 comments
Closed

[clang-format] Incorrect space for "delete[] *x" #57418

zzyyyl opened this issue Aug 29, 2022 · 5 comments
Assignees

Comments

@zzyyyl
Copy link

zzyyyl commented Aug 29, 2022

Versions: 14 and main

Input

void f() {
  char *x[1] = {new char[10]};
  delete[] *x;
}

Output

void f() {
  char *x[1] = {new char[10]};
  delete[] * x;
}

Expect

same as input

@llvmbot
Copy link
Collaborator

llvmbot commented Aug 29, 2022

@llvm/issue-subscribers-clang-format

@jackhong12 jackhong12 self-assigned this Aug 30, 2022
@jackhong12
Copy link
Member

Revision: https://reviews.llvm.org/D132911

@jackhong12 jackhong12 added awaiting-review Has pending Phabricator review clang-format and removed clang-format labels Aug 30, 2022
@llvmbot
Copy link
Collaborator

llvmbot commented Aug 30, 2022

@llvm/issue-subscribers-clang-format

@zzyyyl
Copy link
Author

zzyyyl commented Aug 30, 2022

@jackhong12
It's still incorrect when --style="{PointerAlignment: Left}"

delete[] *x; -> delete[]* x;
delete[] *(x); -> delete[]*(x);

Perhaps the pointer here should be annotated as UnaryOperator?

@jackhong12
Copy link
Member

jackhong12 commented Aug 30, 2022

@zzyyyl Thanks for reminding me! You are right. The * token here should be UnaryOperator.

I think the configuration, --style="{PointerAlignment: Left}", will not change the alignment of the * token here. So, the result should be:
echo "delete[] *(x);" | clang-format --style="{PointerAlignment: Left}" -> delete[] *(x);
echo "delete[] *x;" | clang-format --style="{PointerAlignment: Left}" -> delete[] *x;

@github-actions github-actions bot removed the awaiting-review Has pending Phabricator review label Sep 2, 2022
kontura added a commit to kontura/dnf5 that referenced this issue Apr 25, 2023
`RequiresExpressionIndentation` is added to keep compatiblity, it is new
in clang-format 16:
https://clang.llvm.org/docs/ClangFormatStyleOptions.html#requiresexpressionindentation

There is a change with `delete[]` operator, this is a bugfix:
llvm/llvm-project#57418

The last change is a regression tracked here:
llvm/llvm-project#62356
kontura added a commit to kontura/dnf5 that referenced this issue Apr 26, 2023
There is a change with `delete[]` operator, this is a bugfix:
llvm/llvm-project#57418

Another change with one line function is a regression tracked here:
llvm/llvm-project#62356

The last change is a new behavior.
j-mracek pushed a commit to rpm-software-management/dnf5 that referenced this issue May 3, 2023
There is a change with `delete[]` operator, this is a bugfix:
llvm/llvm-project#57418

Another change with one line function is a regression tracked here:
llvm/llvm-project#62356

The last change is a new behavior.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants