26 bool SomeLineAffected =
false;
31 Line->LeadingEmptyLinesAffected = affectsLeadingEmptyLines(*
Line->First);
35 if (
Line->InPPDirective) {
37 const auto *PPEnd = I + 1;
38 while (PPEnd != E && !(*PPEnd)->First->HasUnescapedNewline) {
39 Last = (*PPEnd)->Last;
43 if (affectsTokenRange(*
Line->First, *
Last,
45 SomeLineAffected =
true;
46 markAllAsAffected(I, PPEnd);
52 if (nonPPLineAffected(
Line, PreviousLine, Lines))
53 SomeLineAffected =
true;
58 return SomeLineAffected;
64 if (!SourceMgr.isBeforeInTranslationUnit(Range.getEnd(), R.getBegin()) &&
65 !SourceMgr.isBeforeInTranslationUnit(R.getEnd(), Range.getBegin())) {
74 bool IncludeLeadingNewlines) {
76 if (!IncludeLeadingNewlines)
84bool AffectedRangeManager::affectsLeadingEmptyLines(
const FormatToken &
Tok) {
86 Tok.WhitespaceRange.getBegin(),
87 Tok.WhitespaceRange.getBegin().getLocWithOffset(
Tok.LastNewlineOffset));
91void AffectedRangeManager::markAllAsAffected(
95 (*I)->Affected =
true;
96 markAllAsAffected((*I)->Children.begin(), (*I)->Children.end());
101bool AffectedRangeManager::nonPPLineAffected(
104 bool SomeLineAffected =
false;
106 if (
Line->ChildrenAffected)
107 SomeLineAffected =
true;
110 bool SomeTokenAffected =
false;
113 bool IncludeLeadingNewlines =
false;
117 bool SomeFirstChildAffected =
false;
122 if (affectsTokenRange(*
Tok, *
Tok, IncludeLeadingNewlines))
123 SomeTokenAffected =
true;
126 if (!
Tok->Children.empty() &&
Tok->Children.front()->Affected)
127 SomeFirstChildAffected =
true;
129 IncludeLeadingNewlines =
Tok->Children.empty();
134 bool LineMoved = PreviousLine && PreviousLine->Affected &&
135 Line->First->NewlinesBefore == 0;
137 bool IsContinuedComment =
138 Line->First->is(tok::comment) && !
Line->First->Next &&
139 Line->First->NewlinesBefore < 2 && PreviousLine &&
140 PreviousLine->Affected && PreviousLine->Last->is(tok::comment);
142 bool IsAffectedClosingBrace =
143 Line->First->is(tok::r_brace) &&
145 Lines[
Line->MatchingOpeningBlockLineIndex]->Affected;
147 if (SomeTokenAffected || SomeFirstChildAffected || LineMoved ||
148 IsContinuedComment || IsAffectedClosingBrace) {
149 Line->Affected =
true;
150 SomeLineAffected =
true;
152 return SomeLineAffected;
AffectedRangeManager class manages affected ranges in the code.
This file implements a token annotator, i.e.
Represents a character-granular source range.
static CharSourceRange getCharRange(SourceRange R)
Encodes a location in the source.
SourceLocation getLocWithOffset(IntTy Offset) const
Return a source location with the specified offset from this SourceLocation.
The JSON file list parser is used to communicate input to InstallAPI.