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

Incorrect clang-format PointerAlignment for brace-enclosed initialization within if-statement #109371

Closed
swalkner opened this issue Sep 20, 2024 · 2 comments · Fixed by #109505
Closed
Assignees
Labels
clang-format question A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!

Comments

@swalkner
Copy link

I can confirm this behaviour and would like to gently bump this report.

if (MyClass * obj{GetMyClass()})

But - for some reason - auto and primitive-types seem to work as expected:

if (auto* obj{GetMyClass()})
if (int* obj{GetInt()})

I have reproduced that in clang-format:

  • 17.0.3 (packaged with VS)
  • 18.1.3 (and other versions via clang-format-configurator.site)

The only config option I changed:

PointerAlignment: Left

(This issue has been split from #60146 )

@owenca
Copy link
Contributor

owenca commented Oct 15, 2024

98281da was reverted by ee64684 due to regressions.

@owenca
Copy link
Contributor

owenca commented Oct 15, 2024

foo * bar{baz} can be either a declaration or an expression depending on whether or not foo is a TypeName. Please use the TypeNames option to disambiguate it.

@owenca owenca closed this as not planned Won't fix, can't repro, duplicate, stale Oct 15, 2024
@EugeneZelenko EugeneZelenko added the question A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead! label Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang-format question A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants