[PATCH] D117416: [clang-format] Handle C variables with name that matches c++ access specifier
Björn Schäpers via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sat Jan 29 12:50:41 PST 2022
HazardyKnusperkeks accepted this revision.
HazardyKnusperkeks added a comment.
This revision is now accepted and ready to land.
+1 for assert
================
Comment at: clang/lib/Format/FormatToken.h:126
+/// Sorted operators that can follow a C variable.
+static const std::vector<clang::tok::TokenKind> COperatorsFollowingVar = {
+ tok::l_square, tok::r_square,
----------------
curdeius wrote:
> Is there a place anywhere that you verify it's sorted?
> If no, please add an assert.
Could initialize from a lambda in which the assert is located, thus it is only executed once.
```
static const std::vector<clang::tok::TokenKind> COperatorsFollowingVar = []{
std::vector<clang::tok::TokenKind> Ret...;
assert(...);
return Ret;
}();
```
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