From f8fb3729e9d794f174aa737351235f76e6ac46db Mon Sep 17 00:00:00 2001 From: Raphael Isemann Date: Mon, 2 Dec 2019 12:44:55 +0100 Subject: [PATCH] [lldb][NFC] Make Stream's IndentLevel an unsigned integers. We expect it to be always positive values and LLVM/Clang's IndentLevel values are already unsigned integers, so we should do the same. --- lldb/include/lldb/Utility/Stream.h | 12 ++++++------ lldb/source/Target/Target.cpp | 2 +- lldb/source/Utility/Stream.cpp | 10 ++++++---- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/lldb/include/lldb/Utility/Stream.h b/lldb/include/lldb/Utility/Stream.h index 88cdb88..9982d82 100644 --- a/lldb/include/lldb/Utility/Stream.h +++ b/lldb/include/lldb/Utility/Stream.h @@ -338,8 +338,8 @@ public: /// Get the current indentation level. /// /// \return - /// The current indentation level as an integer. - int GetIndentLevel() const; + /// The current indentation level. + unsigned GetIndentLevel() const; /// Indent the current line in the stream. /// @@ -353,10 +353,10 @@ public: size_t Indent(llvm::StringRef s); /// Decrement the current indentation level. - void IndentLess(int amount = 2); + void IndentLess(unsigned amount = 2); /// Increment the current indentation level. - void IndentMore(int amount = 2); + void IndentMore(unsigned amount = 2); /// Output an offset value. /// @@ -411,7 +411,7 @@ public: /// /// \param[in] level /// The new indentation level. - void SetIndentLevel(int level); + void SetIndentLevel(unsigned level); /// Output a SLEB128 number to the stream. /// @@ -442,7 +442,7 @@ protected: uint32_t m_addr_size; ///< Size of an address in bytes. lldb::ByteOrder m_byte_order; ///< Byte order to use when encoding scalar types. - int m_indent_level; ///< Indention level. + unsigned m_indent_level; ///< Indention level. std::size_t m_bytes_written = 0; ///< Number of bytes written so far. void _PutHex8(uint8_t uvalue, bool add_prefix); diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp index 4b9a1b7..aeb77b7 100644 --- a/lldb/source/Target/Target.cpp +++ b/lldb/source/Target/Target.cpp @@ -3177,7 +3177,7 @@ void Target::StopHook::SetThreadSpecifier(ThreadSpec *specifier) { void Target::StopHook::GetDescription(Stream *s, lldb::DescriptionLevel level) const { - int indent_level = s->GetIndentLevel(); + unsigned indent_level = s->GetIndentLevel(); s->SetIndentLevel(indent_level + 2); diff --git a/lldb/source/Utility/Stream.cpp b/lldb/source/Utility/Stream.cpp index 991f7e9..119d1e0 100644 --- a/lldb/source/Utility/Stream.cpp +++ b/lldb/source/Utility/Stream.cpp @@ -185,16 +185,18 @@ Stream &Stream::operator<<(int64_t sval) { } // Get the current indentation level -int Stream::GetIndentLevel() const { return m_indent_level; } +unsigned Stream::GetIndentLevel() const { return m_indent_level; } // Set the current indentation level -void Stream::SetIndentLevel(int indent_level) { m_indent_level = indent_level; } +void Stream::SetIndentLevel(unsigned indent_level) { + m_indent_level = indent_level; +} // Increment the current indentation level -void Stream::IndentMore(int amount) { m_indent_level += amount; } +void Stream::IndentMore(unsigned amount) { m_indent_level += amount; } // Decrement the current indentation level -void Stream::IndentLess(int amount) { +void Stream::IndentLess(unsigned amount) { if (m_indent_level >= amount) m_indent_level -= amount; else -- 2.7.4