bool AffectedRangeManager::affectsCharSourceRange(
const CharSourceRange &Range) {
- for (SmallVectorImpl<CharSourceRange>::const_iterator I = Ranges.begin(),
- E = Ranges.end();
- I != E; ++I) {
- if (!SourceMgr.isBeforeInTranslationUnit(Range.getEnd(), I->getBegin()) &&
- !SourceMgr.isBeforeInTranslationUnit(I->getEnd(), Range.getBegin()))
+ for (const CharSourceRange &R : Ranges)
+ if (!SourceMgr.isBeforeInTranslationUnit(Range.getEnd(), R.getBegin()) &&
+ !SourceMgr.isBeforeInTranslationUnit(R.getEnd(), Range.getBegin()))
return true;
- }
return false;
}
const CommaSeparatedList::ColumnFormat *
CommaSeparatedList::getColumnFormat(unsigned RemainingCharacters) const {
const ColumnFormat *BestFormat = nullptr;
- for (SmallVector<ColumnFormat, 4>::const_reverse_iterator
- I = Formats.rbegin(),
- E = Formats.rend();
- I != E; ++I) {
- if (I->TotalWidth <= RemainingCharacters || I->Columns == 1) {
- if (BestFormat && I->LineCount > BestFormat->LineCount)
+ for (const ColumnFormat &Format : llvm::reverse(Formats)) {
+ if (Format.TotalWidth <= RemainingCharacters || Format.Columns == 1) {
+ if (BestFormat && Format.LineCount > BestFormat->LineCount)
break;
- BestFormat = &*I;
+ BestFormat = &Format;
}
}
return BestFormat;
LLVM_DEBUG({
llvm::dbgs() << "Replacements for run " << Run << ":\n";
- for (tooling::Replacements::const_iterator I = RunResult.first.begin(),
- E = RunResult.first.end();
- I != E; ++I) {
- llvm::dbgs() << I->toString() << "\n";
- }
+ for (const tooling::Replacement &Replacement : RunResult.first)
+ llvm::dbgs() << Replacement.toString() << "\n";
});
for (unsigned i = 0, e = AnnotatedLines.size(); i != e; ++i) {
delete AnnotatedLines[i];
pushToken(FormatTok);
addUnwrappedLine();
- for (SmallVectorImpl<UnwrappedLine>::iterator I = Lines.begin(),
- E = Lines.end();
- I != E; ++I) {
- Callback.consumeUnwrappedLine(*I);
- }
+ for (const UnwrappedLine &Line : Lines)
+ Callback.consumeUnwrappedLine(Line);
+
Callback.finishRun();
Lines.clear();
while (!PPLevelBranchIndex.empty() &&
void UnwrappedLineParser::flushComments(bool NewlineBeforeNext) {
bool JustComments = Line->Tokens.empty();
- for (SmallVectorImpl<FormatToken *>::const_iterator
- I = CommentsBeforeNextToken.begin(),
- E = CommentsBeforeNextToken.end();
- I != E; ++I) {
+ for (FormatToken *Tok : CommentsBeforeNextToken) {
// Line comments that belong to the same line comment section are put on the
// same line since later we might want to reflow content between them.
// Additional fine-grained breaking of line comment sections is controlled
//
// FIXME: Consider putting separate line comment sections as children to the
// unwrapped line instead.
- (*I)->ContinuesLineCommentSection =
- continuesLineCommentSection(**I, *Line, CommentPragmasRegex);
- if (isOnNewLine(**I) && JustComments && !(*I)->ContinuesLineCommentSection)
+ Tok->ContinuesLineCommentSection =
+ continuesLineCommentSection(*Tok, *Line, CommentPragmasRegex);
+ if (isOnNewLine(*Tok) && JustComments && !Tok->ContinuesLineCommentSection)
addUnwrappedLine();
- pushToken(*I);
+ pushToken(Tok);
}
if (NewlineBeforeNext && JustComments)
addUnwrappedLine();