[Lldb-commits] [lldb] r280139 - A few minor stylistic cleanups in StringExtractor.

Zachary Turner via lldb-commits lldb-commits at lists.llvm.org
Tue Aug 30 12:47:05 PDT 2016


Author: zturner
Date: Tue Aug 30 14:47:05 2016
New Revision: 280139

URL: http://llvm.org/viewvc/llvm-project?rev=280139&view=rev
Log:
A few minor stylistic cleanups in StringExtractor.

Makes Peek() return a StringRef instead of a const char*.

This leads to a few callers of Peek() being able to be made a
little nicer (for example using StringRef member functions instead
of c-style strncmp and related functions) and generally safer
usage.

Modified:
    lldb/trunk/include/lldb/Core/ArchSpec.h
    lldb/trunk/include/lldb/Interpreter/Args.h
    lldb/trunk/include/lldb/Utility/StringExtractor.h
    lldb/trunk/source/Core/ArchSpec.cpp
    lldb/trunk/source/Interpreter/Args.cpp
    lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
    lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
    lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
    lldb/trunk/source/Utility/StringExtractor.cpp
    lldb/trunk/unittests/Utility/StringExtractorTest.cpp

Modified: lldb/trunk/include/lldb/Core/ArchSpec.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ArchSpec.h?rev=280139&r1=280138&r2=280139&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ArchSpec.h (original)
+++ lldb/trunk/include/lldb/Core/ArchSpec.h Tue Aug 30 14:47:05 2016
@@ -265,8 +265,9 @@ public:
     ArchSpec (const llvm::Triple &triple);
     explicit 
     ArchSpec (const char *triple_cstr);
-    explicit 
-    ArchSpec (const char *triple_cstr, Platform *platform);
+    explicit ArchSpec(llvm::StringRef triple_str);
+    explicit ArchSpec(const char *triple_cstr, Platform *platform);
+    ArchSpec(llvm::StringRef triple_str, Platform *platform);
     //------------------------------------------------------------------
     /// Constructor over architecture name.
     ///

Modified: lldb/trunk/include/lldb/Interpreter/Args.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/Args.h?rev=280139&r1=280138&r2=280139&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Interpreter/Args.h (original)
+++ lldb/trunk/include/lldb/Interpreter/Args.h Tue Aug 30 14:47:05 2016
@@ -202,7 +202,10 @@ public:
     ///     The NULL terminated C string of the copy of \a arg_cstr.
     //------------------------------------------------------------------
     const char *
-    AppendArgument (const char *arg_cstr, char quote_char = '\0');
+    AppendArgument(llvm::StringRef arg_str, char quote_char = '\0');
+
+    const char *
+    AppendArgument(const char *arg_cstr, char quote_char = '\0');
 
     void
     AppendArguments (const Args &rhs);
@@ -227,6 +230,8 @@ public:
     //------------------------------------------------------------------
     const char *
     InsertArgumentAtIndex (size_t idx, const char *arg_cstr, char quote_char = '\0');
+    const char *
+    InsertArgumentAtIndex(size_t idx, llvm::StringRef arg_str, char quote_char = '\0');
 
     //------------------------------------------------------------------
     /// Replaces the argument value at index \a idx to \a arg_cstr

Modified: lldb/trunk/include/lldb/Utility/StringExtractor.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/StringExtractor.h?rev=280139&r1=280138&r2=280139&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Utility/StringExtractor.h (original)
+++ lldb/trunk/include/lldb/Utility/StringExtractor.h Tue Aug 30 14:47:05 2016
@@ -112,10 +112,10 @@ public:
     char
     PeekChar (char fail_value = '\0')
     {
-        const char *cstr = Peek();
-        if (cstr)
-            return cstr[0];
-        return fail_value;
+        llvm::StringRef str = Peek();
+        if (str.empty())
+            return fail_value;
+        return str[0];
     }
 
     int
@@ -154,9 +154,6 @@ public:
     size_t
     GetHexBytesAvail (llvm::MutableArrayRef<uint8_t> dest);
 
