[PATCH] D151078: [clang][Diagnostics] Use llvm::raw_ostream::indent()
This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rG1c765483fd34: [clang][Diagnostics] Use llvm::raw_ostream::indent() (authored by tbaeder). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D151078/new/ https://reviews.llvm.org/D151078 Files: clang/lib/Frontend/TextDiagnostic.cpp Index: clang/lib/Frontend/TextDiagnostic.cpp === --- clang/lib/Frontend/TextDiagnostic.cpp +++ clang/lib/Frontend/TextDiagnostic.cpp @@ -615,9 +615,6 @@ const unsigned Length = std::min(Str.find('\n'), Str.size()); bool TextNormal = true; - // The string used to indent each line. - SmallString<16> IndentStr; - IndentStr.assign(Indentation, ' '); bool Wrapped = false; for (unsigned WordStart = 0, WordEnd; WordStart < Length; WordStart = WordEnd) { @@ -646,7 +643,7 @@ // This word does not fit on the current line, so wrap to the next // line. OS << '\n'; -OS.write([0], Indentation); +OS.indent(Indentation); applyTemplateHighlighting(OS, Str.substr(WordStart, WordLength), TextNormal, Bold); Column = Indentation + WordLength; @@ -1188,12 +1185,8 @@ ? std::max(4u, getNumDisplayWidth(DisplayLineNo + MaxLines)) : 0; auto indentForLineNumbers = [&] { -if (MaxLineNoDisplayWidth > 0) { - OS << ' '; - for (unsigned I = 0; I != MaxLineNoDisplayWidth; ++I) -OS << ' '; - OS << " | "; -} +if (MaxLineNoDisplayWidth > 0) + OS.indent(MaxLineNoDisplayWidth + 2) << "| "; }; for (unsigned LineNo = Lines.first; LineNo != Lines.second + 1; @@ -1307,11 +1300,8 @@ // Emit line number. if (MaxLineNoDisplayWidth > 0) { unsigned LineNoDisplayWidth = getNumDisplayWidth(LineNo); -OS << ' '; -for (unsigned I = LineNoDisplayWidth; I < MaxLineNoDisplayWidth; ++I) - OS << ' '; -OS << LineNo; -OS << " | "; +OS.indent(MaxLineNoDisplayWidth - LineNoDisplayWidth + 1) +<< LineNo << " | "; } // Print the source line one character at a time. Index: clang/lib/Frontend/TextDiagnostic.cpp === --- clang/lib/Frontend/TextDiagnostic.cpp +++ clang/lib/Frontend/TextDiagnostic.cpp @@ -615,9 +615,6 @@ const unsigned Length = std::min(Str.find('\n'), Str.size()); bool TextNormal = true; - // The string used to indent each line. - SmallString<16> IndentStr; - IndentStr.assign(Indentation, ' '); bool Wrapped = false; for (unsigned WordStart = 0, WordEnd; WordStart < Length; WordStart = WordEnd) { @@ -646,7 +643,7 @@ // This word does not fit on the current line, so wrap to the next // line. OS << '\n'; -OS.write([0], Indentation); +OS.indent(Indentation); applyTemplateHighlighting(OS, Str.substr(WordStart, WordLength), TextNormal, Bold); Column = Indentation + WordLength; @@ -1188,12 +1185,8 @@ ? std::max(4u, getNumDisplayWidth(DisplayLineNo + MaxLines)) : 0; auto indentForLineNumbers = [&] { -if (MaxLineNoDisplayWidth > 0) { - OS << ' '; - for (unsigned I = 0; I != MaxLineNoDisplayWidth; ++I) -OS << ' '; - OS << " | "; -} +if (MaxLineNoDisplayWidth > 0) + OS.indent(MaxLineNoDisplayWidth + 2) << "| "; }; for (unsigned LineNo = Lines.first; LineNo != Lines.second + 1; @@ -1307,11 +1300,8 @@ // Emit line number. if (MaxLineNoDisplayWidth > 0) { unsigned LineNoDisplayWidth = getNumDisplayWidth(LineNo); -OS << ' '; -for (unsigned I = LineNoDisplayWidth; I < MaxLineNoDisplayWidth; ++I) - OS << ' '; -OS << LineNo; -OS << " | "; +OS.indent(MaxLineNoDisplayWidth - LineNoDisplayWidth + 1) +<< LineNo << " | "; } // Print the source line one character at a time. ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D151078: [clang][Diagnostics] Use llvm::raw_ostream::indent()
tbaeder updated this revision to Diff 524271. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D151078/new/ https://reviews.llvm.org/D151078 Files: clang/lib/Frontend/TextDiagnostic.cpp Index: clang/lib/Frontend/TextDiagnostic.cpp === --- clang/lib/Frontend/TextDiagnostic.cpp +++ clang/lib/Frontend/TextDiagnostic.cpp @@ -623,9 +623,6 @@ const unsigned Length = std::min(Str.find('\n'), Str.size()); bool TextNormal = true; - // The string used to indent each line. - SmallString<16> IndentStr; - IndentStr.assign(Indentation, ' '); bool Wrapped = false; for (unsigned WordStart = 0, WordEnd; WordStart < Length; WordStart = WordEnd) { @@ -654,7 +651,7 @@ // This word does not fit on the current line, so wrap to the next // line. OS << '\n'; -OS.write([0], Indentation); +OS.indent(Indentation); applyTemplateHighlighting(OS, Str.substr(WordStart, WordLength), TextNormal, Bold); Column = Indentation + WordLength; @@ -1196,12 +1193,8 @@ ? std::max(4u, getNumDisplayWidth(DisplayLineNo + MaxLines)) : 0; auto indentForLineNumbers = [&] { -if (MaxLineNoDisplayWidth > 0) { - OS << ' '; - for (unsigned I = 0; I != MaxLineNoDisplayWidth; ++I) -OS << ' '; - OS << " | "; -} +if (MaxLineNoDisplayWidth > 0) + OS.indent(MaxLineNoDisplayWidth + 2) << "| "; }; for (unsigned LineNo = Lines.first; LineNo != Lines.second + 1; @@ -1315,11 +1308,8 @@ // Emit line number. if (MaxLineNoDisplayWidth > 0) { unsigned LineNoDisplayWidth = getNumDisplayWidth(LineNo); -OS << ' '; -for (unsigned I = LineNoDisplayWidth; I < MaxLineNoDisplayWidth; ++I) - OS << ' '; -OS << LineNo; -OS << " | "; +OS.indent(MaxLineNoDisplayWidth - LineNoDisplayWidth + 1) +<< LineNo << " | "; } // Print the source line one character at a time. Index: clang/lib/Frontend/TextDiagnostic.cpp === --- clang/lib/Frontend/TextDiagnostic.cpp +++ clang/lib/Frontend/TextDiagnostic.cpp @@ -623,9 +623,6 @@ const unsigned Length = std::min(Str.find('\n'), Str.size()); bool TextNormal = true; - // The string used to indent each line. - SmallString<16> IndentStr; - IndentStr.assign(Indentation, ' '); bool Wrapped = false; for (unsigned WordStart = 0, WordEnd; WordStart < Length; WordStart = WordEnd) { @@ -654,7 +651,7 @@ // This word does not fit on the current line, so wrap to the next // line. OS << '\n'; -OS.write([0], Indentation); +OS.indent(Indentation); applyTemplateHighlighting(OS, Str.substr(WordStart, WordLength), TextNormal, Bold); Column = Indentation + WordLength; @@ -1196,12 +1193,8 @@ ? std::max(4u, getNumDisplayWidth(DisplayLineNo + MaxLines)) : 0; auto indentForLineNumbers = [&] { -if (MaxLineNoDisplayWidth > 0) { - OS << ' '; - for (unsigned I = 0; I != MaxLineNoDisplayWidth; ++I) -OS << ' '; - OS << " | "; -} +if (MaxLineNoDisplayWidth > 0) + OS.indent(MaxLineNoDisplayWidth + 2) << "| "; }; for (unsigned LineNo = Lines.first; LineNo != Lines.second + 1; @@ -1315,11 +1308,8 @@ // Emit line number. if (MaxLineNoDisplayWidth > 0) { unsigned LineNoDisplayWidth = getNumDisplayWidth(LineNo); -OS << ' '; -for (unsigned I = LineNoDisplayWidth; I < MaxLineNoDisplayWidth; ++I) - OS << ' '; -OS << LineNo; -OS << " | "; +OS.indent(MaxLineNoDisplayWidth - LineNoDisplayWidth + 1) +<< LineNo << " | "; } // Print the source line one character at a time. ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D151078: [clang][Diagnostics] Use llvm::raw_ostream::indent()
aaron.ballman accepted this revision. aaron.ballman added a comment. This revision is now accepted and ready to land. LGTM! CHANGES SINCE LAST ACTION https://reviews.llvm.org/D151078/new/ https://reviews.llvm.org/D151078 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D151078: [clang][Diagnostics] Use llvm::raw_ostream::indent()
tbaeder updated this revision to Diff 524253. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D151078/new/ https://reviews.llvm.org/D151078 Files: clang/lib/Frontend/TextDiagnostic.cpp Index: clang/lib/Frontend/TextDiagnostic.cpp === --- clang/lib/Frontend/TextDiagnostic.cpp +++ clang/lib/Frontend/TextDiagnostic.cpp @@ -623,9 +623,6 @@ const unsigned Length = std::min(Str.find('\n'), Str.size()); bool TextNormal = true; - // The string used to indent each line. - SmallString<16> IndentStr; - IndentStr.assign(Indentation, ' '); bool Wrapped = false; for (unsigned WordStart = 0, WordEnd; WordStart < Length; WordStart = WordEnd) { @@ -654,7 +651,7 @@ // This word does not fit on the current line, so wrap to the next // line. OS << '\n'; -OS.write([0], Indentation); +OS.indent(Indentation); applyTemplateHighlighting(OS, Str.substr(WordStart, WordLength), TextNormal, Bold); Column = Indentation + WordLength; @@ -1197,10 +1194,8 @@ : 0; auto indentForLineNumbers = [&] { if (MaxLineNoDisplayWidth > 0) { - OS << ' '; - for (unsigned I = 0; I != MaxLineNoDisplayWidth; ++I) -OS << ' '; - OS << " | "; + OS.indent(MaxLineNoDisplayWidth + 2); + OS << "| "; } }; @@ -1315,9 +1310,7 @@ // Emit line number. if (MaxLineNoDisplayWidth > 0) { unsigned LineNoDisplayWidth = getNumDisplayWidth(LineNo); -OS << ' '; -for (unsigned I = LineNoDisplayWidth; I < MaxLineNoDisplayWidth; ++I) - OS << ' '; +OS.indent(MaxLineNoDisplayWidth - LineNoDisplayWidth + 1); OS << LineNo; OS << " | "; } Index: clang/lib/Frontend/TextDiagnostic.cpp === --- clang/lib/Frontend/TextDiagnostic.cpp +++ clang/lib/Frontend/TextDiagnostic.cpp @@ -623,9 +623,6 @@ const unsigned Length = std::min(Str.find('\n'), Str.size()); bool TextNormal = true; - // The string used to indent each line. - SmallString<16> IndentStr; - IndentStr.assign(Indentation, ' '); bool Wrapped = false; for (unsigned WordStart = 0, WordEnd; WordStart < Length; WordStart = WordEnd) { @@ -654,7 +651,7 @@ // This word does not fit on the current line, so wrap to the next // line. OS << '\n'; -OS.write([0], Indentation); +OS.indent(Indentation); applyTemplateHighlighting(OS, Str.substr(WordStart, WordLength), TextNormal, Bold); Column = Indentation + WordLength; @@ -1197,10 +1194,8 @@ : 0; auto indentForLineNumbers = [&] { if (MaxLineNoDisplayWidth > 0) { - OS << ' '; - for (unsigned I = 0; I != MaxLineNoDisplayWidth; ++I) -OS << ' '; - OS << " | "; + OS.indent(MaxLineNoDisplayWidth + 2); + OS << "| "; } }; @@ -1315,9 +1310,7 @@ // Emit line number. if (MaxLineNoDisplayWidth > 0) { unsigned LineNoDisplayWidth = getNumDisplayWidth(LineNo); -OS << ' '; -for (unsigned I = LineNoDisplayWidth; I < MaxLineNoDisplayWidth; ++I) - OS << ' '; +OS.indent(MaxLineNoDisplayWidth - LineNoDisplayWidth + 1); OS << LineNo; OS << " | "; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D151078: [clang][Diagnostics] Use llvm::raw_ostream::indent()
tbaeder added inline comments. Comment at: clang/lib/Frontend/TextDiagnostic.cpp:1195-1197 auto indentForLineNumbers = [&] { -if (MaxLineNoDisplayWidth > 0) { - OS << ' '; - for (unsigned I = 0; I != MaxLineNoDisplayWidth; ++I) -OS << ' '; - OS << " | "; -} +if (MaxLineNoDisplayWidth > 0) + OS.indent(MaxLineNoDisplayWidth + 4); aaron.ballman wrote: > This drops the output of `|` -- is that intentional? No! Looks like I got a bit too excited about removing code. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D151078/new/ https://reviews.llvm.org/D151078 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D151078: [clang][Diagnostics] Use llvm::raw_ostream::indent()
aaron.ballman added inline comments. Comment at: clang/lib/Frontend/TextDiagnostic.cpp:1195-1197 auto indentForLineNumbers = [&] { -if (MaxLineNoDisplayWidth > 0) { - OS << ' '; - for (unsigned I = 0; I != MaxLineNoDisplayWidth; ++I) -OS << ' '; - OS << " | "; -} +if (MaxLineNoDisplayWidth > 0) + OS.indent(MaxLineNoDisplayWidth + 4); This drops the output of `|` -- is that intentional? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D151078/new/ https://reviews.llvm.org/D151078 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D151078: [clang][Diagnostics] Use llvm::raw_ostream::indent()
tbaeder created this revision. tbaeder added reviewers: aaron.ballman, cjdb. Herald added a project: All. tbaeder requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits. TIL that this exists. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D151078 Files: clang/lib/Frontend/TextDiagnostic.cpp Index: clang/lib/Frontend/TextDiagnostic.cpp === --- clang/lib/Frontend/TextDiagnostic.cpp +++ clang/lib/Frontend/TextDiagnostic.cpp @@ -623,9 +623,6 @@ const unsigned Length = std::min(Str.find('\n'), Str.size()); bool TextNormal = true; - // The string used to indent each line. - SmallString<16> IndentStr; - IndentStr.assign(Indentation, ' '); bool Wrapped = false; for (unsigned WordStart = 0, WordEnd; WordStart < Length; WordStart = WordEnd) { @@ -654,7 +651,7 @@ // This word does not fit on the current line, so wrap to the next // line. OS << '\n'; -OS.write([0], Indentation); +OS.indent(Indentation); applyTemplateHighlighting(OS, Str.substr(WordStart, WordLength), TextNormal, Bold); Column = Indentation + WordLength; @@ -1196,12 +1193,8 @@ ? std::max(4u, getNumDisplayWidth(DisplayLineNo + MaxLines)) : 0; auto indentForLineNumbers = [&] { -if (MaxLineNoDisplayWidth > 0) { - OS << ' '; - for (unsigned I = 0; I != MaxLineNoDisplayWidth; ++I) -OS << ' '; - OS << " | "; -} +if (MaxLineNoDisplayWidth > 0) + OS.indent(MaxLineNoDisplayWidth + 4); }; for (unsigned LineNo = Lines.first; LineNo != Lines.second + 1; @@ -1315,9 +1308,7 @@ // Emit line number. if (MaxLineNoDisplayWidth > 0) { unsigned LineNoDisplayWidth = getNumDisplayWidth(LineNo); -OS << ' '; -for (unsigned I = LineNoDisplayWidth; I < MaxLineNoDisplayWidth; ++I) - OS << ' '; +OS.indent(MaxLineNoDisplayWidth - LineNoDisplayWidth + 1); OS << LineNo; OS << " | "; } Index: clang/lib/Frontend/TextDiagnostic.cpp === --- clang/lib/Frontend/TextDiagnostic.cpp +++ clang/lib/Frontend/TextDiagnostic.cpp @@ -623,9 +623,6 @@ const unsigned Length = std::min(Str.find('\n'), Str.size()); bool TextNormal = true; - // The string used to indent each line. - SmallString<16> IndentStr; - IndentStr.assign(Indentation, ' '); bool Wrapped = false; for (unsigned WordStart = 0, WordEnd; WordStart < Length; WordStart = WordEnd) { @@ -654,7 +651,7 @@ // This word does not fit on the current line, so wrap to the next // line. OS << '\n'; -OS.write([0], Indentation); +OS.indent(Indentation); applyTemplateHighlighting(OS, Str.substr(WordStart, WordLength), TextNormal, Bold); Column = Indentation + WordLength; @@ -1196,12 +1193,8 @@ ? std::max(4u, getNumDisplayWidth(DisplayLineNo + MaxLines)) : 0; auto indentForLineNumbers = [&] { -if (MaxLineNoDisplayWidth > 0) { - OS << ' '; - for (unsigned I = 0; I != MaxLineNoDisplayWidth; ++I) -OS << ' '; - OS << " | "; -} +if (MaxLineNoDisplayWidth > 0) + OS.indent(MaxLineNoDisplayWidth + 4); }; for (unsigned LineNo = Lines.first; LineNo != Lines.second + 1; @@ -1315,9 +1308,7 @@ // Emit line number. if (MaxLineNoDisplayWidth > 0) { unsigned LineNoDisplayWidth = getNumDisplayWidth(LineNo); -OS << ' '; -for (unsigned I = LineNoDisplayWidth; I < MaxLineNoDisplayWidth; ++I) - OS << ' '; +OS.indent(MaxLineNoDisplayWidth - LineNoDisplayWidth + 1); OS << LineNo; OS << " | "; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits