From 35a061453579f623aca1edc7f6f23dd969c21395 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Mon, 24 Feb 2020 21:25:55 -0800 Subject: [PATCH] [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 --- lldb/source/Utility/Stream.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lldb/source/Utility/Stream.cpp b/lldb/source/Utility/Stream.cpp index 8d32b5674502..8c09eadcebd8 100644 --- a/lldb/source/Utility/Stream.cpp +++ b/lldb/source/Utility/Stream.cpp @@ -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.