================
@@ -227,17 +228,26 @@ void MacroParenthesesPPCallbacks::argument(const Token 
&MacroNameTok,
 
     // Cast.
     if (Prev.is(tok::l_paren) && Next.is(tok::star) &&
-        TI + 2 != MI->tokens_end() && (TI + 2)->is(tok::r_paren))
+        std::next(TI, 2) != MI->tokens_end() &&
+        std::next(TI, 2)->is(tok::r_paren))
       continue;
 
     // Assignment/return, i.e. '=x;' or 'return x;'.
     if (Prev.isOneOf(tok::equal, tok::kw_return) && Next.is(tok::semi))
       continue;
 
     // C++ template parameters.
-    if (PP->getLangOpts().CPlusPlus && Prev.isOneOf(tok::comma, tok::less) &&
-        Next.isOneOf(tok::comma, tok::greater))
-      continue;
+    if (PP->getLangOpts().CPlusPlus && Prev.isOneOf(tok::comma, tok::less)) {
+      const auto *NextIt = std::next(TI);
+      while (NextIt != MI->tokens_end() &&
+             NextIt->isOneOf(tok::star, tok::amp, tok::ampamp, tok::kw_const,
+                             tok::kw_volatile))
+        ++NextIt;
----------------
localspook wrote:

Could use an algorithm here
```suggestion
      const auto *NextIt = std::find_if_not(std::next(TI), MI->tokens_end(), [] 
(const Token& T) {
        return T.isOneOf(tok::star, tok::amp, tok::ampamp, tok::kw_const,
                             tok::kw_volatile); });
```

https://github.com/llvm/llvm-project/pull/174329
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to