Line->First->NewlinesBefore == 0;
bool IsContinuedComment =
- Line->First->is(tok::comment) && Line->First->Next == nullptr &&
+ Line->First->is(tok::comment) && !Line->First->Next &&
Line->First->NewlinesBefore < 2 && PreviousLine &&
PreviousLine->Affected && PreviousLine->Last->is(tok::comment);
State.NoContinuation = false;
if ((Current.is(TT_ImplicitStringLiteral) &&
- (Previous.Tok.getIdentifierInfo() == nullptr ||
+ (!Previous.Tok.getIdentifierInfo() ||
Previous.Tok.getIdentifierInfo()->getPPKeywordID() ==
tok::pp_not_keyword))) {
unsigned EndColumn =
NewState.BreakBeforeParameter = BreakBeforeParameter;
NewState.HasMultipleNestedBlocks = (Current.BlockParameterCount > 1);
- if (Style.BraceWrapping.BeforeLambdaBody && Current.Next != nullptr &&
+ if (Style.BraceWrapping.BeforeLambdaBody && Current.Next &&
Current.is(tok::l_paren)) {
// Search for any parameter that is a lambda.
FormatToken const *next = Current.Next;
- while (next != nullptr) {
+ while (next) {
if (next->is(TT_LambdaLSquare)) {
NewState.HasMultipleNestedBlocks = true;
break;
Current, StartColumn, Current.OriginalColumn, !Current.Previous,
State.Line->InPPDirective, Encoding, Style, Whitespaces.useCRLF());
} else if (Current.is(TT_LineComment) &&
- (Current.Previous == nullptr ||
+ (!Current.Previous ||
Current.Previous->isNot(TT_ImplicitStringLiteral))) {
bool RegularComments = [&]() {
for (const FormatToken *T = &Current; T && T->is(TT_LineComment);
}
bool containsOnlyComments(const AnnotatedLine &Line) {
- for (FormatToken *Tok = Line.First; Tok != nullptr; Tok = Tok->Next)
+ for (FormatToken *Tok = Line.First; Tok; Tok = Tok->Next)
if (Tok->isNot(tok::comment))
return false;
return true;
unsigned CommaSeparatedList::formatAfterToken(LineState &State,
ContinuationIndenter *Indenter,
bool DryRun) {
- if (State.NextToken == nullptr || !State.NextToken->Previous)
+ if (!State.NextToken || !State.NextToken->Previous)
return 0;
if (Formats.size() == 1)
/// Returns \c true if \p Tok is a keyword or an identifier.
bool isWordLike(const FormatToken &Tok) const {
// getIdentifierinfo returns non-null for keywords as well as identifiers.
- return Tok.Tok.getIdentifierInfo() != nullptr &&
+ return Tok.Tok.getIdentifierInfo() &&
!Tok.isOneOf(kw_verilogHash, kw_verilogHashHash, kw_apostrophe);
}
VerilogExtraKeywords.end();
default:
// getIdentifierInfo returns non-null for both identifiers and keywords.
- return Tok.Tok.getIdentifierInfo() != nullptr;
+ return Tok.Tok.getIdentifierInfo();
}
}
/// invokes @selector(...)). So, we allow treat any identifier or
/// keyword as a potential Objective-C selector component.
static bool canBeObjCSelectorComponent(const FormatToken &Tok) {
- return Tok.Tok.getIdentifierInfo() != nullptr;
+ return Tok.Tok.getIdentifierInfo();
}
/// With `Left` being '(', check if we're at either `[...](` or
Tok->Next->isNot(tok::l_paren)) {
Tok->setType(TT_CSharpGenericTypeConstraint);
parseCSharpGenericTypeConstraint();
- if (Tok->getPreviousNonComment() == nullptr)
+ if (!Tok->getPreviousNonComment())
Line.IsContinuation = true;
}
break;
static unsigned maxNestingDepth(const AnnotatedLine &Line) {
unsigned Result = 0;
- for (const auto *Tok = Line.First; Tok != nullptr; Tok = Tok->Next)
+ for (const auto *Tok = Line.First; Tok; Tok = Tok->Next)
Result = std::max(Result, Tok->NestingLevel);
return Result;
}
calculateUnbreakableTailLengths(Line);
unsigned IndentLevel = Line.Level;
- for (Current = Line.First; Current != nullptr; Current = Current->Next) {
+ for (Current = Line.First; Current; Current = Current->Next) {
if (Current->Role)
Current->Role->precomputeFormattingInfos(Current);
if (Current->MatchingParen &&
auto *CurrentToken = Line.First;
CurrentToken->ArrayInitializerLineStart = true;
unsigned Depth = 0;
- while (CurrentToken != nullptr && CurrentToken != Line.Last) {
+ while (CurrentToken && CurrentToken != Line.Last) {
if (CurrentToken->is(tok::l_brace)) {
CurrentToken->IsArrayInitializer = true;
- if (CurrentToken->Next != nullptr)
+ if (CurrentToken->Next)
CurrentToken->Next->MustBreakBefore = true;
CurrentToken =
calculateInitializerColumnList(Line, CurrentToken->Next, Depth + 1);
FormatToken *TokenAnnotator::calculateInitializerColumnList(
AnnotatedLine &Line, FormatToken *CurrentToken, unsigned Depth) const {
- while (CurrentToken != nullptr && CurrentToken != Line.Last) {
+ while (CurrentToken && CurrentToken != Line.Last) {
if (CurrentToken->is(tok::l_brace))
++Depth;
else if (CurrentToken->is(tok::r_brace))
--Depth;
if (Depth == 2 && CurrentToken->isOneOf(tok::l_brace, tok::comma)) {
CurrentToken = CurrentToken->Next;
- if (CurrentToken == nullptr)
+ if (!CurrentToken)
break;
CurrentToken->StartsColumn = true;
CurrentToken = CurrentToken->Previous;
Newlines = std::min(Newlines, 1u);
}
// Remove empty lines at the start of nested blocks (lambdas/arrow functions)
- if (PreviousLine == nullptr && Line.Level > 0)
+ if (!PreviousLine && Line.Level > 0)
Newlines = std::min(Newlines, 1u);
if (Newlines == 0 && !RootToken.IsFirst)
Newlines = 1;
const FormatToken *FormatTok) {
// FIXME: This returns true for C/C++ keywords like 'struct'.
return FormatTok->is(tok::identifier) &&
- (FormatTok->Tok.getIdentifierInfo() == nullptr ||
+ (!FormatTok->Tok.getIdentifierInfo() ||
!FormatTok->isOneOf(
Keywords.kw_in, Keywords.kw_of, Keywords.kw_as, Keywords.kw_async,
Keywords.kw_await, Keywords.kw_yield, Keywords.kw_finally,
Changes[CellIter->Index].Spaces = (MaxNetWidth - ThisNetWidth);
auto RowCount = 1U;
auto Offset = std::distance(Cells.begin(), CellIter);
- for (const auto *Next = CellIter->NextColumnElement; Next != nullptr;
+ for (const auto *Next = CellIter->NextColumnElement; Next;
Next = Next->NextColumnElement) {
auto *Start = (Cells.begin() + RowCount * CellDescs.CellCounts[0]);
auto *End = Start + Offset;
Changes[CellIter->Index].Spaces += (i > 0) ? 1 : 0;
}
alignToStartOfCell(CellIter->Index, CellIter->EndIndex);
- for (const auto *Next = CellIter->NextColumnElement; Next != nullptr;
+ for (const auto *Next = CellIter->NextColumnElement; Next;
Next = Next->NextColumnElement) {
ThisWidth =
calculateCellWidth(Next->Index, Next->EndIndex, true) + NetWidth;
}
auto RowCount = 1U;
auto Offset = std::distance(Cells.begin(), CellIter);
- for (const auto *Next = CellIter->NextColumnElement; Next != nullptr;
+ for (const auto *Next = CellIter->NextColumnElement; Next;
Next = Next->NextColumnElement) {
if (RowCount > CellDescs.CellCounts.size())
break;
bool WhitespaceManager::isSplitCell(const CellDescription &Cell) {
if (Cell.HasSplit)
return true;
- for (const auto *Next = Cell.NextColumnElement; Next != nullptr;
+ for (const auto *Next = Cell.NextColumnElement; Next;
Next = Next->NextColumnElement) {
if (Next->HasSplit)
return true;
WhitespaceManager::linkCells(CellDescriptions &&CellDesc) {
auto &Cells = CellDesc.Cells;
for (auto *CellIter = Cells.begin(); CellIter != Cells.end(); ++CellIter) {
- if (CellIter->NextColumnElement == nullptr &&
- ((CellIter + 1) != Cells.end())) {
+ if (!CellIter->NextColumnElement && (CellIter + 1) != Cells.end()) {
for (auto *NextIter = CellIter + 1; NextIter != Cells.end(); ++NextIter) {
if (NextIter->Cell == CellIter->Cell) {
CellIter->NextColumnElement = &(*NextIter);
calculateCellWidth(CellIter->Index, CellIter->EndIndex, true);
if (Changes[CellIter->Index].NewlinesBefore == 0)
CellWidth += NetWidth;
- for (const auto *Next = CellIter->NextColumnElement; Next != nullptr;
+ for (const auto *Next = CellIter->NextColumnElement; Next;
Next = Next->NextColumnElement) {
auto ThisWidth = calculateCellWidth(Next->Index, Next->EndIndex, true);
if (Changes[Next->Index].NewlinesBefore == 0)
auto MaxNetWidth = getNetWidth(CellStart, CellStop, InitialSpaces);
auto RowCount = 1U;
auto Offset = std::distance(CellStart, CellStop);
- for (const auto *Next = CellStop->NextColumnElement; Next != nullptr;
+ for (const auto *Next = CellStop->NextColumnElement; Next;
Next = Next->NextColumnElement) {
if (RowCount > MaxRowCount)
break;