[PATCH] D141811: [clang-format] Allow trailing return types in macros
Emilia Dreamer via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 23 10:39:02 PDT 2023
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc70e360b355a: [clang-format] Allow trailing return types in macros (authored by rymiel).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D141811/new/
https://reviews.llvm.org/D141811
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
@@ -8010,6 +8010,11 @@
"auto aaaaaaaaaaaaaaaaaaaaaa(T t)\n"
" -> decltype(eaaaaaaaaaaaaaaa<T>(t.a).aaaaaaaa());");
+ FormatStyle Style = getLLVMStyleWithColumns(60);
+ verifyFormat("#define MAKE_DEF(NAME) \\\n"
+ " auto NAME() -> int { return 42; }",
+ Style);
+
// Not trailing return types.
verifyFormat("void f() { auto a = b->c(); }");
verifyFormat("auto a = p->foo();");
Index: clang/lib/Format/TokenAnnotator.cpp
===================================================================
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1909,7 +1909,8 @@
} else if (Current.is(tok::arrow) &&
Style.Language == FormatStyle::LK_Java) {
Current.setType(TT_LambdaArrow);
- } else if (Current.is(tok::arrow) && AutoFound && Line.MustBeDeclaration &&
+ } else if (Current.is(tok::arrow) && AutoFound &&
+ (Line.MustBeDeclaration || Line.InPPDirective) &&
Current.NestingLevel == 0 &&
!Current.Previous->isOneOf(tok::kw_operator, tok::identifier)) {
// not auto operator->() -> xxx;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D141811.507804.patch
Type: text/x-patch
Size: 1407 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230323/fadc57b7/attachment.bin>
More information about the cfe-commits
mailing list