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()
66 LLVM_ATTRIBUTE_UNUSED static void printDebugInfo(const UnwrappedLine &Line) { in printDebugInfo() argument
67 printLine(llvm::dbgs(), Line); in printDebugInfo()
72 ScopedDeclarationState(UnwrappedLine &Line, llvm::BitVector &Stack, in ScopedDeclarationState() argument
74 : Line(Line), Stack(Stack) { in ScopedDeclarationState()
75 Line.MustBeDeclaration = MustBeDeclaration; in ScopedDeclarationState()
81 Line.MustBeDeclaration = Stack.back(); in ~ScopedDeclarationState()
83 Line.MustBeDeclaration = true; in ~ScopedDeclarationState()
87 UnwrappedLine &Line; member in clang::format::__anon0b27da130111::ScopedDeclarationState
100 else if (!Parser.Line->Tokens.empty()) in ScopedLineState()
101 Parser.CurrentLines = &Parser.Line->Tokens.back().Children; in ScopedLineState()
102 PreBlockLine = std::move(Parser.Line); in ScopedLineState()
103 Parser.Line = std::make_unique<UnwrappedLine>(); in ScopedLineState()
104 Parser.Line->Level = PreBlockLine->Level; in ScopedLineState()
105 Parser.Line->PPLevel = PreBlockLine->PPLevel; in ScopedLineState()
106 Parser.Line->InPPDirective = PreBlockLine->InPPDirective; in ScopedLineState()
107 Parser.Line->InMacroBody = PreBlockLine->InMacroBody; in ScopedLineState()
111 if (!Parser.Line->Tokens.empty()) in ~ScopedLineState()
113 assert(Parser.Line->Tokens.empty()); in ~ScopedLineState()
114 Parser.Line = std::move(PreBlockLine); in ~ScopedLineState()
155 : Line(new UnwrappedLine), MustBreakBeforeNextToken(false), in UnwrappedLineParser()
171 Line.reset(new UnwrappedLine); in reset()
182 Line->FirstStartColumn = FirstStartColumn; in reset()
196 Line->FirstStartColumn = FirstStartColumn; in parse()
209 for (auto &Line : Lines) in parse() local
210 if (Line.InPPDirective && Line.Level > 0) in parse()
211 --Line.Level; in parse()
223 for (const auto &Line : Lines) { in parse() local
224 if (!Line.Tokens.empty()) { in parse()
225 auto it = ExpandedLines.find(Line.Tokens.begin()->Tok); in parse()
234 LLVM_DEBUG(printDebugInfo(Line)); in parse()
235 Callback.consumeUnwrappedLine(Line); in parse()
241 for (const UnwrappedLine &Line : Lines) { in parse() local
242 LLVM_DEBUG(printDebugInfo(Line)); in parse()
243 Callback.consumeUnwrappedLine(Line); in parse()
263 bool MustBeDeclaration = !Line->InPPDirective && !Style.isJavaScript(); in parseFile()
264 ScopedDeclarationState DeclarationState(*Line, DeclarationScopeStack, in parseFile()
403 if (!Style.RemoveBracesLLVM || Line->InPPDirective || in parseLevel()
441 (Style.isJavaScript() && Line->MustBeDeclaration)) { in parseLevel()
451 (Line->InPPDirective && Line->Level == 1))) { in parseLevel()
452 ++Line->Level; in parseLevel()
499 if (!Line->InMacroBody) { in calculateBraceTypes()
602 if (Style.isCpp() && Line->InMacroBody && PrevTok != FormatTok && in calculateBraceTypes()
670 hash_combine(h, i.Line); in computePPHash()
702 AnnotatedLine Line(ParsedLine); in mightFitOnOneLine() local
703 assert(Line.Last == LastToken); in mightFitOnOneLine()
706 Annotator.annotate(Line); in mightFitOnOneLine()
707 Annotator.calculateFormattingInformation(Line); in mightFitOnOneLine()
719 if (const auto *FirstToken = Line.First; FirstToken->is(tok::r_brace)) { in mightFitOnOneLine()
733 assert(!Line.InMacroBody); in mightFitOnOneLine()
734 assert(!Line.InPPDirective); in mightFitOnOneLine()
735 return Line.Level * Style.IndentWidth + Length <= ColumnLimit; in mightFitOnOneLine()
770 ++Line->Level; in parseBlock()
775 const unsigned InitialLevel = Line->Level; in parseBlock()
784 if (Line->Level > 300) in parseBlock()
802 --Line->Level; in parseBlock()
804 ScopedDeclarationState DeclarationState(*Line, DeclarationScopeStack, in parseBlock()
807 Line->Level += AddLevels; in parseBlock()
817 Line->Level = InitialLevel; in parseBlock()
883 Line->Level = InitialLevel; in parseBlock()
901 Line->MatchingOpeningBlockLineIndex = OpeningLineIndex; in parseBlock()
912 static bool isGoogScope(const UnwrappedLine &Line) { in isGoogScope() argument
915 if (Line.Tokens.size() < 4) in isGoogScope()
917 auto I = Line.Tokens.begin(); in isGoogScope()
930 static bool isIIFE(const UnwrappedLine &Line, in isIIFE() argument
936 if (Line.Tokens.size() < 3) in isIIFE()
938 auto I = Line.Tokens.begin(); in isIIFE()
977 (isGoogScope(*Line) || isIIFE(*Line, Keywords))); in parseChildBlock()
979 ScopedDeclarationState DeclarationState(*Line, DeclarationScopeStack, in parseChildBlock()
981 Line->Level += SkipIndent ? 0 : 1; in parseChildBlock()
984 Line->Level -= SkipIndent ? 0 : 1; in parseChildBlock()
991 ScopedMacroState MacroState(*Line, Tokens, FormatTok); in parsePPDirective()
1030 size_t Line = CurrentLines->size(); in conditionalCompilationCondition() local
1032 Line += Lines.size(); in conditionalCompilationCondition()
1036 PPStack.push_back({PP_Unreachable, Line}); in conditionalCompilationCondition()
1038 PPStack.push_back({PP_Conditional, Line}); in conditionalCompilationCondition()
1094 for (auto &Line : Lines) { in parsePPIf() local
1095 if (Line.Tokens.front().Tok->isNot(tok::comment)) { in parsePPIf()
1150 for (auto &Line : Lines) { in parsePPDefine() local
1151 if (!Line.Tokens.front().Tok->isOneOf(tok::comment, tok::hash)) { in parsePPDefine()
1171 Line->Level += PPBranchLevel + 1; in parsePPDefine()
1173 ++Line->Level; in parsePPDefine()
1175 Line->PPLevel = PPBranchLevel + (IncludeGuard == IG_Defined ? 0 : 1); in parsePPDefine()
1176 assert((int)Line->PPLevel >= 0); in parsePPDefine()
1177 Line->InMacroBody = true; in parsePPDefine()
1203 Line->InPragmaDirective = true; in parsePPPragma()
1212 Line->Level += PPBranchLevel + 1; in parsePPUnknown()
1393 bool HasAt = llvm::any_of(Line->Tokens, [](UnwrappedLineNode &LineNode) { in readTokenWithJavaScriptASI()
1493 if (Style.isJavaScript() && Line->MustBeDeclaration) { in parseStructuralElement()
1504 if (Style.isJavaScript() && Line->MustBeDeclaration) { in parseStructuralElement()
1511 if (Style.isJavaScript() && Line->MustBeDeclaration) { in parseStructuralElement()
1520 if (Style.isJavaScript() && Line->MustBeDeclaration) { in parseStructuralElement()
1530 if (Style.isJavaScript() && Line->MustBeDeclaration) { in parseStructuralElement()
1553 if (Style.isJavaScript() && Line->MustBeDeclaration) { in parseStructuralElement()
1562 if (Style.isJavaScript() && Line->MustBeDeclaration) { in parseStructuralElement()
1672 Tokens->peekNextToken()->is(tok::colon) && !Line->MustBeDeclaration) { in parseStructuralElement()
1674 Line->Tokens.begin()->Tok->MustBreakBefore = true; in parseStructuralElement()
1819 Line->SeenDecltypeAuto = true; in parseStructuralElement()
1884 IsDecltypeAutoFunction = Line->SeenDecltypeAuto; in parseStructuralElement()
1890 Line->Tokens.front().Tok->is(Keywords.kw_synchronized)) { in parseStructuralElement()
1910 if (Style.isJavaScript() && Line->MustBeDeclaration) { in parseStructuralElement()
1922 Line->MustBeDeclaration) { in parseStructuralElement()
1936 size_t TokenCount = Line->Tokens.size(); in parseStructuralElement()
1940 Line->Tokens.front().Tok->isNot(Keywords.kw_async)))) { in parseStructuralElement()
2000 auto I = Line->Tokens.begin(), E = Line->Tokens.end(); in parseStructuralElement()
2047 Line->Tokens.begin()->Tok->is(Keywords.kw_defset)) { in parseStructuralElement()
2080 if (Style.isJavaScript() && Line->MustBeDeclaration) { in parseStructuralElement()
2176 ++Line->Level; in tryToParsePropertyAccessor()
2179 --Line->Level; in tryToParsePropertyAccessor()
2183 ++Line->Level; in tryToParsePropertyAccessor()
2189 --Line->Level; in tryToParsePropertyAccessor()
2324 NestedLambdas.push_back(Line->SeenDecltypeAuto); in tryToParseLambda()
2525 if (!MightBeStmtExpr && !MightBeFoldExpr && !Line->InMacroBody && in parseParens()
2659 static FormatToken *getLastNonComment(const UnwrappedLine &Line) { in getLastNonComment() argument
2660 for (const auto &Token : llvm::reverse(Line.Tokens)) in getLastNonComment()
2670 if (Style.InsertBraces && !Line->InPPDirective && !Line->Tokens.empty() && in parseUnbracedBody()
2673 ? getLastNonComment(*Line) in parseUnbracedBody()
2674 : Line->Tokens.back().Tok; in parseUnbracedBody()
2685 ++Line->Level; in parseUnbracedBody()
2689 assert(!Line->InPPDirective); in parseUnbracedBody()
2704 --Line->Level; in parseUnbracedBody()
2815 CompoundStatementIndenter Indenter(this, Style, Line->Level); in parseIfThenElse()
2852 CompoundStatementIndenter Indenter(this, Style, Line->Level); in parseIfThenElse()
2874 ++Line->Level; in parseIfThenElse()
2885 --Line->Level; in parseIfThenElse()
2963 CompoundStatementIndenter Indenter(this, Style, Line->Level); in parseTryCatch()
2974 ++Line->Level; in parseTryCatch()
2976 --Line->Level; in parseTryCatch()
3003 Line->MustBeDeclaration = false; in parseTryCatch()
3004 CompoundStatementIndenter Indenter(this, Style, Line->Level); in parseTryCatch()
3058 ++Line->Level; in parseNamespace()
3069 --Line->Level; in parseNamespace()
3123 CompoundStatementIndenter Indenter(this, Style, Line->Level); in parseLoopBody()
3200 ++Line->Level; in parseDoWhile()
3208 unsigned OldLineLevel = Line->Level; in parseLabel()
3209 if (Line->Level > 1 || (!Line->InPPDirective && Line->Level > 0)) in parseLabel()
3210 --Line->Level; in parseLabel()
3212 Line->Level = 0; in parseLabel()
3217 CompoundStatementIndenter Indenter(this, Line->Level, in parseLabel()
3227 ++Line->Level; in parseLabel()
3238 Line->Level = OldLineLevel; in parseLabel()
3268 CompoundStatementIndenter Indenter(this, Style, Line->Level); in parseSwitch()
3275 ++Line->Level; in parseSwitch()
3277 --Line->Level; in parseSwitch()
3775 Line->Level += 1; in parseEnum()
3779 Line->Level -= 1; in parseEnum()
3885 ++Line->Level; in parseJavaEnumBody()
3913 --Line->Level; in parseJavaEnumBody()
4215 if (Line->Tokens.empty()) { in parseJavaScriptEs6ImportExport()
4318 Line->IsContinuation = true; in parseVerilogHierarchyHeader()
4380 auto InitialLevel = Line->Level++; in parseVerilogTable()
4389 Line->Level = InitialLevel; in parseVerilogTable()
4400 auto OrigLevel = Line->Level; in parseVerilogCaseLabel()
4402 if (Line->Level == 0 || (Line->InPPDirective && Line->Level <= 1)) in parseVerilogCaseLabel()
4403 ++Line->Level; in parseVerilogCaseLabel()
4405 --Line->Level; in parseVerilogCaseLabel()
4411 Line->Level = OrigLevel; in parseVerilogCaseLabel()
4414 bool UnwrappedLineParser::containsExpansion(const UnwrappedLine &Line) const { in containsExpansion()
4415 for (const auto &N : Line.Tokens) { in containsExpansion()
4426 if (Line->Tokens.empty()) in addUnwrappedLine()
4431 printDebugInfo(*Line); in addUnwrappedLine()
4440 Line->MatchingOpeningBlockLineIndex != UnwrappedLine::kInvalidIndex && in addUnwrappedLine()
4446 if (!parsingPPDirective() && !InExpansion && containsExpansion(*Line)) { in addUnwrappedLine()
4448 Reconstruct.emplace(Line->Level, Unexpanded); in addUnwrappedLine()
4449 Reconstruct->addLine(*Line); in addUnwrappedLine()
4454 CurrentExpandedLines.push_back(std::move(*Line)); in addUnwrappedLine()
4474 CurrentLines->push_back(std::move(*Line)); in addUnwrappedLine()
4476 Line->Tokens.clear(); in addUnwrappedLine()
4477 Line->MatchingOpeningBlockLineIndex = UnwrappedLine::kInvalidIndex; in addUnwrappedLine()
4478 Line->FirstStartColumn = 0; in addUnwrappedLine()
4479 Line->IsContinuation = false; in addUnwrappedLine()
4480 Line->SeenDecltypeAuto = false; in addUnwrappedLine()
4483 --Line->Level; in addUnwrappedLine()
4497 return (Line->InPPDirective || FormatTok.HasUnescapedNewline) && in isOnNewLine()
4505 const UnwrappedLine &Line, in continuesLineCommentSection() argument
4507 if (Line.Tokens.empty()) in continuesLineCommentSection()
4584 const FormatToken *MinColumnToken = Line.Tokens.front().Tok; in continuesLineCommentSection()
4589 for (const UnwrappedLineNode &Node : Line.Tokens) { in continuesLineCommentSection()
4604 return continuesLineComment(FormatTok, /*Previous=*/Line.Tokens.back().Tok, in continuesLineCommentSection()
4609 bool JustComments = Line->Tokens.empty(); in flushComments()
4620 continuesLineCommentSection(*Tok, *Line, CommentPragmasRegex); in flushComments()
4694 continuesLineCommentSection(*FormatTok, *Line, CommentPragmasRegex); in distributeComments()
4746 while (!Line->InPPDirective && FormatTok->is(tok::hash) && in readToken()
4754 bool SwitchToPreprocessorLines = !Line->Tokens.empty(); in readToken()
4757 static_cast<unsigned>(-LevelDifference) <= Line->Level) && in readToken()
4759 Line->Level += LevelDifference; in readToken()
4765 Line->Level += PPBranchLevel; in readToken()
4775 !Line->InPPDirective) { in readToken()
4782 !Line->InPPDirective) { in readToken()
4788 auto PreCall = std::move(Line); in readToken()
4789 Line.reset(new UnwrappedLine); in readToken()
4795 assert(Line->Tokens.front().Tok == ID); in readToken()
4797 auto UnexpandedLine = std::move(Line); in readToken()
4799 Line = std::move(PreCall); in readToken()
4888 assert(Line->Tokens.empty()); in parseMacroCall()
4896 auto ArgStart = std::prev(Line->Tokens.end()); in parseMacroCall()
4912 pushTokens(std::next(ArgStart), Line->Tokens.end(), Args->back()); in parseMacroCall()
4922 pushTokens(std::next(ArgStart), Line->Tokens.end(), Args->back()); in parseMacroCall()
4924 ArgStart = std::prev(Line->Tokens.end()); in parseMacroCall()
4932 Line->Tokens.resize(1); in parseMacroCall()
4939 Line->Tokens.push_back(UnwrappedLineNode(Tok)); in pushToken()
4941 Line->Tokens.back().Tok->MustBreakBefore = true; in pushToken()
4942 Line->Tokens.back().Tok->MustBreakBeforeFinalized = true; in pushToken()