-    uint64_t
-    GetHexWithFixedSize (uint32_t byte_size, bool little_endian, uint64_t fail_value);
-
     size_t
     GetHexByteString (std::string &str);
 
@@ -166,13 +163,13 @@ public:
     size_t
     GetHexByteStringTerminatedBy (std::string &str,
                                   char terminator);
-    
-    const char *
-    Peek ()
+
+    llvm::StringRef
+    Peek() const
     {
-        if (m_index < m_packet.size())
-            return m_packet.c_str() + m_index;
-        return nullptr;
+        if (!IsGood())
+            return llvm::StringRef();
+        return llvm::StringRef(m_packet).drop_front(m_index);
     }
 
 protected:

Modified: lldb/trunk/source/Core/ArchSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ArchSpec.cpp?rev=280139&r1=280138&r2=280139&view=diff
==============================================================================
--- lldb/trunk/source/Core/ArchSpec.cpp (original)
+++ lldb/trunk/source/Core/ArchSpec.cpp Tue Aug 30 14:47:05 2016
@@ -434,6 +434,12 @@ ArchSpec::ArchSpec (const char *triple_c
         SetTriple(triple_cstr, platform);
 }
 
+ArchSpec::ArchSpec(llvm::StringRef triple_str, Platform *platform)
+    : m_triple(), m_core(kCore_invalid), m_byte_order(eByteOrderInvalid), m_flags(0), m_distribution_id()
+{
+    if (!triple_str.empty())
+        SetTriple(triple_str.str().c_str(), platform);
+}
 
 ArchSpec::ArchSpec (const char *triple_cstr) :
     m_triple (),
@@ -446,6 +452,13 @@ ArchSpec::ArchSpec (const char *triple_c
         SetTriple(triple_cstr);
 }
 
+ArchSpec::ArchSpec(llvm::StringRef triple_str)
+    : m_triple(), m_core(kCore_invalid), m_byte_order(eByteOrderInvalid), m_flags(0), m_distribution_id()
+{
+    if (!triple_str.empty())
+        SetTriple(triple_str.str().c_str());
+}
+
 ArchSpec::ArchSpec(const llvm::Triple &triple) :
     m_triple (),
     m_core (kCore_invalid),

Modified: lldb/trunk/source/Interpreter/Args.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/Args.cpp?rev=280139&r1=280138&r2=280139&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/Args.cpp (original)
+++ lldb/trunk/source/Interpreter/Args.cpp Tue Aug 30 14:47:05 2016
@@ -430,13 +430,19 @@ Args::AppendArguments (const char **argv
 }
 
 const char *
-Args::AppendArgument (const char *arg_cstr, char quote_char)
+Args::AppendArgument(llvm::StringRef arg_str, char quote_char)
+{
+    return InsertArgumentAtIndex(GetArgumentCount(), arg_str, quote_char);
+}
+
+const char *
+Args::AppendArgument(const char *arg_cstr, char quote_char)
 {
     return InsertArgumentAtIndex (GetArgumentCount(), arg_cstr, quote_char);
 }
 
 const char *
