HazardyKnusperkeks created this revision.
HazardyKnusperkeks added reviewers: owenpan, curdeius, MyDeveloperDay, cjdb.
HazardyKnusperkeks added a project: clang-format.
Herald added a project: All.
HazardyKnusperkeks requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D120774

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


Index: clang/unittests/Format/FormatTest.cpp
===================================================================
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -23743,6 +23743,9 @@
   verifyFormat("template <typename T>\n"
                "concept Node = std::is_object_v<T>;");
 
+  verifyFormat("template <class T>\n"
+               "concept integral = __is_integral(T);");
+
   auto Style = getLLVMStyle();
   Style.BreakBeforeConceptDeclarations = FormatStyle::BBCDS_Allowed;
 
Index: clang/lib/Format/UnwrappedLineParser.cpp
===================================================================
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -3085,6 +3085,11 @@
         return;
       break;
 
+// Get the type traits tokens. Let them behave like any other identifier (which
+// may also be a type trait).
+#define TYPE_TRAIT(N, I, K) case tok::kw_##I:
+#include "clang/Basic/TokenKinds.def"
+
     case tok::identifier:
       // We need to differentiate identifiers for a template deduction guide,
       // variables, or function return types (the constraint expression has


Index: clang/unittests/Format/FormatTest.cpp
===================================================================
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -23743,6 +23743,9 @@
   verifyFormat("template <typename T>\n"
                "concept Node = std::is_object_v<T>;");
 
+  verifyFormat("template <class T>\n"
+               "concept integral = __is_integral(T);");
+
   auto Style = getLLVMStyle();
   Style.BreakBeforeConceptDeclarations = FormatStyle::BBCDS_Allowed;
 
Index: clang/lib/Format/UnwrappedLineParser.cpp
===================================================================
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -3085,6 +3085,11 @@
         return;
       break;
 
+// Get the type traits tokens. Let them behave like any other identifier (which
+// may also be a type trait).
+#define TYPE_TRAIT(N, I, K) case tok::kw_##I:
+#include "clang/Basic/TokenKinds.def"
+
     case tok::identifier:
       // We need to differentiate identifiers for a template deduction guide,
       // variables, or function return types (the constraint expression has
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to