Index: lldb/trunk/include/lldb/Utility/ConstString.h =================================================================== --- lldb/trunk/include/lldb/Utility/ConstString.h +++ lldb/trunk/include/lldb/Utility/ConstString.h @@ -346,6 +346,15 @@ bool IsEmpty() const { return m_string == nullptr || m_string[0] == '\0'; } //------------------------------------------------------------------ + /// Test for null string. + /// + /// @return + /// @li \b true if there is no string associated with this instance. + /// @li \b false if there is a string associated with this instance. + //------------------------------------------------------------------ + bool IsNull() const { return m_string == nullptr; } + + //------------------------------------------------------------------ /// Set the C string value. /// /// Set the string value in the object by uniquing the \a cstr string value Index: lldb/trunk/source/Core/Mangled.cpp =================================================================== --- lldb/trunk/source/Core/Mangled.cpp +++ lldb/trunk/source/Core/Mangled.cpp @@ -242,7 +242,7 @@ Mangled::GetDemangledName(lldb::LanguageType language) const { // Check to make sure we have a valid mangled name and that we haven't // already decoded our mangled name. - if (m_mangled && !m_demangled) { + if (m_mangled && m_demangled.IsNull()) { // We need to generate and cache the demangled name. static Timer::Category func_cat(LLVM_PRETTY_FUNCTION); Timer scoped_timer(func_cat, "Mangled::GetDemangledName (m_mangled = %s)", @@ -312,7 +312,7 @@ free(demangled_name); } } - if (!m_demangled) { + if (m_demangled.IsNull()) { // Set the demangled string to the empty string to indicate we tried to // parse it once and failed. m_demangled.SetCString(""); Index: lldb/trunk/unittests/Utility/ConstStringTest.cpp =================================================================== --- lldb/trunk/unittests/Utility/ConstStringTest.cpp +++ lldb/trunk/unittests/Utility/ConstStringTest.cpp @@ -33,3 +33,20 @@ EXPECT_TRUE(foo.GetMangledCounterpart(counterpart)); EXPECT_EQ("bar", counterpart.GetStringRef()); } + +TEST(ConstStringTest, NullAndEmptyStates) { + ConstString foo("foo"); + EXPECT_FALSE(!foo); + EXPECT_FALSE(foo.IsEmpty()); + EXPECT_FALSE(foo.IsNull()); + + ConstString empty(""); + EXPECT_TRUE(!empty); + EXPECT_TRUE(empty.IsEmpty()); + EXPECT_FALSE(empty.IsNull()); + + ConstString null; + EXPECT_TRUE(!null); + EXPECT_TRUE(null.IsEmpty()); + EXPECT_TRUE(null.IsNull()); +}