-Args::InsertArgumentAtIndex (size_t idx, const char *arg_cstr, char quote_char)
+Args::InsertArgumentAtIndex(size_t idx, llvm::StringRef arg_str, char quote_char)
 {
     // Since we are using a std::list to hold onto the copied C string and
     // we don't have direct access to the elements, we have to iterate to
@@ -446,8 +452,8 @@ Args::InsertArgumentAtIndex (size_t idx,
     for (pos = m_args.begin(); i > 0 && pos != end; ++pos)
         --i;
 
-    pos = m_args.insert(pos, arg_cstr);
-    
+    pos = m_args.insert(pos, std::string(arg_str.data(), arg_str.size()));
+
     if (idx >= m_args_quote_char.size())
     {
         m_args_quote_char.resize(idx + 1);
@@ -455,13 +461,19 @@ Args::InsertArgumentAtIndex (size_t idx,
     }
     else
         m_args_quote_char.insert(m_args_quote_char.begin() + idx, quote_char);
-    
+
     UpdateArgvFromArgs();
     return GetArgumentAtIndex(idx);
 }
 
 const char *
-Args::ReplaceArgumentAtIndex (size_t idx, const char *arg_cstr, char quote_char)
+Args::InsertArgumentAtIndex(size_t idx, const char *arg_cstr, char quote_char)
+{
+    return InsertArgumentAtIndex(idx, llvm::StringRef(arg_cstr), quote_char);
+}
+
+const char *
+Args::ReplaceArgumentAtIndex(size_t idx, const char *arg_cstr, char quote_char)
 {
     // Since we are using a std::list to hold onto the copied C string and
     // we don't have direct access to the elements, we have to iterate to

Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp?rev=280139&r1=280138&r2=280139&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp Tue Aug 30 14:47:05 2016
@@ -3240,7 +3240,7 @@ GDBRemoteCommunicationClient::ReadFile (
         uint32_t retcode = response.GetHexMaxU32(false, UINT32_MAX);
         if (retcode == UINT32_MAX)
             return retcode;
-        const char next = (response.Peek() ? *response.Peek() : 0);
+        const char next = (response.GetBytesLeft() ? response.PeekChar() : 0);
         if (next == ',')
             return 0;
         if (next == ';')
@@ -3428,7 +3428,7 @@ GDBRemoteCommunicationClient::CalculateM
             return false;
         if (response.GetChar() != ',')
             return false;
-        if (response.Peek() && *response.Peek() == 'x')
+        if (response.GetBytesLeft() && response.PeekChar() == 'x')
             return false;
         low = response.GetHexMaxU64(false, UINT64_MAX);
         high = response.GetHexMaxU64(false, UINT64_MAX);

Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp?rev=280139&r1=280138&r2=280139&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp Tue Aug 30 14:47:05 2016
@@ -966,7 +966,7 @@ GDBRemoteCommunicationServerCommon::Hand
     {
         std::string str;
         packet.GetHexByteString(str);
-        m_process_launch_info.GetEnvironmentEntries().AppendArgument(str.c_str());
+        m_process_launch_info.GetEnvironmentEntries().AppendArgument(str);
         return SendOKResponse();
     }
     return SendErrorResponse(12);
@@ -979,8 +979,7 @@ GDBRemoteCommunicationServerCommon::Hand
     const uint32_t bytes_left = packet.GetBytesLeft();
     if (bytes_left > 0)
     {
-        const char* arch_triple = packet.Peek();
-        ArchSpec arch_spec(arch_triple,NULL);
+        ArchSpec arch_spec(packet.Peek(), nullptr);
         m_process_launch_info.SetArchitecture(arch_spec);
         return SendOKResponse();
     }

Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp?rev=280139&r1=280138&r2=280139&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp Tue Aug 30 14:47:05 2016
@@ -1186,7 +1186,7 @@ GDBRemoteCommunicationServerLLGS::Handle
     if (packet.GetBytesLeft () > 0)
     {
         // FIXME add continue at address support for $C{signo}[;{continue-address}].
-        if (*packet.Peek () == ';')
+        if (packet.PeekChar() == ';')
             return SendUnimplementedResponse (packet.GetStringRef().c_str());
         else
             return SendIllFormedResponse (packet, "unexpected content after $C{signal-number}");
@@ -1318,13 +1318,13 @@ GDBRemoteCommunicationServerLLGS::Handle
     }
 
     // Check if this is all continue (no options or ";c").
-    if (::strcmp (packet.Peek (), ";c") == 0)
+    if (packet.Peek() == ";c")
     {
         // Move past the ';', then do a simple 'c'.
         packet.SetFilePos (packet.GetFilePos () + 1);
         return Handle_c (packet);
     }
-    else if (::strcmp (packet.Peek (), ";s") == 0)
+    else if (packet.Peek() == ";s")
     {
         // Move past the ';', then do a simple 's'.
         packet.SetFilePos (packet.GetFilePos () + 1);
@@ -1341,7 +1341,7 @@ GDBRemoteCommunicationServerLLGS::Handle
 
     ResumeActionList thread_actions;
 
-    while (packet.GetBytesLeft () && *packet.Peek () == ';')
+    while (packet.GetBytesLeft() && packet.PeekChar() == ';')
     {
         // Skip the semi-colon.
         packet.GetChar ();
@@ -1383,7 +1383,7 @@ GDBRemoteCommunicationServerLLGS::Handle
         }
 
         // Parse out optional :{thread-id} value.
-        if (packet.GetBytesLeft () && (*packet.Peek () == ':'))
+        if (packet.GetBytesLeft() && packet.PeekChar() == ':')
         {
             // Consume the separator.
             packet.GetChar ();
@@ -2926,7 +2926,7 @@ GDBRemoteCommunicationServerLLGS::GetThr
         return thread_sp;
 
     // Parse out thread: portion.
-    if (strncmp (packet.Peek (), "thread:", strlen("thread:")) != 0)
+    if (packet.Peek().startswith("thread:"))
     {
         if (log)
             log->Printf ("GDBRemoteCommunicationServerLLGS::%s gdb-remote parse error: expected 'thread:' but not found, packet contents = '%s'", __FUNCTION__, packet.GetStringRef ().c_str ());

Modified: lldb/trunk/source/Utility/StringExtractor.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/StringExtractor.cpp?rev=280139&r1=280138&r2=280139&view=diff
==============================================================================
--- lldb/trunk/source/Utility/StringExtractor.cpp (original)
+++ lldb/trunk/source/Utility/StringExtractor.cpp Tue Aug 30 14:47:05 2016
@@ -16,6 +16,7 @@
 #include <tuple>
 // Other libraries and framework includes
 // Project includes
+#include "llvm/ADT/Optional.h"
 #include "llvm/Support/Endian.h"
 
 static inline int
@@ -99,6 +100,16 @@ StringExtractor::GetChar (char fail_valu
     return fail_value;
 }
 
+static llvm::Optional<uint8_t>
+translateHexChar(char ch1, char ch2)
+{
+    const int hi_nibble = xdigit_to_sint(ch1);
+    const int lo_nibble = xdigit_to_sint(ch2);
+    if (hi_nibble == -1 || lo_nibble == -1)
+        return llvm::None;
+    return (uint8_t)((hi_nibble << 4) + lo_nibble);
+}
+
 //----------------------------------------------------------------------
 // If a pair of valid hex digits exist at the head of the
 // StringExtractor they are decoded into an unsigned byte and returned
@@ -112,17 +123,12 @@ StringExtractor::DecodeHexU8()
 {
     SkipSpaces();
     if (GetBytesLeft() < 2)
-    {
         return -1;
-    }
-    const int hi_nibble = xdigit_to_sint(m_packet[m_index]);
-    const int lo_nibble = xdigit_to_sint(m_packet[m_index+1]);
-    if (hi_nibble == -1 || lo_nibble == -1)
-    {
+    auto result = translateHexChar(m_packet[m_index], m_packet[m_index + 1]);
+    if (!result.hasValue())
         return -1;
-    }
     m_index += 2;
-    return (uint8_t)((hi_nibble << 4) + lo_nibble);
+    return *result;
 }
 
 //----------------------------------------------------------------------
@@ -242,8 +248,8 @@ StringExtractor::GetHexMaxU32 (bool litt
     // of a uint32 were missing from the input.  We're essentially padding left
     // with 0's.
     uint8_t bytes[2 * sizeof(uint32_t) - 1] = {0};
-    auto byte_array = llvm::MutableArrayRef<uint8_t>(bytes);
-    auto decode_loc = byte_array.drop_front(sizeof(uint32_t) - 1);
+    llvm::MutableArrayRef<uint8_t> byte_array(bytes);
+    llvm::MutableArrayRef<uint8_t> decode_loc = byte_array.take_back(sizeof(uint32_t));
     uint32_t bytes_decoded = GetHexBytesAvail(decode_loc);
     if (bytes_decoded == sizeof(uint32_t) && ::isxdigit(PeekChar()))
         return fail();
@@ -263,15 +269,15 @@ StringExtractor::GetHexMaxU64 (bool litt
 {
     SkipSpaces();
 
-    // Allocate enough space for 2 uint32's.  In big endian, if the user writes
-    // "AB" then this should be treated as 0xAB, not 0xAB000000.  In order to
-    // do this, we decode into the second half of the array, and then shift the
-    // starting point of the big endian translation left by however many bytes
+    // Allocate enough space for 2 uint64's.  In big endian, if the user writes
+    // "AB" then this should be treated as 0x000000AB, not 0xAB000000.  In order
+    // to do this, we decode into the second half of the array, and then shift
+    // the starting point of the big endian translation left by however many bytes
     // of a uint32 were missing from the input.  We're essentially padding left
     // with 0's.
     uint8_t bytes[2 * sizeof(uint64_t) - 1] = {0};
-    auto byte_array = llvm::MutableArrayRef<uint8_t>(bytes);
-    auto decode_loc = byte_array.drop_front(sizeof(uint64_t) - 1);
+    llvm::MutableArrayRef<uint8_t> byte_array(bytes);
+    llvm::MutableArrayRef<uint8_t> decode_loc = byte_array.take_back(sizeof(uint64_t));
     uint32_t bytes_decoded = GetHexBytesAvail(decode_loc);
     if (bytes_decoded == sizeof(uint64_t) && ::isxdigit(PeekChar()))
         return fail();
@@ -327,41 +333,6 @@ StringExtractor::GetHexBytesAvail (llvm:
     return bytes_extracted;
 }
 
-// Consume ASCII hex nibble character pairs until we have decoded byte_size
-// bytes of data.
-
-uint64_t
-StringExtractor::GetHexWithFixedSize (uint32_t byte_size, bool little_endian, uint64_t fail_value)
-{
-    if (byte_size <= 8 && GetBytesLeft() >= byte_size * 2)
-    {
-        uint64_t result = 0;
-        uint32_t i;
-        if (little_endian)
-        {
-            // Little Endian
-            uint32_t shift_amount;
-            for (i = 0, shift_amount = 0;
-                 i < byte_size && IsGood();
-                 ++i, shift_amount += 8)
-            {
-                result |= ((uint64_t)GetHexU8() << shift_amount);
-            }
-        }
-        else
-        {
-            // Big Endian
-            for (i = 0; i < byte_size && IsGood(); ++i)
-            {
-                result <<= 8;
-                result |= GetHexU8();
-            }
-        }
-    }
-    m_index = UINT64_MAX;
-    return fail_value;
-}
-
 size_t
 StringExtractor::GetHexByteString (std::string &str)
 {
@@ -377,11 +348,16 @@ size_t
 StringExtractor::GetHexByteStringFixedLength (std::string &str, uint32_t nibble_length)
 {
     str.clear();
-
-    uint32_t nibble_count = 0;
-    for (const char *pch = Peek(); (nibble_count < nibble_length) && (pch != nullptr); str.append(1, GetHexU8(0, false)), pch = Peek (), nibble_count += 2)
-    {}
-
+    llvm::StringRef nibs = Peek().take_front(nibble_length);
+    while (nibs.size() >= 2)
+    {
+        auto ch = translateHexChar(nibs[0], nibs[1]);
+        if (!ch.hasValue())
+            break;
+        str.push_back(*ch);
+        nibs = nibs.drop_front(2);
+    }
+    m_index += str.size() * 2;
     return str.size();
 }
 
@@ -393,7 +369,7 @@ StringExtractor::GetHexByteStringTermina
     char ch;
     while ((ch = GetHexU8(0,false)) != '\0')
         str.append(1, ch);
-    if (Peek() && *Peek() == terminator)
+    if (GetBytesLeft() > 0 && PeekChar() == terminator)
         return str.size();
 
     str.clear();

Modified: lldb/trunk/unittests/Utility/StringExtractorTest.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Utility/StringExtractorTest.cpp?rev=280139&r1=280138&r2=280139&view=diff
==============================================================================
--- lldb/trunk/unittests/Utility/StringExtractorTest.cpp (original)
+++ lldb/trunk/unittests/Utility/StringExtractorTest.cpp Tue Aug 30 14:47:05 2016
@@ -20,7 +20,6 @@ TEST_F (StringExtractorTest, InitEmpty)
     ASSERT_STREQ (kEmptyString, ex.GetStringRef().c_str());
     ASSERT_EQ (true, ex.Empty());
     ASSERT_EQ (0u, ex.GetBytesLeft());
-    ASSERT_EQ (nullptr, ex.Peek());
 }
 
 TEST_F (StringExtractorTest, InitMisc)
@@ -33,7 +32,7 @@ TEST_F (StringExtractorTest, InitMisc)
     ASSERT_STREQ (kInitMiscString, ex.GetStringRef().c_str());
     ASSERT_EQ (false, ex.Empty());
     ASSERT_EQ (sizeof(kInitMiscString)-1, ex.GetBytesLeft());
-    ASSERT_EQ (kInitMiscString[0], *ex.Peek());
+    ASSERT_EQ(kInitMiscString[0], ex.PeekChar());
 }
 
 TEST_F (StringExtractorTest, DecodeHexU8_Underflow)
@@ -46,7 +45,6 @@ TEST_F (StringExtractorTest, DecodeHexU8
     ASSERT_EQ (0u, ex.GetFilePos());
     ASSERT_EQ (true, ex.Empty());
     ASSERT_EQ (0u, ex.GetBytesLeft());
-    ASSERT_EQ (nullptr, ex.Peek());
 }
 
 TEST_F (StringExtractorTest, DecodeHexU8_Underflow2)
@@ -58,7 +56,7 @@ TEST_F (StringExtractorTest, DecodeHexU8
     ASSERT_EQ (true, ex.IsGood());
     ASSERT_EQ (0u, ex.GetFilePos());
     ASSERT_EQ (1u, ex.GetBytesLeft());
-    ASSERT_EQ ('1', *ex.Peek());
+    ASSERT_EQ('1', ex.PeekChar());
 }
 
 TEST_F (StringExtractorTest, DecodeHexU8_InvalidHex)
@@ -70,7 +68,7 @@ TEST_F (StringExtractorTest, DecodeHexU8
     ASSERT_EQ (true, ex.IsGood());
     ASSERT_EQ (0u, ex.GetFilePos());
     ASSERT_EQ (2u, ex.GetBytesLeft());
-    ASSERT_EQ ('x', *ex.Peek());
+    ASSERT_EQ('x', ex.PeekChar());
 }
 
 TEST_F (StringExtractorTest, DecodeHexU8_InvalidHex2)
@@ -82,7 +80,7 @@ TEST_F (StringExtractorTest, DecodeHexU8
     ASSERT_EQ (true, ex.IsGood());
     ASSERT_EQ (0u, ex.GetFilePos());
     ASSERT_EQ (2u, ex.GetBytesLeft());
-    ASSERT_EQ ('a', *ex.Peek());
+    ASSERT_EQ('a', ex.PeekChar());
 }
 
 TEST_F (StringExtractorTest, DecodeHexU8_Exact)
@@ -94,7 +92,6 @@ TEST_F (StringExtractorTest, DecodeHexU8
     ASSERT_EQ (true, ex.IsGood());
     ASSERT_EQ (2u, ex.GetFilePos());
     ASSERT_EQ (0u, ex.GetBytesLeft());
-    ASSERT_EQ (nullptr, ex.Peek());
 }
 
 TEST_F (StringExtractorTest, DecodeHexU8_Extra)
@@ -106,7 +103,7 @@ TEST_F (StringExtractorTest, DecodeHexU8
     ASSERT_EQ (true, ex.IsGood());
     ASSERT_EQ (2u, ex.GetFilePos());
     ASSERT_EQ (2u, ex.GetBytesLeft());
-    ASSERT_EQ ('3', *ex.Peek());
+    ASSERT_EQ('3', ex.PeekChar());
 }
 
 TEST_F (StringExtractorTest, GetHexU8_Underflow)
@@ -119,7 +116,6 @@ TEST_F (StringExtractorTest, GetHexU8_Un
     ASSERT_EQ (UINT64_MAX, ex.GetFilePos());
     ASSERT_EQ (true, ex.Empty());
     ASSERT_EQ (0u, ex.GetBytesLeft());
-    ASSERT_EQ (nullptr, ex.Peek());
 }
 
 TEST_F (StringExtractorTest, GetHexU8_Underflow2)
@@ -131,7 +127,6 @@ TEST_F (StringExtractorTest, GetHexU8_Un
     ASSERT_EQ (false, ex.IsGood());
     ASSERT_EQ (UINT64_MAX, ex.GetFilePos());
     ASSERT_EQ (0u, ex.GetBytesLeft());
-    ASSERT_EQ (nullptr, ex.Peek());
 }
 
 TEST_F (StringExtractorTest, GetHexU8_InvalidHex)
@@ -143,7 +138,6 @@ TEST_F (StringExtractorTest, GetHexU8_In
     ASSERT_EQ (false, ex.IsGood());
     ASSERT_EQ (UINT64_MAX, ex.GetFilePos());
     ASSERT_EQ (0u, ex.GetBytesLeft());
-    ASSERT_EQ (nullptr, ex.Peek());
 }
 
 TEST_F (StringExtractorTest, GetHexU8_Exact)
@@ -155,7 +149,6 @@ TEST_F (StringExtractorTest, GetHexU8_Ex
     ASSERT_EQ (true, ex.IsGood());
     ASSERT_EQ (2u, ex.GetFilePos());
     ASSERT_EQ (0u, ex.GetBytesLeft());
-    ASSERT_EQ (nullptr, ex.Peek());
 }
 
 TEST_F (StringExtractorTest, GetHexU8_Extra)
@@ -167,7 +160,7 @@ TEST_F (StringExtractorTest, GetHexU8_Ex
     ASSERT_EQ (true, ex.IsGood());
     ASSERT_EQ (2u, ex.GetFilePos());
     ASSERT_EQ (2u, ex.GetBytesLeft());
-    ASSERT_EQ ('3', *ex.Peek());
+    ASSERT_EQ('3', ex.PeekChar());
 }
 
 TEST_F (StringExtractorTest, GetHexU8_Underflow_NoEof)
@@ -181,7 +174,6 @@ TEST_F (StringExtractorTest, GetHexU8_Un
     ASSERT_EQ (UINT64_MAX, ex.GetFilePos());
     ASSERT_EQ (true, ex.Empty());
     ASSERT_EQ (0u, ex.GetBytesLeft());
-    ASSERT_EQ (nullptr, ex.Peek());
 }
 
 TEST_F (StringExtractorTest, GetHexU8_Underflow2_NoEof)
@@ -194,7 +186,7 @@ TEST_F (StringExtractorTest, GetHexU8_Un
     ASSERT_EQ (true, ex.IsGood());
     ASSERT_EQ (0u, ex.GetFilePos());
     ASSERT_EQ (1u, ex.GetBytesLeft());
-    ASSERT_EQ ('1', *ex.Peek());
+    ASSERT_EQ('1', ex.PeekChar());
 }
 
 TEST_F (StringExtractorTest, GetHexU8_InvalidHex_NoEof)
@@ -207,7 +199,7 @@ TEST_F (StringExtractorTest, GetHexU8_In
     ASSERT_EQ (true, ex.IsGood());
     ASSERT_EQ (0u, ex.GetFilePos());
     ASSERT_EQ (2u, ex.GetBytesLeft());
-    ASSERT_EQ ('x', *ex.Peek());
+    ASSERT_EQ('x', ex.PeekChar());
 }
 
 TEST_F (StringExtractorTest, GetHexU8_Exact_NoEof)
@@ -220,7 +212,6 @@ TEST_F (StringExtractorTest, GetHexU8_Ex
     ASSERT_EQ (true, ex.IsGood());
     ASSERT_EQ (2u, ex.GetFilePos());
     ASSERT_EQ (0u, ex.GetBytesLeft());
-    ASSERT_EQ (nullptr, ex.Peek());
 }
 
 TEST_F (StringExtractorTest, GetHexU8_Extra_NoEof)
@@ -233,7 +224,7 @@ TEST_F (StringExtractorTest, GetHexU8_Ex
     ASSERT_EQ (true, ex.IsGood());
     ASSERT_EQ (2u, ex.GetFilePos());
     ASSERT_EQ (2u, ex.GetBytesLeft());
-    ASSERT_EQ ('3', *ex.Peek());
+    ASSERT_EQ('3', ex.PeekChar());
 }
 
 TEST_F (StringExtractorTest, GetHexBytes)
@@ -257,7 +248,7 @@ TEST_F (StringExtractorTest, GetHexBytes
     ASSERT_EQ(2*kValidHexPairs, ex.GetFilePos());
     ASSERT_EQ(false, ex.Empty());
     ASSERT_EQ(4u, ex.GetBytesLeft());
-    ASSERT_EQ('x', *ex.Peek());
+    ASSERT_EQ('x', ex.PeekChar());
 }
 
 TEST_F(StringExtractorTest, GetHexBytes_FullString)
@@ -344,7 +335,6 @@ TEST_F (StringExtractorTest, GetHexBytes
     ASSERT_EQ(UINT64_MAX, ex.GetFilePos());
     ASSERT_EQ(false, ex.Empty());
     ASSERT_EQ(0u, ex.GetBytesLeft());
-    ASSERT_EQ(0, ex.Peek());
 }
 
 TEST_F (StringExtractorTest, GetHexBytes_Partial)
@@ -374,7 +364,7 @@ TEST_F (StringExtractorTest, GetHexBytes
     ASSERT_EQ(kReadBytes*2, ex.GetFilePos());
     ASSERT_EQ(false, ex.Empty());
     ASSERT_EQ(12u, ex.GetBytesLeft());
-    ASSERT_EQ('2', *ex.Peek());
+    ASSERT_EQ('2', ex.PeekChar());
 }
 
 TEST_F (StringExtractorTest, GetHexBytesAvail)
@@ -398,7 +388,7 @@ TEST_F (StringExtractorTest, GetHexBytes
     ASSERT_EQ(2*kValidHexPairs, ex.GetFilePos());
     ASSERT_EQ(false, ex.Empty());
     ASSERT_EQ(4u, ex.GetBytesLeft());
-    ASSERT_EQ('x', *ex.Peek());
+    ASSERT_EQ('x', ex.PeekChar());
 }
 
 TEST_F(StringExtractorTest, GetHexBytesAvail_FullString)
@@ -481,7 +471,7 @@ TEST_F (StringExtractorTest, GetHexBytes
     ASSERT_EQ(kValidHexPairs*2, ex.GetFilePos());
     ASSERT_EQ(false, ex.Empty());
     ASSERT_EQ(4u, ex.GetBytesLeft());
-    ASSERT_EQ('x', *ex.Peek());
+    ASSERT_EQ('x', ex.PeekChar());
 }
 
 TEST_F (StringExtractorTest, GetHexBytesAvail_Partial)
@@ -511,7 +501,7 @@ TEST_F (StringExtractorTest, GetHexBytes
     ASSERT_EQ(kReadBytes*2, ex.GetFilePos());
     ASSERT_EQ(false, ex.Empty());
     ASSERT_EQ(12u, ex.GetBytesLeft());
-    ASSERT_EQ('2', *ex.Peek());
+    ASSERT_EQ('2', ex.PeekChar());
 }
 
 TEST_F(StringExtractorTest, GetNameColonValueSuccess)




More information about the lldb-commits mailing list