Lines Matching defs: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();
65 LLVM_ATTRIBUTE_UNUSED static void printDebugInfo(const UnwrappedLine &Line) {
66 printLine(llvm::dbgs(), Line);
71 ScopedDeclarationState(UnwrappedLine &Line, llvm::BitVector &Stack,
73 : Line(Line), Stack(Stack) {
74 Line.MustBeDeclaration = MustBeDeclaration;
80 Line.MustBeDeclaration = Stack.back();
82 Line.MustBeDeclaration = true;
86 UnwrappedLine &Line;
92 std::ostream &operator<<(std::ostream &Stream, const UnwrappedLine &Line) {
94 printLine(OS, Line);
105 else if (!Parser.Line->Tokens.empty())
106 Parser.CurrentLines = &Parser.Line->Tokens.back().Children;
107 PreBlockLine = std::move(Parser.Line);
108 Parser.Line = std::make_unique<UnwrappedLine>();
109 Parser.Line->Level = PreBlockLine->Level;
110 Parser.Line->PPLevel = PreBlockLine->PPLevel;
111 Parser.Line->InPPDirective = PreBlockLine->InPPDirective;
112 Parser.Line->InMacroBody = PreBlockLine->InMacroBody;
113 Parser.Line->UnbracedBodyLevel = PreBlockLine->UnbracedBodyLevel;
117 if (!Parser.Line->Tokens.empty())
119 assert(Parser.Line->Tokens.empty());
120 Parser.Line = std::move(PreBlockLine);
161 : Line(new UnwrappedLine), MustBreakBeforeNextToken(false),
180 Line.reset(new UnwrappedLine);
191 Line->FirstStartColumn = FirstStartColumn;
205 Line->FirstStartColumn = FirstStartColumn;
218 for (auto &Line : Lines)
219 if (Line.InPPDirective && Line.Level > 0)
220 --Line.Level;
232 for (const auto &Line : Lines) {
233 if (!Line.Tokens.empty()) {
234 auto it = ExpandedLines.find(Line.Tokens.begin()->Tok);
243 LLVM_DEBUG(printDebugInfo(Line));
244 Callback.consumeUnwrappedLine(Line);
250 for (const UnwrappedLine &Line : Lines) {
251 LLVM_DEBUG(printDebugInfo(Line));
252 Callback.consumeUnwrappedLine(Line);
272 bool MustBeDeclaration = !Line->InPPDirective && !Style.isJavaScript();
273 ScopedDeclarationState DeclarationState(*Line, DeclarationScopeStack,
415 if (!Style.RemoveBracesLLVM || Line->InPPDirective ||
449 (Style.isJavaScript() && Line->MustBeDeclaration)) {
460 (Line->InPPDirective && Line->Level == 1))) {
461 ++Line->Level;
505 if (!Line->InMacroBody && !Style.isTableGen()) {
613 if (IsCpp && Line->InMacroBody && PrevTok != FormatTok &&
677 hash_combine(h, i.Line);
709 AnnotatedLine Line(ParsedLine);
710 assert(Line.Last == LastToken);
713 Annotator.annotate(Line);
714 Annotator.calculateFormattingInformation(Line);
726 if (const auto *FirstToken = Line.First; FirstToken->is(tok::r_brace)) {
740 assert(!Line.InMacroBody);
741 assert(!Line.InPPDirective);
742 return Line.Level * Style.IndentWidth + Length <= ColumnLimit;
777 ++Line->Level;
782 const unsigned InitialLevel = Line->Level;
791 if (Line->Level > 300)
809 --Line->Level;
811 ScopedDeclarationState DeclarationState(*Line, DeclarationScopeStack,
814 Line->Level += AddLevels;
824 Line->Level = InitialLevel;
893 Line->Level = InitialLevel;
911 Line->MatchingOpeningBlockLineIndex = OpeningLineIndex;
922 static bool isGoogScope(const UnwrappedLine &Line) {
925 if (Line.Tokens.size() < 4)
927 auto I = Line.Tokens.begin();
940 static bool isIIFE(const UnwrappedLine &Line,
946 if (Line.Tokens.size() < 3)
948 auto I = Line.Tokens.begin();
987 (isGoogScope(*Line) || isIIFE(*Line, Keywords)));
989 ScopedDeclarationState DeclarationState(*Line, DeclarationScopeStack,
991 Line->Level += SkipIndent ? 0 : 1;
994 Line->Level -= SkipIndent ? 0 : 1;
1001 ScopedMacroState MacroState(*Line, Tokens, FormatTok);
1046 size_t Line = CurrentLines->size();
1048 Line += Lines.size();
1052 PPStack.push_back({PP_Unreachable, Line});
1054 PPStack.push_back({PP_Conditional, Line});
1110 for (auto &Line : Lines) {
1111 if (Line.Tokens.front().Tok->isNot(tok::comment)) {
1166 for (auto &Line : Lines) {
1167 if (!Line.Tokens.front().Tok->isOneOf(tok::comment, tok::hash)) {
1187 Line->Level += PPBranchLevel + 1;
1189 ++Line->Level;
1191 Line->PPLevel = PPBranchLevel + (IncludeGuard == IG_Defined ? 0 : 1);
1192 assert((int)Line->PPLevel >= 0);
1193 Line->InMacroBody = true;
1213 Line->InPragmaDirective = true;
1221 Line->Level += PPBranchLevel + 1;
1401 bool HasAt = llvm::any_of(Line->Tokens, [](UnwrappedLineNode &LineNode) {
1500 if (Style.isJavaScript() && Line->MustBeDeclaration) {
1511 if (Style.isJavaScript() && Line->MustBeDeclaration) {
1518 if (Style.isJavaScript() && Line->MustBeDeclaration) {
1527 if (Style.isJavaScript() && Line->MustBeDeclaration) {
1537 if (Style.isJavaScript() && Line->MustBeDeclaration) {
1568 if (Style.isJavaScript() && Line->MustBeDeclaration) {
1582 if (Style.isJavaScript() && Line->MustBeDeclaration) {
1695 Tokens->peekNextToken()->is(tok::colon) && !Line->MustBeDeclaration) {
1697 if (!Line->InMacroBody || CurrentLines->size() > 1)
1698 Line->Tokens.begin()->Tok->MustBreakBefore = true;
1851 Line->SeenDecltypeAuto = true;
1915 IsDecltypeAutoFunction = Line->SeenDecltypeAuto;
1921 Line->Tokens.front().Tok->is(Keywords.kw_synchronized)) {
1942 if (Style.isJavaScript() && Line->MustBeDeclaration) {
1954 Line->MustBeDeclaration) {
1968 size_t TokenCount = Line->Tokens.size();
1972 Line->Tokens.front().Tok->isNot(Keywords.kw_async)))) {
2032 auto I = Line->Tokens.begin(), E = Line->Tokens.end();
2081 Line->Tokens.begin()->Tok->is(Keywords.kw_defset)) {
2120 if (Style.isJavaScript() && Line->MustBeDeclaration) {
2225 ++Line->Level;
2228 --Line->Level;
2232 ++Line->Level;
2238 --Line->Level;
2375 NestedLambdas.push_back(Line->SeenDecltypeAuto);
2587 if (!MightBeStmtExpr && !MightBeFoldExpr && !Line->InMacroBody &&
2745 static FormatToken *getLastNonComment(const UnwrappedLine &Line) {
2746 for (const auto &Token : llvm::reverse(Line.Tokens))
2756 if (Style.InsertBraces && !Line->InPPDirective && !Line->Tokens.empty() &&
2759 ? getLastNonComment(*Line)
2760 : Line->Tokens.back().Tok;
2771 ++Line->Level;
2772 ++Line->UnbracedBodyLevel;
2774 --Line->UnbracedBodyLevel;
2777 assert(!Line->InPPDirective);
2792 --Line->Level;
2903 CompoundStatementIndenter Indenter(this, Style, Line->Level);
2940 CompoundStatementIndenter Indenter(this, Style, Line->Level);
2962 ++Line->Level;
2973 --Line->Level;
3056 CompoundStatementIndenter Indenter(this, Style, Line->Level);
3067 ++Line->Level;
3069 --Line->Level;
3096 Line->MustBeDeclaration = false;
3097 CompoundStatementIndenter Indenter(this, Style, Line->Level);
3119 ++Line->Level;
3129 --Line->Level;
3222 CompoundStatementIndenter Indenter(this, Style, Line->Level);
3299 ++Line->Level;
3307 unsigned OldLineLevel = Line->Level;
3310 Line->Level = 0;
3311 else if (Line->Level > 1 || (!Line->InPPDirective && Line->Level > 0))
3312 --Line->Level;
3317 CompoundStatementIndenter Indenter(this, Line->Level,
3327 ++Line->Level;
3338 Line->Level = OldLineLevel;
3374 CompoundStatementIndenter Indenter(this, Style, Line->Level);
3386 ++Line->Level;
3388 --Line->Level;
3886 Line->Level += 1;
3890 Line->Level -= 1;
3996 ++Line->Level;
4024 --Line->Level;
4368 if (Line->Tokens.empty()) {
4472 Line->IsContinuation = true;
4534 auto InitialLevel = Line->Level++;
4543 Line->Level = InitialLevel;
4554 auto OrigLevel = Line->Level;
4556 if (Line->Level == 0 || (Line->InPPDirective && Line->Level <= 1))
4557 ++Line->Level;
4559 --Line->Level;
4565 Line->Level = OrigLevel;
4568 bool UnwrappedLineParser::containsExpansion(const UnwrappedLine &Line) const {
4569 for (const auto &N : Line.Tokens) {
4580 if (Line->Tokens.empty())
4585 printDebugInfo(*Line);
4594 Line->MatchingOpeningBlockLineIndex != UnwrappedLine::kInvalidIndex &&
4600 if (!parsingPPDirective() && !InExpansion && containsExpansion(*Line)) {
4602 Reconstruct.emplace(Line->Level, Unexpanded);
4603 Reconstruct->addLine(*Line);
4608 CurrentExpandedLines.push_back(std::move(*Line));
4628 CurrentLines->push_back(std::move(*Line));
4630 Line->Tokens.clear();
4631 Line->MatchingOpeningBlockLineIndex = UnwrappedLine::kInvalidIndex;
4632 Line->FirstStartColumn = 0;
4633 Line->IsContinuation = false;
4634 Line->SeenDecltypeAuto = false;
4637 --Line->Level;
4651 return (Line->InPPDirective || FormatTok.HasUnescapedNewline) &&
4656 // section on \p Line.
4659 const UnwrappedLine &Line, const FormatStyle &Style,
4661 if (Line.Tokens.empty() || Style.ReflowComments != FormatStyle::RCS_Always)
4672 // If Line starts with a line comment, then FormatTok continues the comment
4681 // If Line starts with a token other than a line comment, then FormatTok
4738 const FormatToken *MinColumnToken = Line.Tokens.front().Tok;
4743 for (const UnwrappedLineNode &Node : Line.Tokens) {
4758 return continuesLineComment(FormatTok, /*Previous=*/Line.Tokens.back().Tok,
4763 bool JustComments = Line->Tokens.empty();
4765 // Line comments that belong to the same line comment section are put on the
4774 continuesLineCommentSection(*Tok, *Line, Style, CommentPragmasRegex);
4847 *FormatTok, *Line, Style, CommentPragmasRegex);
4898 while (!Line->InPPDirective && FormatTok->is(tok::hash) &&
4906 bool SwitchToPreprocessorLines = !Line->Tokens.empty();
4909 static_cast<unsigned>(-LevelDifference) <= Line->Level) &&
4910 "LevelDifference makes Line->Level negative");
4911 Line->Level += LevelDifference;
4917 Line->Level += PPBranchLevel;
4919 assert(Line->Level >= Line->UnbracedBodyLevel);
4920 Line->Level -= Line->UnbracedBodyLevel;
4929 !Line->InPPDirective) {
4936 !Line->InPPDirective) {
4942 auto PreCall = std::move(Line);
4943 Line.reset(new UnwrappedLine);
4949 assert(Line->Tokens.front().Tok == ID);
4951 auto UnexpandedLine = std::move(Line);
4953 Line = std::move(PreCall);
5042 assert(Line->Tokens.empty());
5050 auto ArgStart = std::prev(Line->Tokens.end());
5066 pushTokens(std::next(ArgStart), Line->Tokens.end(), Args->back());
5076 pushTokens(std::next(ArgStart), Line->Tokens.end(), Args->back());
5078 ArgStart = std::prev(Line->Tokens.end());
5086 Line->Tokens.resize(1);
5093 Line->Tokens.push_back(UnwrappedLineNode(Tok));
5095 Line->Tokens.back().Tok->MustBreakBefore = true;
5096 Line->Tokens.back().Tok->MustBreakBeforeFinalized = true;