lichray added inline comments.
================
Comment at: clang/lib/Format/TokenAnnotator.cpp:1354
+ static bool isDeductionGuide(FormatToken &Current) {
+ // Look for a deduction guide A()...) -> A<...>;
+ if (Current.Previous && Current.Previous->is(tok::r_paren) &&
----------------
Parentheses not matching is comment.
================
Comment at: clang/lib/Format/TokenAnnotator.cpp:1365
+ if (TemplateCloser->is(tok::greater))
+ NestingLevel--;
+ if (TemplateCloser->is(tok::kw_decltype))
----------------
Does this work? What about `A() -> A<(3 < 2)>;`?
================
Comment at: clang/lib/Format/TokenAnnotator.cpp:1366
+ NestingLevel--;
+ if (TemplateCloser->is(tok::kw_decltype))
+ return false;
----------------
What's this for? What about `A() -> A<sizeof(p->foo<1>>);`
I guess we don't have to look for the end of template, because a class X can't
refer to its member called X with `->` because that member is constructor. The
approach to match the identifiers may not work in the future but may work fine
for now.
================
Comment at: clang/unittests/Format/FormatTest.cpp:4992
+ verifyFormat("x = p->foo<3>();");
+ verifyFormat("A()->A<decltype(p->foo<3>())>;");
+}
----------------
This looks like a deduction guide. It should be formatted as `A() ->
A<decltype(p->foo<3>())>;` I assume? If you cannot cover this case in this
patch, this test case needs a comment.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D69577/new/
https://reviews.llvm.org/D69577
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits