[PATCH] D120445: [clang-format] Treat && followed by noexcept operator as a binary operator inside template arguments

Luis Penagos via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 24 17:05:59 PST 2022


penagos updated this revision to Diff 411272.
penagos added a comment.

Rebase to trigger CI.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D120445/new/

https://reviews.llvm.org/D120445

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===================================================================
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -9512,6 +9512,7 @@
   verifyFormat("f(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n"
                "      .template operator()<A>());",
                getLLVMStyleWithColumns(35));
+  verifyFormat("bool_constant<a && noexcept(f())>");
 
   // Not template parameters.
   verifyFormat("return a < b && c > d;");
Index: clang/lib/Format/TokenAnnotator.cpp
===================================================================
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2066,6 +2066,10 @@
       return TT_UnaryOperator;
 
     const FormatToken *NextToken = Tok.getNextNonComment();
+
+    if (InTemplateArgument && NextToken && NextToken->is(tok::kw_noexcept))
+      return TT_BinaryOperator;
+
     if (!NextToken ||
         NextToken->isOneOf(tok::arrow, tok::equal, tok::kw_noexcept) ||
         NextToken->canBePointerOrReferenceQualifier() ||


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D120445.411272.patch
Type: text/x-patch
Size: 1078 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220225/6c97b3f7/attachment.bin>


More information about the cfe-commits mailing list