[Lldb-commits] [lldb] f8fb372 - [lldb][NFC] Make Stream's IndentLevel an unsigned integers.
Raphael Isemann via lldb-commits
lldb-commits at lists.llvm.org
Mon Dec 2 04:02:55 PST 2019
Author: Raphael Isemann
Date: 2019-12-02T13:01:26+01:00
New Revision: f8fb3729e9d794f174aa737351235f76e6ac46db
URL: https://github.com/llvm/llvm-project/commit/f8fb3729e9d794f174aa737351235f76e6ac46db
DIFF: https://github.com/llvm/llvm-project/commit/f8fb3729e9d794f174aa737351235f76e6ac46db.diff
LOG: [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.
Added:
Modified:
lldb/include/lldb/Utility/Stream.h
lldb/source/Target/Target.cpp
lldb/source/Utility/Stream.cpp
Removed:
################################################################################
diff --git a/lldb/include/lldb/Utility/Stream.h b/lldb/include/lldb/Utility/Stream.h
index 88cdb88d77ad..9982d8236a65 100644
--- a/lldb/include/lldb/Utility/Stream.h
+++ b/lldb/include/lldb/Utility/Stream.h
@@ -338,8 +338,8 @@ class Stream {
/// 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 @@ class Stream {
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 @@ class Stream {
///
/// \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 @@ class Stream {
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 4b9a1b77ad16..aeb77b7cf676 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 991f7e924d8d..119d1e0f7964 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
More information about the lldb-commits
mailing list