[clang-format] Treat && followed by noexcept operator as a binary operator inside template arguments

Fixes https://github.com/llvm/llvm-project/issues/44544.

Reviewed By: curdeius, MyDeveloperDay

Differential Revision: https://reviews.llvm.org/D120445
This commit is contained in:
Luis Penagos 2022-02-28 11:30:30 +01:00 committed by Marek Kurdej
parent 44adca60d4
commit 24d4f601aa
2 changed files with 6 additions and 0 deletions

View File

@ -2089,6 +2089,10 @@ private:
return TT_UnaryOperator;
const FormatToken *NextToken = Tok.getNextNonComment();
if (InTemplateArgument && NextToken && NextToken->is(tok::kw_noexcept))
return TT_BinaryOperator;
if (!NextToken ||
NextToken->isOneOf(tok::arrow, tok::equal, tok::kw_noexcept) ||
NextToken->canBePointerOrReferenceQualifier() ||

View File

@ -9512,6 +9512,8 @@ TEST_F(FormatTest, UnderstandsTemplateParameters) {
verifyFormat("f(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n"
" .template operator()<A>());",
getLLVMStyleWithColumns(35));
verifyFormat("bool_constant<a && noexcept(f())>");
verifyFormat("bool_constant<a || noexcept(f())>");
// Not template parameters.
verifyFormat("return a < b && c > d;");