[PATCH] D120774: [clang-format] Handle builtins in constraint expression
Björn Schäpers via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 3 03:45:00 PST 2022
HazardyKnusperkeks updated this revision to Diff 412664.
HazardyKnusperkeks added a comment.
More Traits.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D120774/new/
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,15 @@
verifyFormat("template <typename T>\n"
"concept Node = std::is_object_v<T>;");
+ verifyFormat("template <class T>\n"
+ "concept integral = __is_integral(T);");
+
+ verifyFormat("template <class T>\n"
+ "concept is2D = __array_extent(T, 1) == 2;");
+
+ verifyFormat("template <class T>\n"
+ "concept isRhs = __is_rvalue_expr(std::declval<T>() + 2)");
+
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,13 @@
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:
+#define ARRAY_TYPE_TRAIT(I, E, K) case tok::kw_##I:
+#define EXPRESSION_TRAIT(I, E, 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D120774.412664.patch
Type: text/x-patch
Size: 1495 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220303/abb85c91/attachment-0001.bin>
More information about the cfe-commits
mailing list