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