Lines Matching refs:Line

38 void printLine(llvm::raw_ostream &OS, const UnwrappedLine &Line,  in printLine()  argument
40 OS << Prefix << "Line(" << Line.Level << ", FSC=" << Line.FirstStartColumn in printLine()
41 << ")" << (Line.InPPDirective ? " MACRO" : "") << ": "; in printLine()
43 for (std::list<UnwrappedLineNode>::const_iterator I = Line.Tokens.begin(), in printLine()
44 E = Line.Tokens.end(); in printLine()
67 LLVM_ATTRIBUTE_UNUSED static void printDebugInfo(const UnwrappedLine &Line) { in printDebugInfo() argument
68 printLine(llvm::dbgs(), Line); in printDebugInfo()
73 ScopedDeclarationState(UnwrappedLine &Line, llvm::BitVector &Stack, in ScopedDeclarationState() argument
75 : Line(Line), Stack(Stack) { in ScopedDeclarationState()
76 Line.MustBeDeclaration = MustBeDeclaration; in ScopedDeclarationState()
82 Line.MustBeDeclaration = Stack.back(); in ~ScopedDeclarationState()
84 Line.MustBeDeclaration = true; in ~ScopedDeclarationState()
88 UnwrappedLine &Line; member in clang::format::__anon49c1c4920111::ScopedDeclarationState
94 std::ostream &operator<<(std::ostream &Stream, const UnwrappedLine &Line) { in operator <<() argument
96 printLine(OS, Line); in operator <<()
107 else if (!Parser.Line->Tokens.empty()) in ScopedLineState()
108 Parser.CurrentLines = &Parser.Line->Tokens.back().Children; in ScopedLineState()
109 PreBlockLine = std::move(Parser.Line); in ScopedLineState()
110 Parser.Line = std::make_unique<UnwrappedLine>(); in ScopedLineState()
111 Parser.Line->Level = PreBlockLine->Level; in ScopedLineState()
112 Parser.Line->PPLevel = PreBlockLine->PPLevel; in ScopedLineState()
113 Parser.Line->InPPDirective = PreBlockLine->InPPDirective; in ScopedLineState()
114 Parser.Line->InMacroBody = PreBlockLine->InMacroBody; in ScopedLineState()
115 Parser.Line->UnbracedBodyLevel = PreBlockLine->UnbracedBodyLevel; in ScopedLineState()
119 if (!Parser.Line->Tokens.empty()) in ~ScopedLineState()
121 assert(Parser.Line->Tokens.empty()); in ~ScopedLineState()
122 Parser.Line = std::move(PreBlockLine); in ~ScopedLineState()
163 : Line(new UnwrappedLine), MustBreakBeforeNextToken(false), in UnwrappedLineParser()
182 Line.reset(new UnwrappedLine); in reset()
193 Line->FirstStartColumn = FirstStartColumn; in reset()
207 Line->FirstStartColumn = FirstStartColumn; in parse()
220 for (auto &Line : Lines) in parse() local
221 if (Line.InPPDirective && Line.Level > 0) in parse()
222 --Line.Level; in parse()
234 for (const auto &Line : Lines) { in parse() local
235 if (!Line.Tokens.empty()) { in parse()
236 auto it = ExpandedLines.find(Line.Tokens.begin()->Tok); in parse()
245 LLVM_DEBUG(printDebugInfo(Line)); in parse()
246 Callback.consumeUnwrappedLine(Line); in parse()
252 for (const UnwrappedLine &Line : Lines) { in parse() local
253 LLVM_DEBUG(printDebugInfo(Line)); in parse()
254 Callback.consumeUnwrappedLine(Line); in parse()
274 bool MustBeDeclaration = !Line->InPPDirective && !Style.isJavaScript(); in parseFile()
275 ScopedDeclarationState DeclarationState(*Line, DeclarationScopeStack, in parseFile()
417 if (!Style.RemoveBracesLLVM || Line->InPPDirective || in parseLevel()
451 (Style.isJavaScript() && Line->MustBeDeclaration)) { in parseLevel()
462 (Line->InPPDirective && Line->Level == 1))) { in parseLevel()
463 ++Line->Level; in parseLevel()
507 if (!Line->InMacroBody && !Style.isTableGen()) { in calculateBraceTypes()
614 if (IsCpp && Line->InMacroBody && PrevTok != FormatTok && in calculateBraceTypes()
678 hash_combine(h, i.Line); in computePPHash()
710 AnnotatedLine Line(ParsedLine); in mightFitOnOneLine() local
711 assert(Line.Last == LastToken); in mightFitOnOneLine()
714 Annotator.annotate(Line); in mightFitOnOneLine()
715 Annotator.calculateFormattingInformation(Line); in mightFitOnOneLine()
727 if (const auto *FirstToken = Line.First; FirstToken->is(tok::r_brace)) { in mightFitOnOneLine()
741 assert(!Line.InMacroBody); in mightFitOnOneLine()
742 assert(!Line.InPPDirective); in mightFitOnOneLine()
743 return Line.Level * Style.IndentWidth + Length <= ColumnLimit; in mightFitOnOneLine()
778 ++Line->Level; in parseBlock()
783 const unsigned InitialLevel = Line->Level; in parseBlock()
792 if (Line->Level > 300) in parseBlock()
810 --Line->Level; in parseBlock()
812 ScopedDeclarationState DeclarationState(*Line, DeclarationScopeStack, in parseBlock()
815 Line->Level += AddLevels; in parseBlock()
825 Line->Level = InitialLevel; in parseBlock()
894 Line->Level = InitialLevel; in parseBlock()
912 Line->MatchingOpeningBlockLineIndex = OpeningLineIndex; in parseBlock()
923 static bool isGoogScope(const UnwrappedLine &Line) { in isGoogScope() argument
926 if (Line.Tokens.size() < 4) in isGoogScope()
928 auto I = Line.Tokens.begin(); in isGoogScope()
941 static bool isIIFE(const UnwrappedLine &Line, in isIIFE() argument
947 if (Line.Tokens.size() < 3) in isIIFE()
949 auto I = Line.Tokens.begin(); in isIIFE()
988 (isGoogScope(*Line) || isIIFE(*Line, Keywords))); in parseChildBlock()
990 ScopedDeclarationState DeclarationState(*Line, DeclarationScopeStack, in parseChildBlock()
992 Line->Level += SkipIndent ? 0 : 1; in parseChildBlock()
995 Line->Level -= SkipIndent ? 0 : 1; in parseChildBlock()
1002 ScopedMacroState MacroState(*Line, Tokens, FormatTok); in parsePPDirective()
1041 size_t Line = CurrentLines->size(); in conditionalCompilationCondition() local
1043 Line += Lines.size(); in conditionalCompilationCondition()
1047 PPStack.push_back({PP_Unreachable, Line}); in conditionalCompilationCondition()
1049 PPStack.push_back({PP_Conditional, Line}); in conditionalCompilationCondition()
1105 for (auto &Line : Lines) { in parsePPIf() local
1106 if (Line.Tokens.front().Tok->isNot(tok::comment)) { in parsePPIf()
1161 for (auto &Line : Lines) { in parsePPDefine() local
1162 if (!Line.Tokens.front().Tok->isOneOf(tok::comment, tok::hash)) { in parsePPDefine()
1182 Line->Level += PPBranchLevel + 1; in parsePPDefine()
1184 ++Line->Level; in parsePPDefine()
1186 Line->PPLevel = PPBranchLevel + (IncludeGuard == IG_Defined ? 0 : 1); in parsePPDefine()
1187 assert((int)Line->PPLevel >= 0); in parsePPDefine()
1188 Line->InMacroBody = true; in parsePPDefine()
1208 Line->InPragmaDirective = true; in parsePPPragma()
1217 Line->Level += PPBranchLevel + 1; in parsePPUnknown()
1397 bool HasAt = llvm::any_of(Line->Tokens, [](UnwrappedLineNode &LineNode) { in readTokenWithJavaScriptASI()
1496 if (Style.isJavaScript() && Line->MustBeDeclaration) { in parseStructuralElement()
1507 if (Style.isJavaScript() && Line->MustBeDeclaration) { in parseStructuralElement()
1514 if (Style.isJavaScript() && Line->MustBeDeclaration) { in parseStructuralElement()
1523 if (Style.isJavaScript() && Line->MustBeDeclaration) { in parseStructuralElement()
1533 if (Style.isJavaScript() && Line->MustBeDeclaration) { in parseStructuralElement()
1564 if (Style.isJavaScript() && Line->MustBeDeclaration) { in parseStructuralElement()
1573 if (Style.isJavaScript() && Line->MustBeDeclaration) { in parseStructuralElement()
1682 Tokens->peekNextToken()->is(tok::colon) && !Line->MustBeDeclaration) { in parseStructuralElement()
1684 if (!Line->InMacroBody || CurrentLines->size() > 1) in parseStructuralElement()
1685 Line->Tokens.begin()->Tok->MustBreakBefore = true; in parseStructuralElement()
1837 Line->SeenDecltypeAuto = true; in parseStructuralElement()
1901 IsDecltypeAutoFunction = Line->SeenDecltypeAuto; in parseStructuralElement()
1907 Line->Tokens.front().Tok->is(Keywords.kw_synchronized)) { in parseStructuralElement()
1928 if (Style.isJavaScript() && Line->MustBeDeclaration) { in parseStructuralElement()
1940 Line->MustBeDeclaration) { in parseStructuralElement()
1954 size_t TokenCount = Line->Tokens.size(); in parseStructuralElement()
1958 Line->Tokens.front().Tok->isNot(Keywords.kw_async)))) { in parseStructuralElement()
2018 auto I = Line->Tokens.begin(), E = Line->Tokens.end(); in parseStructuralElement()
2065 Line->Tokens.begin()->Tok->is(Keywords.kw_defset)) { in parseStructuralElement()
2104 if (Style.isJavaScript() && Line->MustBeDeclaration) { in parseStructuralElement()
2205 ++Line->Level; in tryToParsePropertyAccessor()
2208 --Line->Level; in tryToParsePropertyAccessor()
2212 ++Line->Level; in tryToParsePropertyAccessor()
2218 --Line->Level; in tryToParsePropertyAccessor()
2355 NestedLambdas.push_back(Line->SeenDecltypeAuto); in tryToParseLambda()
2566 if (!MightBeStmtExpr && !MightBeFoldExpr && !Line->InMacroBody && in parseParens()
2715 static FormatToken *getLastNonComment(const UnwrappedLine &Line) { in getLastNonComment() argument
2716 for (const auto &Token : llvm::reverse(Line.Tokens)) in getLastNonComment()
2726 if (Style.InsertBraces && !Line->InPPDirective && !Line->Tokens.empty() && in parseUnbracedBody()
2729 ? getLastNonComment(*Line) in parseUnbracedBody()
2730 : Line->Tokens.back().Tok; in parseUnbracedBody()
2741 ++Line->Level; in parseUnbracedBody()
2742 ++Line->UnbracedBodyLevel; in parseUnbracedBody()
2744 --Line->UnbracedBodyLevel; in parseUnbracedBody()
2747 assert(!Line->InPPDirective); in parseUnbracedBody()
2762 --Line->Level; in parseUnbracedBody()
2873 CompoundStatementIndenter Indenter(this, Style, Line->Level); in parseIfThenElse()
2910 CompoundStatementIndenter Indenter(this, Style, Line->Level); in parseIfThenElse()
2932 ++Line->Level; in parseIfThenElse()
2943 --Line->Level; in parseIfThenElse()
3026 CompoundStatementIndenter Indenter(this, Style, Line->Level); in parseTryCatch()
3037 ++Line->Level; in parseTryCatch()
3039 --Line->Level; in parseTryCatch()
3066 Line->MustBeDeclaration = false; in parseTryCatch()
3067 CompoundStatementIndenter Indenter(this, Style, Line->Level); in parseTryCatch()
3121 ++Line->Level; in parseNamespace()
3132 --Line->Level; in parseNamespace()
3186 CompoundStatementIndenter Indenter(this, Style, Line->Level); in parseLoopBody()
3263 ++Line->Level; in parseDoWhile()
3271 unsigned OldLineLevel = Line->Level; in parseLabel()
3274 Line->Level = 0; in parseLabel()
3275 else if (Line->Level > 1 || (!Line->InPPDirective && Line->Level > 0)) in parseLabel()
3276 --Line->Level; in parseLabel()
3281 CompoundStatementIndenter Indenter(this, Line->Level, in parseLabel()
3291 ++Line->Level; in parseLabel()
3302 Line->Level = OldLineLevel; in parseLabel()
3338 CompoundStatementIndenter Indenter(this, Style, Line->Level); in parseSwitch()
3350 ++Line->Level; in parseSwitch()
3352 --Line->Level; in parseSwitch()
3850 Line->Level += 1; in parseEnum()
3854 Line->Level -= 1; in parseEnum()
3960 ++Line->Level; in parseJavaEnumBody()
3988 --Line->Level; in parseJavaEnumBody()
4331 if (Line->Tokens.empty()) { in parseJavaScriptEs6ImportExport()
4434 Line->IsContinuation = true; in parseVerilogHierarchyHeader()
4496 auto InitialLevel = Line->Level++; in parseVerilogTable()
4505 Line->Level = InitialLevel; in parseVerilogTable()
4516 auto OrigLevel = Line->Level; in parseVerilogCaseLabel()
4518 if (Line->Level == 0 || (Line->InPPDirective && Line->Level <= 1)) in parseVerilogCaseLabel()
4519 ++Line->Level; in parseVerilogCaseLabel()
4521 --Line->Level; in parseVerilogCaseLabel()
4527 Line->Level = OrigLevel; in parseVerilogCaseLabel()
4530 bool UnwrappedLineParser::containsExpansion(const UnwrappedLine &Line) const { in containsExpansion()
4531 for (const auto &N : Line.Tokens) { in containsExpansion()
4542 if (Line->Tokens.empty()) in addUnwrappedLine()
4547 printDebugInfo(*Line); in addUnwrappedLine()
4556 Line->MatchingOpeningBlockLineIndex != UnwrappedLine::kInvalidIndex && in addUnwrappedLine()
4562 if (!parsingPPDirective() && !InExpansion && containsExpansion(*Line)) { in addUnwrappedLine()
4564 Reconstruct.emplace(Line->Level, Unexpanded); in addUnwrappedLine()
4565 Reconstruct->addLine(*Line); in addUnwrappedLine()
4570 CurrentExpandedLines.push_back(std::move(*Line)); in addUnwrappedLine()
4590 CurrentLines->push_back(std::move(*Line)); in addUnwrappedLine()
4592 Line->Tokens.clear(); in addUnwrappedLine()
4593 Line->MatchingOpeningBlockLineIndex = UnwrappedLine::kInvalidIndex; in addUnwrappedLine()
4594 Line->FirstStartColumn = 0; in addUnwrappedLine()
4595 Line->IsContinuation = false; in addUnwrappedLine()
4596 Line->SeenDecltypeAuto = false; in addUnwrappedLine()
4599 --Line->Level; in addUnwrappedLine()
4613 return (Line->InPPDirective || FormatTok.HasUnescapedNewline) && in isOnNewLine()
4621 const UnwrappedLine &Line, in continuesLineCommentSection() argument
4623 if (Line.Tokens.empty()) in continuesLineCommentSection()
4700 const FormatToken *MinColumnToken = Line.Tokens.front().Tok; in continuesLineCommentSection()
4705 for (const UnwrappedLineNode &Node : Line.Tokens) { in continuesLineCommentSection()
4720 return continuesLineComment(FormatTok, /*Previous=*/Line.Tokens.back().Tok, in continuesLineCommentSection()
4725 bool JustComments = Line->Tokens.empty(); in flushComments()
4736 continuesLineCommentSection(*Tok, *Line, CommentPragmasRegex); in flushComments()
4810 continuesLineCommentSection(*FormatTok, *Line, CommentPragmasRegex); in distributeComments()
4861 while (!Line->InPPDirective && FormatTok->is(tok::hash) && in readToken()
4869 bool SwitchToPreprocessorLines = !Line->Tokens.empty(); in readToken()
4872 static_cast<unsigned>(-LevelDifference) <= Line->Level) && in readToken()
4874 Line->Level += LevelDifference; in readToken()
4880 Line->Level += PPBranchLevel; in readToken()
4882 assert(Line->Level >= Line->UnbracedBodyLevel); in readToken()
4883 Line->Level -= Line->UnbracedBodyLevel; in readToken()
4892 !Line->InPPDirective) { in readToken()
4899 !Line->InPPDirective) { in readToken()
4905 auto PreCall = std::move(Line); in readToken()
4906 Line.reset(new UnwrappedLine); in readToken()
4912 assert(Line->Tokens.front().Tok == ID); in readToken()
4914 auto UnexpandedLine = std::move(Line); in readToken()
4916 Line = std::move(PreCall); in readToken()
5005 assert(Line->Tokens.empty()); in parseMacroCall()
5013 auto ArgStart = std::prev(Line->Tokens.end()); in parseMacroCall()
5029 pushTokens(std::next(ArgStart), Line->Tokens.end(), Args->back()); in parseMacroCall()
5039 pushTokens(std::next(ArgStart), Line->Tokens.end(), Args->back()); in parseMacroCall()
5041 ArgStart = std::prev(Line->Tokens.end()); in parseMacroCall()
5049 Line->Tokens.resize(1); in parseMacroCall()
5056 Line->Tokens.push_back(UnwrappedLineNode(Tok)); in pushToken()
5058 Line->Tokens.back().Tok->MustBreakBefore = true; in pushToken()
5059 Line->Tokens.back().Tok->MustBreakBeforeFinalized = true; in pushToken()