[PATCH] D87007: [clang-format] Correctly parse function declarations with TypenameMacros
Alexander Richardson via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 2 05:15:24 PDT 2020
arichardson created this revision.
arichardson added reviewers: MyDeveloperDay, JakeMerdichAMD, sammccall, curdeius.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
arichardson requested review of this revision.
When using the always break after return type setting:
Before:
SomeType funcdecl(LIST(uint64_t));
After:
SomeType
funcdecl(LIST(uint64_t));"
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D87007
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
@@ -6681,9 +6681,11 @@
Style);
// All declarations and definitions should have the return type moved to its
- // own
- // line.
+ // own line.
Style.AlwaysBreakAfterReturnType = FormatStyle::RTBS_All;
+ Style.TypenameMacros = {"LIST"};
+ verifyFormat("SomeType\n"
+ "funcdecl(LIST(uint64_t));", Style);
verifyFormat("class E {\n"
" int\n"
" f() {\n"
Index: clang/lib/Format/TokenAnnotator.cpp
===================================================================
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2400,6 +2400,8 @@
return true;
for (const FormatToken *Tok = Next->Next; Tok && Tok != Next->MatchingParen;
Tok = Tok->Next) {
+ if (Tok->is(TT_TypeDeclarationParen))
+ return true;
if (Tok->isOneOf(tok::l_paren, TT_TemplateOpener) && Tok->MatchingParen) {
Tok = Tok->MatchingParen;
continue;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D87007.289401.patch
Type: text/x-patch
Size: 1158 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200902/35b1e197/attachment.bin>
More information about the cfe-commits
mailing list