Lines Matching refs:Line
42 static bool startsWithInitStatement(const AnnotatedLine &Line) { in startsWithInitStatement() argument
43 return Line.startsWith(tok::kw_for) || Line.startsWith(tok::kw_if) || in startsWithInitStatement()
44 Line.startsWith(tok::kw_switch); in startsWithInitStatement()
125 AnnotatingParser(const FormatStyle &Style, AnnotatedLine &Line, in AnnotatingParser() argument
128 : Style(Style), Line(Line), CurrentToken(Line.First), AutoFound(false), in AnnotatingParser()
249 if (MaybeAngles && InExpr && !Line.startsWith(tok::kw_template) && in parseAngle()
353 (Line.startsWith(Keywords.kw_type, tok::identifier) || in parseParens()
354 Line.startsWith(tok::kw_export, Keywords.kw_type, in parseParens()
387 } else if (Line.InPPDirective && in parseParens()
403 } else if (!Line.MustBeDeclaration && in parseParens()
404 (!Line.InPPDirective || (Line.InMacroBody && !Scopes.empty()))) { in parseParens()
491 (Line.MustBeDeclaration || in parseParens()
697 bool InsideInlineASM = Line.startsWith(tok::kw_asm); in parseSquare()
868 } else if (!Style.isVerilog() && !Line.InPragmaDirective && in parseSquare()
1308 if (!Prev && Line.MustBeDeclaration) in consumeToken()
1322 !Line.First->isOneOf(tok::kw_enum, tok::kw_case)) || in consumeToken()
1328 Line.MustBeDeclaration)) { // method/property declaration in consumeToken()
1356 if (Line.Level > 1 || (!Line.InPPDirective && Line.Level > 0)) in consumeToken()
1357 --Line.Level; in consumeToken()
1361 if (Line.First->isOneOf(Keywords.kw_module, Keywords.kw_import) || in consumeToken()
1362 Line.First->startsSequence(tok::kw_export, Keywords.kw_module) || in consumeToken()
1363 Line.First->startsSequence(tok::kw_export, Keywords.kw_import)) { in consumeToken()
1365 } else if (Line.First->is(tok::kw_asm)) { in consumeToken()
1372 Line.startsWith(TT_ObjCMethodSpecifier)) { in consumeToken()
1378 Line.startsWith(TT_ObjCMethodSpecifier) && in consumeToken()
1413 !Line.getFirstNonComment()->isOneOf(tok::kw_enum, tok::kw_case, in consumeToken()
1415 !Line.startsWith(tok::kw_typedef, tok::kw_enum)) { in consumeToken()
1429 Line.Type = LT_AccessModifier; in consumeToken()
1547 if (Line.MustBeDeclaration && Contexts.size() == 1 && in consumeToken()
1548 !Contexts.back().IsExpression && !Line.startsWith(TT_ObjCProperty) && in consumeToken()
1549 !Line.startsWith(tok::l_paren) && in consumeToken()
1555 Line.MightBeFunctionDecl = true; in consumeToken()
1569 Line.Type = LT_RequiresExpression; in consumeToken()
1696 if (Line.MustBeDeclaration && !Contexts.back().IsExpression && in consumeToken()
1715 if (!Contexts.back().IsExpression && Line.MustBeDeclaration && in consumeToken()
1740 Line.startsWith(Keywords.kw_assign)) { in consumeToken()
1743 (Contexts.size() == 1 || startsWithInitStatement(Line))) { in consumeToken()
1745 Line.IsMultiVariableDeclStmt = true; in consumeToken()
1755 (Line.Level > 1 || (!Line.InPPDirective && Line.Level > 0))) { in consumeToken()
1756 --Line.Level; in consumeToken()
1777 Line.IsContinuation = true; in consumeToken()
1961 if (!Line.InMacroBody && CurrentToken->is(tok::hash)) { in parseLine()
1986 if (CurrentToken->is(tok::less) && Line.Last->is(tok::greater)) { in parseLine()
1993 if (Style.Language == FormatStyle::LK_Proto && Line.Level == 0 && in parseLine()
2020 if (Line.First->is(tok::kw_export) && in parseLine()
2031 if (const auto Type = Line.Type; Type == LT_AccessModifier || in parseLine()
2041 if (Line.startsWith(TT_ObjCMethodSpecifier)) { in parseLine()
2191 if (Line.First->isOneOf(tok::kw_using, tok::kw_return)) in modifyContext()
2193 if (Line.First->is(tok::kw_template)) { in modifyContext()
2201 const FormatToken *Tok = Line.First->getNextNonComment(); in modifyContext()
2234 (Line.startsWith(Keywords.kw_type, tok::identifier) || in modifyContext()
2235 Line.startsWith(tok::kw_export, Keywords.kw_type, in modifyContext()
2245 if (!Line.startsWith(TT_UnaryOperator)) { in modifyContext()
2286 if (Line.MustBeDeclaration && in modifyContext()
2395 (!Line.MightBeFunctionDecl || Current.NestingLevel != 0)) { in determineTokenType()
2411 Line.MightBeFunctionDecl && Current.NestingLevel == 0 && in determineTokenType()
2439 if (Style.isJavaScript() && Line.MustBeDeclaration && in determineTokenType()
2554 Line.MightBeFunctionDecl && Contexts.size() == 1) { in determineTokenType()
2595 (!NextNonComment && !Line.InMacroBody) || in isStartOfName()
2599 (Line.InPragmaDirective && NextNonComment->is(tok::identifier))))) { in isStartOfName()
2905 (AfterRParen->Next->is(tok::numeric_constant) || Line.InPPDirective)) { in rParenEndsCast()
2909 if (Line.InPPDirective && AfterRParen->is(tok::minus)) in rParenEndsCast()
3127 if (Line.Type == LT_SimpleRequirement || in determineStarAmpUsage()
3164 AnnotatedLine &Line; member in clang::format::__anonadd98d890111::AnnotatingParser
3190 AnnotatedLine &Line) in ExpressionParser() argument
3191 : Style(Style), Keywords(Keywords), Line(Line), Current(Line.First) {} in ExpressionParser()
3320 auto Ret = Current ? Current : Line.Last; in parse()
3588 const AnnotatedLine &Line; member in clang::format::__anonadd98d890111::ExpressionParser
3597 for (AnnotatedLine *Line : reverse(Lines)) { in setCommentLineLevels()
3598 assert(Line->First); in setCommentLineLevels()
3603 Line->isComment() && !isClangFormatOff(Line->First->TokenText) && in setCommentLineLevels()
3605 Line->First->OriginalColumn) { in setCommentLineLevels()
3610 Line->Type = LT_CommentAbovePPDirective; in setCommentLineLevels()
3614 Line->Level = Style.IndentPPDirectives != FormatStyle::PPDIS_BeforeHash && in setCommentLineLevels()
3619 NextNonCommentLine = Line->First->isNot(tok::r_brace) ? Line : nullptr; in setCommentLineLevels()
3622 setCommentLineLevels(Line->Children); in setCommentLineLevels()
3626 static unsigned maxNestingDepth(const AnnotatedLine &Line) { in maxNestingDepth() argument
3628 for (const auto *Tok = Line.First; Tok; Tok = Tok->Next) in maxNestingDepth()
3635 static FormatToken *getFunctionName(const AnnotatedLine &Line, in getFunctionName() argument
3637 for (FormatToken *Tok = Line.getFirstNonComment(), *Name = nullptr; Tok; in getFunctionName()
3709 void TokenAnnotator::annotate(AnnotatedLine &Line) { in annotate() argument
3710 if (!Line.InMacroBody) in annotate()
3713 auto &ScopeStack = Line.InMacroBody ? MacroBodyScopes : Scopes; in annotate()
3714 AnnotatingParser Parser(Style, Line, Keywords, ScopeStack); in annotate()
3715 Line.Type = Parser.parseLine(); in annotate()
3717 if (!Line.Children.empty()) { in annotate()
3719 const bool InRequiresExpression = Line.Type == LT_RequiresExpression; in annotate()
3720 for (auto &Child : Line.Children) { in annotate()
3737 if (maxNestingDepth(Line) > 50) in annotate()
3738 Line.Type = LT_Invalid; in annotate()
3740 if (Line.Type == LT_Invalid) in annotate()
3743 ExpressionParser ExprParser(Style, Keywords, Line); in annotate()
3748 auto *Tok = getFunctionName(Line, OpeningParen); in annotate()
3750 Line.endsWith(TT_FunctionLBrace) || isCtorOrDtorName(Tok))) { in annotate()
3757 if (Line.startsWith(TT_ObjCMethodSpecifier)) in annotate()
3758 Line.Type = LT_ObjCMethodDecl; in annotate()
3759 else if (Line.startsWith(TT_ObjCDecl)) in annotate()
3760 Line.Type = LT_ObjCDecl; in annotate()
3761 else if (Line.startsWith(TT_ObjCProperty)) in annotate()
3762 Line.Type = LT_ObjCProperty; in annotate()
3764 auto *First = Line.First; in annotate()
3773 const AnnotatedLine &Line, in isFunctionDeclarationName() argument
3832 if (Line.startsWith(tok::kw_friend)) in isFunctionDeclarationName()
3883 if (Line.Last->is(tok::l_brace)) in isFunctionDeclarationName()
3902 !Line.endsWith(tok::semi)) { in isFunctionDeclarationName()
3924 bool TokenAnnotator::mustBreakForReturnType(const AnnotatedLine &Line) const { in mustBreakForReturnType()
3925 assert(Line.MightBeFunctionDecl); in mustBreakForReturnType()
3929 Line.Level > 0) { in mustBreakForReturnType()
3943 return Line.mightBeFunctionDefinition(); in mustBreakForReturnType()
3949 void TokenAnnotator::calculateFormattingInformation(AnnotatedLine &Line) const { in calculateFormattingInformation()
3950 if (Line.Computed) in calculateFormattingInformation()
3953 Line.Computed = true; in calculateFormattingInformation()
3955 for (AnnotatedLine *ChildLine : Line.Children) in calculateFormattingInformation()
3958 auto *First = Line.First; in calculateFormattingInformation()
3961 : Line.FirstStartColumn + First->ColumnWidth; in calculateFormattingInformation()
3964 Line.Type == LT_ArrayOfStructInitializer); in calculateFormattingInformation()
3966 calculateArrayInitializerColumnList(Line); in calculateFormattingInformation()
3968 const auto *FirstNonComment = Line.getFirstNonComment(); in calculateFormattingInformation()
3984 isFunctionDeclarationName(LangOpts, *Tok, Line, ClosingParen)) { in calculateFormattingInformation()
4002 Line.endsWith(tok::semi, tok::r_brace)) { in calculateFormattingInformation()
4003 auto *Tok = Line.Last->Previous; in calculateFormattingInformation()
4018 Line.ReturnTypeWrapped = true; in calculateFormattingInformation()
4071 bool InFunctionDecl = Line.MightBeFunctionDecl; in calculateFormattingInformation()
4109 spaceRequiredBefore(Line, *Current)) { in calculateFormattingInformation()
4118 Current->MustBreakBefore || mustBreakBefore(Line, *Current); in calculateFormattingInformation()
4121 Current->MustBreakBefore = mustBreakForReturnType(Line); in calculateFormattingInformation()
4126 Current->MustBreakBefore || canBreakBefore(Line, *Current); in calculateFormattingInformation()
4160 Line.Level * Style.IndentWidth + Line.Last->TotalLength > in calculateFormattingInformation()
4178 Current->SplitPenalty = splitPenalty(Line, *Current, InFunctionDecl); in calculateFormattingInformation()
4188 calculateUnbreakableTailLengths(Line); in calculateFormattingInformation()
4189 unsigned IndentLevel = Line.Level; in calculateFormattingInformation()
4203 LLVM_DEBUG({ printDebugInfo(Line); }); in calculateFormattingInformation()
4207 AnnotatedLine &Line) const { in calculateUnbreakableTailLengths()
4209 FormatToken *Current = Line.Last; in calculateUnbreakableTailLengths()
4224 AnnotatedLine &Line) const { in calculateArrayInitializerColumnList()
4225 if (Line.First == Line.Last) in calculateArrayInitializerColumnList()
4227 auto *CurrentToken = Line.First; in calculateArrayInitializerColumnList()
4230 while (CurrentToken && CurrentToken != Line.Last) { in calculateArrayInitializerColumnList()
4236 calculateInitializerColumnList(Line, CurrentToken->Next, Depth + 1); in calculateArrayInitializerColumnList()
4244 AnnotatedLine &Line, FormatToken *CurrentToken, unsigned Depth) const { in calculateInitializerColumnList() argument
4245 while (CurrentToken && CurrentToken != Line.Last) { in calculateInitializerColumnList()
4262 unsigned TokenAnnotator::splitPenalty(const AnnotatedLine &Line, in splitPenalty() argument
4317 if (Line.startsWith(tok::kw_for) && Right.PartOfMultiVariableDeclStmt) in splitPenalty()
4374 if (Line.startsWith(TT_ObjCMethodSpecifier)) in splitPenalty()
4386 if (Line.startsWith(tok::kw_for) && Left.is(tok::equal)) in splitPenalty()
4394 return Line.MightBeFunctionDecl ? 50 : 500; in splitPenalty()
4399 if (Line.Type == LT_ObjCDecl && Left.is(tok::l_paren) && Left.Previous && in splitPenalty()
4493 bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line, in spaceRequiredBetween() argument
4506 if (Style.ObjCSpaceAfterProperty && Line.Type == LT_ObjCProperty && in spaceRequiredBetween()
4515 Right.MatchingParen == &Left && Line.Children.empty()) { in spaceRequiredBetween()
4576 if (Right.is(tok::less) && Line.Type == LT_ObjCDecl) { in spaceRequiredBetween()
4616 if (Left.is(tok::r_paren) && Line.MightBeFunctionDecl) { in spaceRequiredBetween()
4644 (Line.IsMultiVariableDeclStmt && in spaceRequiredBetween()
4646 (Left.NestingLevel == 1 && startsWithInitStatement(Line))))); in spaceRequiredBetween()
4651 !Line.IsMultiVariableDeclStmt))) { in spaceRequiredBetween()
4696 if (Line.IsMultiVariableDeclStmt && in spaceRequiredBetween()
4697 (Left.NestingLevel == Line.First->NestingLevel || in spaceRequiredBetween()
4698 ((Left.NestingLevel == Line.First->NestingLevel + 1) && in spaceRequiredBetween()
4699 startsWithInitStatement(Line)))) { in spaceRequiredBetween()
4845 !(Line.MightBeFunctionDecl && Left.is(TT_FunctionDeclarationName))) { in spaceRequiredBetween()
4850 if (Line.Type == LT_ObjCDecl) in spaceRequiredBetween()
4856 Left.isIf(Line.Type != LT_PreprocessorDirective) || in spaceRequiredBetween()
4867 if (Line.MightBeFunctionDecl && Right.is(TT_FunctionDeclarationLParen)) { in spaceRequiredBetween()
4871 return Line.mightBeFunctionDefinition() in spaceRequiredBetween()
4876 if (Line.Type != LT_PreprocessorDirective && Left.is(tok::r_square) && in spaceRequiredBetween()
4895 if (Line.Type != LT_PreprocessorDirective && in spaceRequiredBetween()
4962 bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line, in spaceRequiredBefore() argument
5017 Line.First->is(Keywords.kw_import)) { in spaceRequiredBefore()
5185 if (Line.MustBeDeclaration && Left.Tok.getIdentifierInfo()) in spaceRequiredBefore()
5232 Line.First->isOneOf(Keywords.kw_import, tok::kw_export)) { in spaceRequiredBefore()
5392 if (Line.Type == LT_ObjCMethodDecl) { in spaceRequiredBefore()
5403 if (Line.Type == LT_ObjCProperty && in spaceRequiredBefore()
5564 Line.Type == LT_ImportStatement) { in spaceRequiredBefore()
5571 return spaceRequiredBetween(Line, Left, Right); in spaceRequiredBefore()
5598 bool TokenAnnotator::mustBreakBefore(const AnnotatedLine &Line, in mustBreakBefore() argument
5601 (!Style.RemoveEmptyLinesInUnwrappedLines || &Right == Line.First)) { in mustBreakBefore()
5607 if (Style.BreakFunctionDefinitionParameters && Line.MightBeFunctionDecl && in mustBreakBefore()
5608 Line.mightBeFunctionDefinition() && Left.MightBeFunctionDeclParen && in mustBreakBefore()
5616 Line.MightBeFunctionDecl && !Left.opensScope() && in mustBreakBefore()
5658 if (Left.is(TT_DictLiteral) && Left.is(tok::l_brace) && Line.Level == 0 && in mustBreakBefore()
5660 Line.First->isOneOf(tok::identifier, Keywords.kw_import, tok::kw_export, in mustBreakBefore()
5664 !Line.First->isOneOf(Keywords.kw_var, Keywords.kw_let)) { in mustBreakBefore()
5669 if (Left.is(tok::l_brace) && Line.Level == 0 && in mustBreakBefore()
5670 (Line.startsWith(tok::kw_enum) || in mustBreakBefore()
5671 Line.startsWith(tok::kw_const, tok::kw_enum) || in mustBreakBefore()
5672 Line.startsWith(tok::kw_export, tok::kw_enum) || in mustBreakBefore()
5673 Line.startsWith(tok::kw_export, tok::kw_const, tok::kw_enum))) { in mustBreakBefore()
5691 return (Left.NestingLevel == 0 && Line.Level == 0) && in mustBreakBefore()
5702 (Left.NestingLevel == 0 && Line.Level == 0 && in mustBreakBefore()
5780 if (Line.startsWith(tok::kw_asm) && Right.is(TT_InlineASMColon) && in mustBreakBefore()
5789 if (Style.JavaScriptWrapImports || Line.Type != LT_ImportStatement) { in mustBreakBefore()
5911 auto *FirstNonComment = Line.getFirstNonComment(); in mustBreakBefore()
5917 if (Line.startsWith(tok::kw_enum) || in mustBreakBefore()
5918 Line.startsWith(tok::kw_typedef, tok::kw_enum)) { in mustBreakBefore()
5932 Line.startsWith(Keywords.kw_interface))) { in mustBreakBefore()
5938 return (Line.startsWith(tok::kw_class) && in mustBreakBefore()
5940 (Line.startsWith(tok::kw_struct) && in mustBreakBefore()
5979 (Line.Last->is(tok::l_brace) || Style.BreakAfterJavaFieldAnnotations)) { in mustBreakBefore()
6073 bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line, in canBreakBefore() argument
6083 if (Line.First->is(TT_CSharpGenericTypeConstraint)) in canBreakBefore()
6234 return Line.IsMultiVariableDeclStmt || in canBreakBefore()
6320 if (Left.is(tok::r_paren) && Line.Type == LT_ObjCProperty) in canBreakBefore()
6359 Line.Type == LT_VirtualFunctionDecl && Left.NestingLevel == 0) { in canBreakBefore()
6469 void TokenAnnotator::printDebugInfo(const AnnotatedLine &Line) const { in printDebugInfo()
6470 llvm::errs() << "AnnotatedTokens(L=" << Line.Level << ", P=" << Line.PPLevel in printDebugInfo()
6471 << ", T=" << Line.Type << ", C=" << Line.IsContinuation in printDebugInfo()
6473 const FormatToken *Tok = Line.First; in printDebugInfo()
6489 assert(Tok == Line.Last); in printDebugInfo()