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(&IndentStr[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(&IndentStr[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