HazardyKnusperkeks added inline comments.
================
Comment at: clang/lib/Format/TokenAnnotator.cpp:2314-2315
+ if (PrevToken->is(tok::r_brace) && Tok.isOneOf(tok::amp, tok::ampamp) &&
+ PrevToken->MatchingParen && PrevToken->MatchingParen->is(TT_Unknown))
+ return TT_BinaryOperator;
+
----------------
jackhong12 wrote:
> jackhong12 wrote:
> > HazardyKnusperkeks wrote:
> > > Unknown is everything, until some type is assigned. This way it should be
> > > clearer.
> > >
> > > Also put that check above the other one and add the `r_brace` back.
> > There are other problems. Clang-format will split the input into multiple
> > lines first. For instance, `struct {\n int n;\n} &&ptr={};` will be
> > separated as `struct {`, `int n;` and `} &&ptr={};`. It only handles the
> > relation in the line. When declaring a struct variable, the value of
> > `MatchingParen` will always be NULL instead of pointing to the last left
> > brace. So it will not enter that branch in this case.
> ```
> if (PrevToken->is(tok::r_brace) && Tok.isOneOf(tok::amp, tok::ampamp) &&
> PrevToken->MatchingParen) {
> if (PrevToken->MatchingParen->is(TT_RecordLBrace))
> return TT_PointerOrReference;
> else
> return TT_BinaryOperator;
> }
> ```
> How about this way? Although the branch of TT_PointerOrReference will not be
> taken, it's clearer for reading.
Then I think I would prefer a comment which explains the logic instead of
adding dead (and thus untested) code.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D127873/new/
https://reviews.llvm.org/D127873
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits