================ @@ -803,6 +803,46 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun, return !Tok.Previous->isOneOf(TT_CastRParen, tok::kw_for, tok::kw_while, tok::kw_switch); }; + // Detecting functions is brittle. It would be better if we could annotate + // the LParen type of functions/calls. + const auto IsFunctionDeclParen = [&](const FormatToken &Tok) { + return Tok.is(tok::l_paren) && Tok.Previous && + (Tok.Previous->is(TT_FunctionDeclarationName) || + (Tok.Previous->Previous && + Tok.Previous->Previous->is(tok::coloncolon) && + Tok.Previous->Previous->Previous && + Tok.Previous->Previous->Previous->is(TT_FunctionDeclarationName))); + }; + const auto IsFunctionCallParen = [&](const FormatToken &Tok) { + return Tok.is(tok::l_paren) && Tok.ParameterCount > 0 && Tok.Previous && + Tok.Previous->is(tok::identifier); + }; + const auto IsInTemplateString = [&](const FormatToken &Tok) { + if (!Style.isJavaScript()) + return false; + for (const FormatToken *Prev = &Tok; Prev; Prev = Prev->Previous) { + if (Prev->is(TT_TemplateString) && Prev->opensScope()) + return true; + if (Prev->is(TT_TemplateString) && Prev->closesScope()) + break; + } + return false; + }; + const auto IsNotSimpleFunction = [&](const FormatToken &Tok) { ---------------- HazardyKnusperkeks wrote:
What is a simple function? A bit more comments would be nice. https://github.com/llvm/llvm-project/pull/93140 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits