[lldb/Utility] Fix unspecified behavior.

Order of evaluation of the operands of any C++ operator [...] is
unspecified. This patch fixes the issue in Stream::Indent by calling the
function consecutively.

On my Windows setup, TestSettings.py fails because the function prints
the value first, followed by the indentation.

Expected result:
  MY_FILE=this is a file name with spaces.txt

Actual result:
MY_FILE  =this is a file name with spaces.txt
This commit is contained in:
Jonas Devlieghere 2020-02-24 21:25:55 -08:00
parent 2c0edbf19c
commit 35a0614535

View File

@ -127,8 +127,9 @@ size_t Stream::PrintfVarArg(const char *format, va_list args) {
size_t Stream::EOL() { return PutChar('\n'); }
size_t Stream::Indent(llvm::StringRef str) {
std::string indentation(m_indent_level, ' ');
return PutCString(indentation) + PutCString(str);
const size_t ind_length = PutCString(std::string(m_indent_level, ' '));
const size_t str_length = PutCString(str);
return ind_length + str_length;
}
// Stream a character "ch" out to this stream.