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: Incorrectly formats multiplication as if it was pointer dereference #110879

Open
griffin2000 opened this issue Oct 2, 2024 · 2 comments · May be fixed by #110945
Open

clang-format: Incorrectly formats multiplication as if it was pointer dereference #110879

griffin2000 opened this issue Oct 2, 2024 · 2 comments · May be fixed by #110945
Assignees

Comments

@griffin2000
Copy link

griffin2000 commented Oct 2, 2024

In the attached example (test.cpp.txt, renamed to .txt so it can be attached) using the attached .clang-format settings (clang-format.txt, also renamed to .txt and . prefix removed), the second line of the struct is formatted by clang-format (v 14.0.0) as if it was a pointer de-reference, and the space following the * is removed.

So this...


constexpr Thingy kConfig = {
    {
        (uint16_t)(kScale * kThing.width_pixels),
        (uint16_t)(kScale * kThing.height_pixels),
    },
};

Becomes:

constexpr Thingy kConfig = {
    {
        (uint16_t)(kScale * kThing.width_pixels),
        (uint16_t)(kScale *kThing.height_pixels),
    },
};

The expected behaviour is the space should be maintained, or added if it it is removed (if either the space before or after the * is removed on the previous line, it will be added back by clang-format)

@EugeneZelenko
Copy link
Contributor

Could you please try 19 or main branch?

@griffin2000
Copy link
Author

Could you please try 19 or main branch?

Yup just verified with https://github.com/llvm/llvm-project/releases/download/llvmorg-19.1.0/clang+llvm-19.1.0-x86_64-pc-windows-msvc.tar.xz, same result

@owenca owenca self-assigned this Oct 3, 2024
owenca added a commit to owenca/llvm-project that referenced this issue Oct 3, 2024
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.

3 participants