[PATCH] D132008: [clang-format] Handle return type auto followed by l_paren
Owen Pan via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 16 21:23:35 PDT 2022
owenpan created this revision.
owenpan added reviewers: HazardyKnusperkeks, MyDeveloperDay, curdeius.
owenpan added a project: clang-format.
Herald added a project: All.
owenpan requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
Fixes https://github.com/llvm/llvm-project/issues/57160.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D132008
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
@@ -24887,7 +24887,7 @@
// the user's own fault
verifyFormat("integral auto(x) = y;"); // actually a declaration, but this is
// clearly the user's own fault
- verifyFormat("auto(*p)() = f;"); // actually a declaration; TODO FIXME
+ verifyFormat("auto (*p)() = f;");
}
TEST_F(FormatTest, Cpp20ModulesSupport) {
Index: clang/lib/Format/TokenAnnotator.cpp
===================================================================
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -3337,9 +3337,11 @@
}
// trailing return type 'auto': []() -> auto {}, auto foo() -> auto {}
- if (Left.is(tok::kw_auto) &&
- Right.isOneOf(TT_LambdaLBrace, TT_FunctionLBrace))
+ if (Left.is(tok::kw_auto) && Right.isOneOf(TT_LambdaLBrace, TT_FunctionLBrace,
+ // function return type 'auto'
+ TT_FunctionTypeLParen)) {
return true;
+ }
// auto{x} auto(x)
if (Left.is(tok::kw_auto) && Right.isOneOf(tok::l_paren, tok::l_brace))
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D132008.453195.patch
Type: text/x-patch
Size: 1336 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220817/55714236/attachment-0001.bin>
More information about the cfe-commits
mailing list