[PATCH] D120503: [clang-format] Handle trailing comment for InsertBraces
Owen Pan via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Feb 24 23:10:35 PST 2022
owenpan added inline comments.
================
Comment at: clang/lib/Format/UnwrappedLineParser.cpp:2340-2341
if (!L.InPPDirective) {
Tok = getLastNonComment(L);
- if (Tok)
+ if (Tok) {
+ Tok = L.Tokens.back().Tok;
----------------
owenpan wrote:
> HazardyKnusperkeks wrote:
> > So basically one would just need a `Line.isComment()` or so? The `lastNonComment` is not important, right?
> We don't really need a pointer to the last non-comment token here as we would return the last token of the line, but the pointer is still needed for the left brace above.
We have to try to find either the first or the last non-comment token in `L` to determine if it's a comment line, for `L` can be something like:
```
/* comment */ f(); // comment
```
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D120503/new/
https://reviews.llvm.org/D120503
More information about the cfe-commits
mailing list