[PATCH] D132295: [clang-format] Change heuristic for locating lambda template arguments

Emilia Dreamer via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Aug 20 06:49:19 PDT 2022


rymiel created this revision.
rymiel added reviewers: HazardyKnusperkeks, owenpan, MyDeveloperDay, curdeius.
Herald added a project: All.
rymiel requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Previously, the heuristic was simply to look for template argument-
specific keywords, such as `typename`, `class`, `template` and `auto`
that are preceded by a left angle bracket `<`.

This changes the heuristic to instead look for a left angle bracket `<`
preceded by a right square bracket `]`, since according to the C++
grammar, the template arguments must *directly* follow the introducer.
(This sort of check might just end up being *too* aggressive)

This patch also adds a bunch more token annotator tests for lambdas,
specifically for some of the stranger forms of lambdas now allowed as
of C++20 or soon-to-be-allowed as part of C++23.

Fixes https://github.com/llvm/llvm-project/issues/57093

This does NOT resolve the FIXME regarding explicit template lists, but
perhaps it gets closer


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D132295

Files:
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/TokenAnnotatorTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D132295.454207.patch
Type: text/x-patch
Size: 4872 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220820/89478fba/attachment.bin>


More information about the cfe-commits mailing list