There should not be any cases where the angle brackets of template
parameters are directly followed by a literal. It is more likely that a
comparison is taking place instead.
This patch makes the TokenAnnotator prefer to annotate < and > as
operators when directly followed by a literal. A similar check already
exists for literals directly *before* potential template args.
Fixes https://github.com/llvm/llvm-project/issues/60140
Reviewed By: HazardyKnusperkeks, owenpan, MyDeveloperDay
Differential Revision: https://reviews.llvm.org/
D142139
} else {
CurrentToken->setType(TT_TemplateCloser);
}
+ if (CurrentToken->Next && CurrentToken->Next->Tok.isLiteral())
+ return false;
next();
return true;
}
// Not template parameters.
verifyFormat("return a < b && c > d;");
+ verifyFormat("a < 0 ? b : a > 0 ? c : d;");
verifyFormat("void f() {\n"
" while (a < b && c > d) {\n"
" }\n"