[PATCH] D120774: [clang-format] Handle builtins in constraint expression
Björn Schäpers via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 1 14:19:25 PST 2022
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D120774.412250.patch
Type: text/x-patch
Size: 1168 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220301/86246e3a/attachment.bin>
More information about the cfe-commits
mailing list