[clang] 3704752 - [clang][NFC] Use range-for loop in TextDiagnostic.cpp
Timm Bäder via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 12 09:50:49 PDT 2023
Author: Timm Bäder
Date: 2023-04-12T18:50:37+02:00
New Revision: 37047523a9fb5ffa74eaf94d9d52db831f99c062
URL: https://github.com/llvm/llvm-project/commit/37047523a9fb5ffa74eaf94d9d52db831f99c062
DIFF: https://github.com/llvm/llvm-project/commit/37047523a9fb5ffa74eaf94d9d52db831f99c062.diff
LOG: [clang][NFC] Use range-for loop in TextDiagnostic.cpp
Added:
Modified:
clang/lib/Frontend/TextDiagnostic.cpp
Removed:
################################################################################
diff --git a/clang/lib/Frontend/TextDiagnostic.cpp b/clang/lib/Frontend/TextDiagnostic.cpp
index 809d5309d1af..95b5f257c63d 100644
--- a/clang/lib/Frontend/TextDiagnostic.cpp
+++ b/clang/lib/Frontend/TextDiagnostic.cpp
@@ -1168,11 +1168,10 @@ void TextDiagnostic::emitSnippetAndCaret(
// Find the set of lines to include.
const unsigned MaxLines = DiagOpts->SnippetLineLimit;
std::pair<unsigned, unsigned> Lines = {CaretLineNo, CaretLineNo};
- for (SmallVectorImpl<CharSourceRange>::iterator I = Ranges.begin(),
- E = Ranges.end();
- I != E; ++I)
- if (auto OptionalRange = findLinesForRange(*I, FID, SM))
+ for (auto &I : Ranges) {
+ if (auto OptionalRange = findLinesForRange(I, FID, SM))
Lines = maybeAddRange(Lines, *OptionalRange, MaxLines);
+ }
for (unsigned LineNo = Lines.first; LineNo != Lines.second + 1; ++LineNo) {
const char *BufStart = BufData.data();
@@ -1212,10 +1211,8 @@ void TextDiagnostic::emitSnippetAndCaret(
std::string CaretLine(sourceColMap.columns(), ' ');
// Highlight all of the characters covered by Ranges with ~ characters.
- for (SmallVectorImpl<CharSourceRange>::iterator I = Ranges.begin(),
- E = Ranges.end();
- I != E; ++I)
- highlightRange(*I, LineNo, FID, sourceColMap, CaretLine, SM, LangOpts);
+ for (auto &I : Ranges)
+ highlightRange(I, LineNo, FID, sourceColMap, CaretLine, SM, LangOpts);
// Next, insert the caret itself.
if (CaretLineNo == LineNo) {
More information about the cfe-commits
mailing list