Author: zturner Date: Tue Nov 15 17:36:43 2016 New Revision: 287055 URL: http://llvm.org/viewvc/llvm-project?rev=287055&view=rev Log: Change Property::GetName() and GetDescription() to return StringRef.
Modified: lldb/trunk/include/lldb/Interpreter/OptionValueProperties.h lldb/trunk/include/lldb/Interpreter/Property.h lldb/trunk/source/Interpreter/OptionValueProperties.cpp lldb/trunk/source/Interpreter/Property.cpp Modified: lldb/trunk/include/lldb/Interpreter/OptionValueProperties.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/OptionValueProperties.h?rev=287055&r1=287054&r2=287055&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/OptionValueProperties.h (original) +++ lldb/trunk/include/lldb/Interpreter/OptionValueProperties.h Tue Nov 15 17:36:43 2016 @@ -76,10 +76,6 @@ public: virtual size_t GetNumProperties() const; - virtual ConstString GetPropertyNameAtIndex(uint32_t idx) const; - - virtual const char *GetPropertyDescriptionAtIndex(uint32_t idx) const; - //--------------------------------------------------------------------- // Get the index of a property given its exact name in this property // collection, "name" can't be a path to a property path that refers Modified: lldb/trunk/include/lldb/Interpreter/Property.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/Property.h?rev=287055&r1=287054&r2=287055&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/Property.h (original) +++ lldb/trunk/include/lldb/Interpreter/Property.h Tue Nov 15 17:36:43 2016 @@ -42,9 +42,10 @@ public: Property(const ConstString &name, const ConstString &desc, bool is_global, const lldb::OptionValueSP &value_sp); - const ConstString &GetName() const { return m_name; } - - const char *GetDescription() const { return m_description.GetCString(); } + llvm::StringRef GetName() const { return m_name.GetStringRef(); } + llvm::StringRef GetDescription() const { + return m_description.GetStringRef(); + } const lldb::OptionValueSP &GetValue() const { return m_value_sp; } Modified: lldb/trunk/source/Interpreter/OptionValueProperties.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/OptionValueProperties.cpp?rev=287055&r1=287054&r2=287055&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/OptionValueProperties.cpp (original) +++ lldb/trunk/source/Interpreter/OptionValueProperties.cpp Tue Nov 15 17:36:43 2016 @@ -59,8 +59,7 @@ void OptionValueProperties::Initialize(c for (size_t i = 0; defs[i].name; ++i) { Property property(defs[i]); assert(property.IsValid()); - m_name_to_index.Append(property.GetName().GetStringRef(), - m_properties.size()); + m_name_to_index.Append(property.GetName(), m_properties.size()); property.GetValue()->SetParent(shared_from_this()); m_properties.push_back(property); } @@ -217,21 +216,6 @@ Error OptionValueProperties::SetSubValue return error; } -ConstString OptionValueProperties::GetPropertyNameAtIndex(uint32_t idx) const { - const Property *property = GetPropertyAtIndex(nullptr, false, idx); - if (property) - return property->GetName(); - return ConstString(); -} - -const char * -OptionValueProperties::GetPropertyDescriptionAtIndex(uint32_t idx) const { - const Property *property = GetPropertyAtIndex(nullptr, false, idx); - if (property) - return property->GetDescription(); - return nullptr; -} - uint32_t OptionValueProperties::GetPropertyIndex(const ConstString &name) const { return m_name_to_index.Find(name.GetStringRef(), SIZE_MAX); @@ -641,8 +625,7 @@ void OptionValueProperties::DumpAllDescr for (size_t i = 0; i < num_properties; ++i) { const Property *property = ProtectedGetPropertyAtIndex(i); if (property) - max_name_len = - std::max<size_t>(property->GetName().GetLength(), max_name_len); + max_name_len = std::max<size_t>(property->GetName().size(), max_name_len); } for (size_t i = 0; i < num_properties; ++i) { const Property *property = ProtectedGetPropertyAtIndex(i); @@ -665,12 +648,12 @@ void OptionValueProperties::Apropos( properties->Apropos(keyword, matching_properties); } else { bool match = false; - const char *name = property->GetName().GetCString(); - if (name && ::strcasestr(name, keyword)) + llvm::StringRef name = property->GetName(); + if (name.contains_lower(keyword)) match = true; else { - const char *desc = property->GetDescription(); - if (desc && ::strcasestr(desc, keyword)) + llvm::StringRef desc = property->GetDescription(); + if (desc.contains_lower(keyword)) match = true; } if (match) { Modified: lldb/trunk/source/Interpreter/Property.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/Property.cpp?rev=287055&r1=287054&r2=287055&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/Property.cpp (original) +++ lldb/trunk/source/Interpreter/Property.cpp Tue Nov 15 17:36:43 2016 @@ -249,9 +249,9 @@ void Property::Dump(const ExecutionConte } } if (dump_desc) { - const char *desc = GetDescription(); - if (desc) - strm.Printf("-- %s", desc); + llvm::StringRef desc = GetDescription(); + if (!desc.empty()) + strm << "-- " << desc; if (transparent && (dump_mask == (OptionValue::eDumpOptionName | OptionValue::eDumpOptionDescription))) @@ -264,34 +264,30 @@ void Property::Dump(const ExecutionConte void Property::DumpDescription(CommandInterpreter &interpreter, Stream &strm, uint32_t output_width, bool display_qualified_name) const { - if (m_value_sp) { - const char *desc = GetDescription(); + if (!m_value_sp) + return; + llvm::StringRef desc = GetDescription(); - if (desc) { - StreamString qualified_name; - const OptionValueProperties *sub_properties = - m_value_sp->GetAsProperties(); - if (sub_properties) { - strm.EOL(); + if (desc.empty()) + return; - if (m_value_sp->DumpQualifiedName(qualified_name)) - strm.Printf("'%s' variables:\n\n", - qualified_name.GetString().c_str()); - sub_properties->DumpAllDescriptions(interpreter, strm); - } else { - if (desc) { - if (display_qualified_name) { - StreamString qualified_name; - DumpQualifiedName(qualified_name); - interpreter.OutputFormattedHelpText( - strm, qualified_name.GetString().c_str(), "--", desc, - output_width); - } else { - interpreter.OutputFormattedHelpText(strm, m_name.GetCString(), "--", - desc, output_width); - } - } - } + StreamString qualified_name; + const OptionValueProperties *sub_properties = m_value_sp->GetAsProperties(); + if (sub_properties) { + strm.EOL(); + + if (m_value_sp->DumpQualifiedName(qualified_name)) + strm.Printf("'%s' variables:\n\n", qualified_name.GetString().c_str()); + sub_properties->DumpAllDescriptions(interpreter, strm); + } else { + if (display_qualified_name) { + StreamString qualified_name; + DumpQualifiedName(qualified_name); + interpreter.OutputFormattedHelpText( + strm, qualified_name.GetString().c_str(), "--", desc, output_width); + } else { + interpreter.OutputFormattedHelpText(strm, m_name.GetCString(), "--", desc, + output_width); } } } _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits