[PATCH] D117416: [clang-format] Handle C variables with name that matches c++ access specifier
psigillito via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sat Jan 29 10:28:37 PST 2022
psigillito marked 7 inline comments as done.
psigillito added inline comments.
================
Comment at: clang/lib/Format/UnwrappedLineParser.cpp:2716-2718
+ auto COperatorMatch =
+ std::lower_bound(COperatorsFollowingVar.begin(),
+ COperatorsFollowingVar.end(), FormatTok->Tok.getKind());
----------------
curdeius wrote:
> Please use `binary_search` and put it inside the `else` branch to avoid it if the first condition is satisfied.
> Something like:
> ```
> if (FormatTok->Tok.is(tok::colon)) {
> ...
> } else if (!binary_search(...) {
> } else if (...) {
> }
> ```
>
> Also, this code and the code in `UnwrappedLineFormatter` are pretty much similar.
> Can we remove this duplication by e.g. setting the token kind here and checking it in the formatter?
Yes, since we now set the kind to 'identifier' here, the binary_search check in the formatter is unnecessary. Updated the formatter to no longer do the check.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D117416/new/
https://reviews.llvm.org/D117416
More information about the cfe-commits
mailing list