[PATCH] D120511: [clang-format] Allow to set token types final

Björn Schäpers via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 24 12:33:29 PST 2022


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

We have a little problem. TokenAnnotator::resetTokenMetadata() resets the type, except for a (growing) whitelist. This is because the TokenAnnotator visits some tokens multiple times. E.g. trying to identify if a < is an operator less or a template opener. And in some runs, which are bascially "reverted" the types are reset.

On the other hand, if the parser does already know the type, it should be able to set it, without it being reset. So we introduce the ability to set a type and make that final.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D120511

Files:
  clang/lib/Format/FormatToken.h
  clang/lib/Format/TokenAnnotator.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/TokenAnnotatorTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D120511.411211.patch
Type: text/x-patch
Size: 8813 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220224/2f1949db/attachment.bin>


More information about the cfe-commits mailing list