================
@@ -4591,7 +4589,9 @@ bool TokenAnnotator::spaceRequiredBetween(const 
AnnotatedLine &Line,
     if (!BeforeLeft)
       return false;
     if (BeforeLeft->is(tok::coloncolon)) {
-      return Left.is(tok::star) &&
+      const auto *Prev = BeforeLeft->Previous;
+      return Left.is(tok::star) && Prev &&
+             !Prev->endsSequence(tok::identifier, TT_FunctionTypeLParen) &&
----------------
kadircet wrote:

i think it's actually common enough to handle in this patch, 
https://github.com/search?q=lang%3Acpp+%2F%3A%3A%5Cw%2B%3A%3A%5C*%5C%29%2F&type=code.

moreover we also have cases like `(std::remove_pointer<O>::type::*)`. so it 
might actually be easier to match by going forward (which should also ensure we 
do less operations)? e.g. something like:
```
// Don't add space around function-type pointers.
// - void (*foo)(int);
// - void (::B::*foo)(int);
// - void (A<T>::B::*)(int);
auto OpeningParen = Right.MatchingParen;
if (!OpeningParen && Right.Next)
  OpeningParen = Right.Next->MatchingParen;
if (OpeningParen && OpeningParen->is(TT_FunctionTypeLParen))
  return false;

if (BeforeLeft->is(tok::coloncolon))
  return true;
```

https://github.com/llvm/llvm-project/pull/105043
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to