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
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
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits