[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:19:05 PDT 2020
arichardson updated this revision to Diff 289404.
arichardson added a comment.
- fix formatting of test case
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D87007/new/
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,12 @@
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.289404.patch
Type: text/x-patch
Size: 1174 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200902/f3bfb339/attachment.bin>
More information about the cfe-commits
mailing list