<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/60898>60898</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            QualifierAlignment Right doesn't handle Pointer to member declarators correctly
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          AlexanderHederstaf
      </td>
    </tr>
</table>

<pre>
    Example input:

```
$ cat /tmp/memberpointer.cpp
struct S;
void foo(const int S::*const ptr) {}
void bar(int const S::*const ptr) {}
```

Output:
```
$ ./clang-format  --style="{QualifierAlignment: Right}" /tmp/memberpointer.cpp
struct S;
void foo(int const S::*const ptr) {}
void bar(int S::const *const ptr) {}
```

Discovered by running clang-format on an existing codebase that had a few instances of pointer to member function. The `const` qualifier is moved iteratively until the code no longer compiles. Probably caused in this section

```
 // The case  `const Foo` -> `Foo const`
    // The case  `const ::Foo` -> `::Foo const`
    // The case  `const Foo *` -> `Foo const *`
    // The case  `const Foo &` -> `Foo const &`
    // The case  `const Foo &&` -> `Foo const &&`
    // The case  `const std::Foo &&` -> `std::Foo const &&`
    // The case  `const std::Foo<T> &&` -> `std::Foo<T> const &&`
 while (Next && Next->isOneOf(tok::identifier, tok::coloncolon))
 Next = Next->Next;
```

Where special treatment would be required for the following case, causing no change.
```
    // The case  `const Foo::*` -> `const Foo::*`
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykVV9zozYQ_zTiZcceLIgNDzw452P61Fzbm-mzkBZQKyROWpz423cEtu-SuLlkbkYjYP_8dveHdiVC0J1FrNjdPbs7JGKi3vlqb_BJWIX-N1ToA4k2aZw6VZ-fxDAaBG3HiVi2Z-mBpZd9m57X8slzkIKA8ZqGkfF6wKFBPzptCf1ajuNiF8hPkuAvlt0vgqPTClrnGC-ks4FA21m9j4vvF9lInvES2O6e7Q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