[PATCH] D134626: [clang-format] Correctly indent closing brace of compound requires
Emilia Dreamer via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 30 22:35:18 PDT 2022
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1fa115b56979: [clang-format] Correctly indent closing brace of compound requires (authored by rymiel).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D134626/new/
https://reviews.llvm.org/D134626
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
@@ -24510,6 +24510,16 @@
" { x * 1 } -> std::convertible_to<T>;\n"
" };");
+ verifyFormat("template <typename T>\n"
+ "concept C = requires(T x) {\n"
+ " {\n"
+ " long_long_long_function_call(1, 2, 3, 4, 5)\n"
+ " } -> long_long_concept_name<T>;\n"
+ " {\n"
+ " long_long_long_function_call(1, 2, 3, 4, 5)\n"
+ " } noexcept -> long_long_concept_name<T>;\n"
+ " };");
+
verifyFormat(
"template <typename T, typename U = T>\n"
"concept Swappable = requires(T &&t, U &&u) {\n"
Index: clang/lib/Format/UnwrappedLineParser.cpp
===================================================================
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -964,6 +964,8 @@
if (MacroBlock && FormatTok->is(tok::l_paren))
parseParens();
+ Line->Level = InitialLevel;
+
if (FormatTok->is(tok::kw_noexcept)) {
// A noexcept in a requires expression.
nextToken();
@@ -979,8 +981,6 @@
if (MunchSemi && FormatTok->is(tok::semi))
nextToken();
- Line->Level = InitialLevel;
-
if (PPStartHash == PPEndHash) {
Line->MatchingOpeningBlockLineIndex = OpeningLineIndex;
if (OpeningLineIndex != UnwrappedLine::kInvalidIndex) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D134626.464473.patch
Type: text/x-patch
Size: 1646 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20221001/f28bcc7a/attachment-0001.bin>
More information about the cfe-commits
mailing list