[PATCH] D113826: [clang-format][c++2b] support removal of the space between auto and {} in P0849R8
MyDeveloperDay via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sat Nov 13 07:59:09 PST 2021
MyDeveloperDay updated this revision to Diff 387024.
MyDeveloperDay added a comment.
Remove invalid testcases
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D113826/new/
https://reviews.llvm.org/D113826
Files:
clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/FormatTest.cpp
Index: clang/unittests/Format/FormatTest.cpp
===================================================================
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -22566,6 +22566,22 @@
EXPECT_EQ(Code, format(Code, Style));
}
+TEST_F(FormatTest, FormatDecayCopy) {
+ verifyFormat("foo(auto())");
+ verifyFormat("foo(auto{})");
+ verifyFormat("foo(auto({}))");
+ verifyFormat("foo(auto{{}})");
+ verifyFormat("foo(auto(1))");
+ verifyFormat("foo(auto{1})");
+ verifyFormat("foo(new auto(1))");
+ verifyFormat("foo(new auto{1})");
+ verifyFormat("decltype(auto(1)) x;");
+ verifyFormat("decltype(auto{1}) x;");
+ verifyFormat("auto(x);");
+ verifyFormat("auto{x};");
+ verifyFormat("auto{x} = y;");
+}
+
} // namespace
} // namespace format
} // namespace clang
Index: clang/lib/Format/TokenAnnotator.cpp
===================================================================
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2940,6 +2940,10 @@
return true;
}
+ // auto{x}
+ if (Left.is(tok::kw_auto) && Right.isOneOf(tok::l_paren, tok::l_brace))
+ return false;
+
// requires clause Concept1<T> && Concept2<T>
if (Left.is(TT_ConstraintJunctions) && Right.is(tok::identifier))
return true;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113826.387024.patch
Type: text/x-patch
Size: 1305 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211113/a3aa5009/attachment.bin>
More information about the cfe-commits
mailing list