Lines Matching refs:Line
31 static bool startsWithInitStatement(const AnnotatedLine &Line) { in startsWithInitStatement() argument
32 return Line.startsWith(tok::kw_for) || Line.startsWith(tok::kw_if) || in startsWithInitStatement()
33 Line.startsWith(tok::kw_switch); in startsWithInitStatement()
113 AnnotatingParser(const FormatStyle &Style, AnnotatedLine &Line, in AnnotatingParser() argument
115 : Style(Style), Line(Line), CurrentToken(Line.First), AutoFound(false), in AnnotatingParser()
211 !Line.startsWith(tok::kw_template)) { in parseAngle()
297 (Line.startsWith(Keywords.kw_type, tok::identifier) || in parseParens()
298 Line.startsWith(tok::kw_export, Keywords.kw_type, in parseParens()
329 } else if (Line.InPPDirective && in parseParens()
345 } else if (!Line.MustBeDeclaration && !Line.InPPDirective) { in parseParens()
423 Line.MustBeDeclaration))) { in parseParens()
609 bool InsideInlineASM = Line.startsWith(tok::kw_asm); in parseSquare()
785 } else if (!Style.isVerilog() && !Line.InPragmaDirective && in parseSquare()
946 if (!Tok->Previous && Line.MustBeDeclaration) in consumeToken()
956 !Line.First->isOneOf(tok::kw_enum, tok::kw_case)) || in consumeToken()
962 Line.MustBeDeclaration)) { // method/property declaration in consumeToken()
991 if (Line.Level > 1 || (!Line.InPPDirective && Line.Level > 0)) in consumeToken()
992 --Line.Level; in consumeToken()
996 if (Line.First->isOneOf(Keywords.kw_module, Keywords.kw_import) || in consumeToken()
997 Line.First->startsSequence(tok::kw_export, Keywords.kw_module) || in consumeToken()
998 Line.First->startsSequence(tok::kw_export, Keywords.kw_import)) { in consumeToken()
1009 Line.startsWith(TT_ObjCMethodSpecifier)) { in consumeToken()
1015 Line.startsWith(TT_ObjCMethodSpecifier) && in consumeToken()
1044 !Line.First->isOneOf(tok::kw_enum, tok::kw_case, in consumeToken()
1070 !Line.InPragmaDirective) { in consumeToken()
1129 if (Line.MustBeDeclaration && Contexts.size() == 1 && in consumeToken()
1130 !Contexts.back().IsExpression && !Line.startsWith(TT_ObjCProperty) && in consumeToken()
1135 Line.MightBeFunctionDecl = true; in consumeToken()
1230 if (Line.MustBeDeclaration && !Contexts.back().IsExpression && in consumeToken()
1238 if ((!Contexts.back().IsExpression && Line.MustBeDeclaration) || in consumeToken()
1261 (Contexts.size() == 1 || startsWithInitStatement(Line))) { in consumeToken()
1263 Line.IsMultiVariableDeclStmt = true; in consumeToken()
1273 (Line.Level > 1 || (!Line.InPPDirective && Line.Level > 0))) { in consumeToken()
1274 --Line.Level; in consumeToken()
1287 Line.IsContinuation = true; in consumeToken()
1459 if (!Line.InMacroBody && CurrentToken->is(tok::hash)) { in parseLine()
1485 if (CurrentToken->is(tok::less) && Line.Last->is(tok::greater)) { in parseLine()
1492 if (Style.Language == FormatStyle::LK_Proto && Line.Level == 0 && in parseLine()
1519 if (Line.First->is(tok::kw_export) && in parseLine()
1535 if (Line.startsWith(TT_ObjCMethodSpecifier)) { in parseLine()
1675 if (Line.First->isOneOf(tok::kw_using, tok::kw_return)) in modifyContext()
1677 if (Line.First->is(tok::kw_template)) { in modifyContext()
1685 const FormatToken *Tok = Line.First->getNextNonComment(); in modifyContext()
1710 (Line.startsWith(Keywords.kw_type, tok::identifier) || in modifyContext()
1711 Line.startsWith(tok::kw_export, Keywords.kw_type, in modifyContext()
1721 if (!Line.startsWith(TT_UnaryOperator)) { in modifyContext()
1761 if (Line.MustBeDeclaration && in modifyContext()
1869 (!Line.MightBeFunctionDecl || Current.NestingLevel != 0)) { in determineTokenType()
1882 } else if (Current.is(tok::arrow) && AutoFound && Line.MustBeDeclaration && in determineTokenType()
1910 if (Style.isJavaScript() && Line.MustBeDeclaration && in determineTokenType()
2005 Line.MightBeFunctionDecl && Contexts.size() == 1) { in determineTokenType()
2474 AnnotatedLine &Line; member in clang::format::__anon192501e00111::AnnotatingParser
2494 AnnotatedLine &Line) in ExpressionParser() argument
2495 : Style(Style), Keywords(Keywords), Line(Line), Current(Line.First) {} in ExpressionParser()
2586 auto Ret = Current ? Current : Line.Last; in parse()
2714 const AnnotatedLine &Line; member in clang::format::__anon192501e00111::ExpressionParser
2723 for (AnnotatedLine *Line : llvm::reverse(Lines)) { in setCommentLineLevels()
2724 assert(Line->First); in setCommentLineLevels()
2728 if (NextNonCommentLine && Line->isComment() && in setCommentLineLevels()
2731 Line->First->OriginalColumn) { in setCommentLineLevels()
2736 Line->Type = LT_CommentAbovePPDirective; in setCommentLineLevels()
2740 Line->Level = Style.IndentPPDirectives != FormatStyle::PPDIS_BeforeHash && in setCommentLineLevels()
2745 NextNonCommentLine = Line->First->isNot(tok::r_brace) ? Line : nullptr; in setCommentLineLevels()
2748 setCommentLineLevels(Line->Children); in setCommentLineLevels()
2752 static unsigned maxNestingDepth(const AnnotatedLine &Line) { in maxNestingDepth() argument
2754 for (const auto *Tok = Line.First; Tok != nullptr; Tok = Tok->Next) in maxNestingDepth()
2759 void TokenAnnotator::annotate(AnnotatedLine &Line) const { in annotate()
2760 for (auto &Child : Line.Children) in annotate()
2763 AnnotatingParser Parser(Style, Line, Keywords); in annotate()
2764 Line.Type = Parser.parseLine(); in annotate()
2770 if (maxNestingDepth(Line) > 50) in annotate()
2771 Line.Type = LT_Invalid; in annotate()
2773 if (Line.Type == LT_Invalid) in annotate()
2776 ExpressionParser ExprParser(Style, Keywords, Line); in annotate()
2779 if (Line.startsWith(TT_ObjCMethodSpecifier)) in annotate()
2780 Line.Type = LT_ObjCMethodDecl; in annotate()
2781 else if (Line.startsWith(TT_ObjCDecl)) in annotate()
2782 Line.Type = LT_ObjCDecl; in annotate()
2783 else if (Line.startsWith(TT_ObjCProperty)) in annotate()
2784 Line.Type = LT_ObjCProperty; in annotate()
2786 Line.First->SpacesRequiredBefore = 1; in annotate()
2787 Line.First->CanBreakBefore = Line.First->MustBreakBefore; in annotate()
2793 const AnnotatedLine &Line) { in isFunctionDeclarationName() argument
2867 if (Line.Last->is(tok::l_brace)) in isFunctionDeclarationName()
2888 !Line.endsWith(tok::semi)) { in isFunctionDeclarationName()
2912 bool TokenAnnotator::mustBreakForReturnType(const AnnotatedLine &Line) const { in mustBreakForReturnType()
2913 assert(Line.MightBeFunctionDecl); in mustBreakForReturnType()
2918 Line.Level > 0) { in mustBreakForReturnType()
2930 return Line.mightBeFunctionDefinition(); in mustBreakForReturnType()
2948 void TokenAnnotator::calculateFormattingInformation(AnnotatedLine &Line) const { in calculateFormattingInformation()
2949 for (AnnotatedLine *ChildLine : Line.Children) in calculateFormattingInformation()
2952 Line.First->TotalLength = in calculateFormattingInformation()
2953 Line.First->IsMultiline ? Style.ColumnLimit in calculateFormattingInformation()
2954 : Line.FirstStartColumn + Line.First->ColumnWidth; in calculateFormattingInformation()
2955 FormatToken *Current = Line.First->Next; in calculateFormattingInformation()
2956 bool InFunctionDecl = Line.MightBeFunctionDecl; in calculateFormattingInformation()
2959 Line.Type == LT_ArrayOfStructInitializer); in calculateFormattingInformation()
2961 calculateArrayInitializerColumnList(Line); in calculateFormattingInformation()
2965 if (isFunctionDeclarationName(Style.isCpp(), *Tok, Line)) { in calculateFormattingInformation()
2970 Line.ReturnTypeWrapped = true; in calculateFormattingInformation()
3010 spaceRequiredBefore(Line, *Current)) { in calculateFormattingInformation()
3019 Current->MustBreakBefore || mustBreakBefore(Line, *Current); in calculateFormattingInformation()
3022 Current->MustBreakBefore = mustBreakForReturnType(Line); in calculateFormattingInformation()
3027 Current->MustBreakBefore || canBreakBefore(Line, *Current); in calculateFormattingInformation()
3056 Current->SplitPenalty = splitPenalty(Line, *Current, InFunctionDecl); in calculateFormattingInformation()
3068 calculateUnbreakableTailLengths(Line); in calculateFormattingInformation()
3069 unsigned IndentLevel = Line.Level; in calculateFormattingInformation()
3070 for (Current = Line.First; Current != nullptr; Current = Current->Next) { in calculateFormattingInformation()
3083 LLVM_DEBUG({ printDebugInfo(Line); }); in calculateFormattingInformation()
3087 AnnotatedLine &Line) const { in calculateUnbreakableTailLengths()
3089 FormatToken *Current = Line.Last; in calculateUnbreakableTailLengths()
3104 AnnotatedLine &Line) const { in calculateArrayInitializerColumnList()
3105 if (Line.First == Line.Last) in calculateArrayInitializerColumnList()
3107 auto *CurrentToken = Line.First; in calculateArrayInitializerColumnList()
3110 while (CurrentToken != nullptr && CurrentToken != Line.Last) { in calculateArrayInitializerColumnList()
3116 calculateInitializerColumnList(Line, CurrentToken->Next, Depth + 1); in calculateArrayInitializerColumnList()
3124 AnnotatedLine &Line, FormatToken *CurrentToken, unsigned Depth) const { in calculateInitializerColumnList() argument
3125 while (CurrentToken != nullptr && CurrentToken != Line.Last) { in calculateInitializerColumnList()
3142 unsigned TokenAnnotator::splitPenalty(const AnnotatedLine &Line, in splitPenalty() argument
3197 if (Line.startsWith(tok::kw_for) && Right.PartOfMultiVariableDeclStmt) in splitPenalty()
3252 if (Line.startsWith(TT_ObjCMethodSpecifier)) in splitPenalty()
3264 if (Line.startsWith(tok::kw_for) && Left.is(tok::equal)) in splitPenalty()
3272 return Line.MightBeFunctionDecl ? 50 : 500; in splitPenalty()
3277 if (Line.Type == LT_ObjCDecl && Left.is(tok::l_paren) && Left.Previous && in splitPenalty()
3371 bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line, in spaceRequiredBetween() argument
3386 if (Style.ObjCSpaceAfterProperty && Line.Type == LT_ObjCProperty && in spaceRequiredBetween()
3441 if (Right.is(tok::less) && Line.Type == LT_ObjCDecl) { in spaceRequiredBetween()
3481 if (Left.is(tok::r_paren) && Line.MightBeFunctionDecl) { in spaceRequiredBetween()
3509 (Line.IsMultiVariableDeclStmt && in spaceRequiredBetween()
3511 (Left.NestingLevel == 1 && startsWithInitStatement(Line))))); in spaceRequiredBetween()
3516 !Line.IsMultiVariableDeclStmt))) { in spaceRequiredBetween()
3560 if (Line.IsMultiVariableDeclStmt && in spaceRequiredBetween()
3561 (Left.NestingLevel == Line.First->NestingLevel || in spaceRequiredBetween()
3562 ((Left.NestingLevel == Line.First->NestingLevel + 1) && in spaceRequiredBetween()
3563 startsWithInitStatement(Line)))) { in spaceRequiredBetween()
3696 if (Line.Type == LT_ObjCDecl) in spaceRequiredBetween()
3702 Left.isIf(Line.Type != LT_PreprocessorDirective) || in spaceRequiredBetween()
3713 if (Line.MightBeFunctionDecl && (Left.is(TT_FunctionDeclarationName))) { in spaceRequiredBetween()
3714 if (Line.mightBeFunctionDefinition()) { in spaceRequiredBetween()
3723 if (Line.Type != LT_PreprocessorDirective && Left.is(tok::r_square) && in spaceRequiredBetween()
3734 return ((!Line.MightBeFunctionDecl || !Left.Previous) && in spaceRequiredBetween()
3747 if (Line.Type != LT_PreprocessorDirective && in spaceRequiredBetween()
3810 bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line, in spaceRequiredBefore() argument
3850 Line.First->is(Keywords.kw_import)) { in spaceRequiredBefore()
4011 if (Line.MustBeDeclaration && Left.Tok.getIdentifierInfo()) in spaceRequiredBefore()
4058 Line.First->isOneOf(Keywords.kw_import, tok::kw_export)) { in spaceRequiredBefore()
4142 if (Line.Type == LT_ObjCMethodDecl) { in spaceRequiredBefore()
4152 if (Line.Type == LT_ObjCProperty && in spaceRequiredBefore()
4182 Line.First->isOneOf(tok::kw_default, tok::kw_case))) { in spaceRequiredBefore()
4185 if (Line.First->isOneOf(tok::kw_default, tok::kw_case)) in spaceRequiredBefore()
4312 Line.Type == LT_ImportStatement) { in spaceRequiredBefore()
4319 return spaceRequiredBetween(Line, Left, Right); in spaceRequiredBefore()
4346 static const FormatToken *getFirstNonComment(const AnnotatedLine &Line) { in getFirstNonComment() argument
4347 const FormatToken *Next = Line.First; in getFirstNonComment()
4355 bool TokenAnnotator::mustBreakBefore(const AnnotatedLine &Line, in mustBreakBefore() argument
4396 if (Left.is(TT_DictLiteral) && Left.is(tok::l_brace) && Line.Level == 0 && in mustBreakBefore()
4398 Line.First->isOneOf(tok::identifier, Keywords.kw_import, tok::kw_export, in mustBreakBefore()
4402 !Line.First->isOneOf(Keywords.kw_var, Keywords.kw_let)) { in mustBreakBefore()
4407 if (Left.is(tok::l_brace) && Line.Level == 0 && in mustBreakBefore()
4408 (Line.startsWith(tok::kw_enum) || in mustBreakBefore()
4409 Line.startsWith(tok::kw_const, tok::kw_enum) || in mustBreakBefore()
4410 Line.startsWith(tok::kw_export, tok::kw_enum) || in mustBreakBefore()
4411 Line.startsWith(tok::kw_export, tok::kw_const, tok::kw_enum))) { in mustBreakBefore()
4429 return (Left.NestingLevel == 0 && Line.Level == 0) && in mustBreakBefore()
4440 (Left.NestingLevel == 0 && Line.Level == 0 && in mustBreakBefore()
4488 if (Line.startsWith(tok::kw_asm) && Right.is(TT_InlineASMColon) && in mustBreakBefore()
4497 if (Style.JavaScriptWrapImports || Line.Type != LT_ImportStatement) { in mustBreakBefore()
4599 auto FirstNonComment = getFirstNonComment(Line); in mustBreakBefore()
4606 if (Line.startsWith(tok::kw_enum) || in mustBreakBefore()
4607 Line.startsWith(tok::kw_typedef, tok::kw_enum)) { in mustBreakBefore()
4621 Line.startsWith(Keywords.kw_interface))) { in mustBreakBefore()
4625 return (Line.startsWith(tok::kw_class) && Style.BraceWrapping.AfterClass) || in mustBreakBefore()
4626 (Line.startsWith(tok::kw_struct) && Style.BraceWrapping.AfterStruct); in mustBreakBefore()
4661 (Line.Last->is(tok::l_brace) || Style.BreakAfterJavaFieldAnnotations)) { in mustBreakBefore()
4780 bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line, in canBreakBefore() argument
4790 if (Line.First->is(TT_CSharpGenericTypeConstraint)) in canBreakBefore()
4894 return Line.IsMultiVariableDeclStmt || in canBreakBefore()
4979 if (Left.is(tok::r_paren) && Line.Type == LT_ObjCProperty) in canBreakBefore()
5014 Line.Type == LT_VirtualFunctionDecl && Left.NestingLevel == 0) { in canBreakBefore()
5134 void TokenAnnotator::printDebugInfo(const AnnotatedLine &Line) const { in printDebugInfo()
5135 llvm::errs() << "AnnotatedTokens(L=" << Line.Level << ", P=" << Line.PPLevel in printDebugInfo()
5136 << ", T=" << Line.Type << ", C=" << Line.IsContinuation in printDebugInfo()
5138 const FormatToken *Tok = Line.First; in printDebugInfo()
5154 assert(Tok == Line.Last); in printDebugInfo()