Skip to content

[clang-format] PointerAlignment does not respect pointer to member field #85761

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

Closed
CDAlexanderW opened this issue Mar 19, 2024 · 3 comments · Fixed by #86253
Closed

[clang-format] PointerAlignment does not respect pointer to member field #85761

CDAlexanderW opened this issue Mar 19, 2024 · 3 comments · Fixed by #86253
Assignees

Comments

@CDAlexanderW
Copy link

Environment

The tested v19 clang-format executable was built from latest source of 13.03.2024. Also tested with clang-format 17.0.3.

Setting in .clang-format is:

Language: Cpp
PointerAlignment: Left
SpaceAroundPointerQualifiers: Before

Problem

class A {
public:
  int B;
};
void function(int A::* parameter, int* parameter2) {
  int A::* variable = &A::B;
  int* A::B;
}

formats to

class A {
public:
  int B;
};
void function(int A::*parameter, int* parameter2) {
  int A::*variable = &A::B;
  int* A::B;
}

For the pointers to member field we expect the space between the ::* and the variable/parameter name to be there and NOT removed.

@owenca
Copy link
Contributor

owenca commented Mar 21, 2024

Is A:: a qualifier like const?

@CDAlexanderW
Copy link
Author

Is A:: a qualifier like const?

Hi owenca!
Thx for your reply.

No, not a qualifier. See (2) Pointer to member declarator on cppreference for the explanation of the language feature.

@owenca
Copy link
Contributor

owenca commented Mar 22, 2024

I knew A::* is for pointers to class members. I asked the question because I was thrown off by the SpaceAroundPointerQualifiers option and thought that maybe you expected A:: to be treated like a qualifier.

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