This is an archive of the discontinued LLVM Phabricator instance.

[clang-format] Don't move qualifiers past pointers-to-member
ClosedPublic

Authored by rymiel on Feb 21 2023, 11:43 PM.

Details

Summary

Previously, given a pointer-to-member type such as Foo const Bar::*,
clang-format would see the const Bar:: part as a regular type name
with scope resolution operators, and with QualifierAlignment: Right it
would attempt to "fix" it, resulting in Foo Bar::const *, a syntax
error.

This patch no longer allows qualifiers to be moved across ::*.

Fixes https://github.com/llvm/llvm-project/issues/60898

Diff Detail

Event Timeline

rymiel created this revision.Feb 21 2023, 11:43 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 21 2023, 11:43 PM
rymiel requested review of this revision.Feb 21 2023, 11:43 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 21 2023, 11:43 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
owenpan accepted this revision.Feb 22 2023, 11:08 AM
owenpan added inline comments.
clang/lib/Format/QualifierAlignmentFixer.cpp
284–285

Or:

while (Next && (Next->is(tok::identifier) || (Next->is(tok::coloncolon) &&
           (!Next->Next || Next->Next->isNot(tok::star))))) {

Nevertheless, I'm okay if you don't make any change.

This revision is now accepted and ready to land.Feb 22 2023, 11:08 AM
MyDeveloperDay accepted this revision.Feb 22 2023, 12:25 PM

Thanks for doing this @rymiel, LGTM..

maybe we should cherry pick into 16?

maybe we should cherry pick into 16?

+1

maybe we should cherry pick into 16?

It's up to one of you (mostly because I don't know how to do backports and I don't want to mess it up)

This revision was landed with ongoing or failed builds.Feb 25 2023, 2:18 AM
This revision was automatically updated to reflect the committed changes.

maybe we should cherry pick into 16?

I don't know how to do backports and I don't want to mess it up

It's easy. Just reopen the issue, add it to the release milestone, and add a /check-pick comment and the release:backport label. See also https://llvm.org/docs/GitHub.html#backporting-fixes-to-the-release-branches.