mirror of
https://github.com/intel/llvm.git
synced 2026-01-16 05:32:28 +08:00
[lldb][NFCI] Remove unneeded ConstString conversions
ConstString can be implicitly converted into a llvm::StringRef. This is very useful in many places, but it also hides places where we are creating a ConstString only to use it as a StringRef for the entire lifespan of the ConstString object. I locally removed the implicit conversion and found some of the places we were doing this. Differential Revision: https://reviews.llvm.org/D159237
This commit is contained in:
@@ -44,7 +44,7 @@ class PlatformProperties : public Properties {
|
||||
public:
|
||||
PlatformProperties();
|
||||
|
||||
static ConstString GetSettingName();
|
||||
static llvm::StringRef GetSettingName();
|
||||
|
||||
bool GetUseModuleCache() const;
|
||||
bool SetUseModuleCache(bool use_module_cache);
|
||||
|
||||
@@ -75,8 +75,7 @@ enum {
|
||||
} // namespace
|
||||
|
||||
ModuleListProperties::ModuleListProperties() {
|
||||
m_collection_sp =
|
||||
std::make_shared<OptionValueProperties>(ConstString("symbols"));
|
||||
m_collection_sp = std::make_shared<OptionValueProperties>("symbols");
|
||||
m_collection_sp->Initialize(g_modulelist_properties);
|
||||
m_collection_sp->SetValueChangedCallback(ePropertySymLinkPaths,
|
||||
[this] { UpdateSymlinkMappings(); });
|
||||
|
||||
@@ -311,7 +311,7 @@ ValueObjectSynthetic::GetChildMemberWithName(llvm::StringRef name,
|
||||
bool can_create) {
|
||||
UpdateValueIfNeeded();
|
||||
|
||||
uint32_t index = GetIndexOfChildWithName(ConstString(name));
|
||||
uint32_t index = GetIndexOfChildWithName(name);
|
||||
|
||||
if (index == UINT32_MAX)
|
||||
return lldb::ValueObjectSP();
|
||||
|
||||
@@ -128,8 +128,8 @@ CommandInterpreter::CommandInterpreter(Debugger &debugger,
|
||||
bool synchronous_execution)
|
||||
: Broadcaster(debugger.GetBroadcasterManager(),
|
||||
CommandInterpreter::GetStaticBroadcasterClass().AsCString()),
|
||||
Properties(OptionValuePropertiesSP(
|
||||
new OptionValueProperties(ConstString("interpreter")))),
|
||||
Properties(
|
||||
OptionValuePropertiesSP(new OptionValueProperties("interpreter"))),
|
||||
IOHandlerDelegate(IOHandlerDelegate::Completion::LLDBCommand),
|
||||
m_debugger(debugger), m_synchronous_execution(true),
|
||||
m_skip_lldbinit_files(false), m_skip_app_init_files(false),
|
||||
|
||||
@@ -98,8 +98,8 @@ enum {
|
||||
|
||||
class DynamicLoaderDarwinKernelProperties : public Properties {
|
||||
public:
|
||||
static ConstString &GetSettingName() {
|
||||
static ConstString g_setting_name("darwin-kernel");
|
||||
static llvm::StringRef GetSettingName() {
|
||||
static constexpr llvm::StringLiteral g_setting_name("darwin-kernel");
|
||||
return g_setting_name;
|
||||
}
|
||||
|
||||
|
||||
@@ -89,8 +89,8 @@ enum {
|
||||
|
||||
class PluginProperties : public Properties {
|
||||
public:
|
||||
static ConstString GetSettingName() {
|
||||
return ConstString(JITLoaderGDB::GetPluginNameStatic());
|
||||
static llvm::StringRef GetSettingName() {
|
||||
return JITLoaderGDB::GetPluginNameStatic();
|
||||
}
|
||||
|
||||
PluginProperties() {
|
||||
|
||||
@@ -38,7 +38,7 @@ public:
|
||||
ValueObjectSP GetChildAtIndex(size_t idx) override;
|
||||
|
||||
private:
|
||||
ConstString GetDataContainerMemberName();
|
||||
llvm::StringRef GetDataContainerMemberName();
|
||||
|
||||
// The lifetime of a ValueObject and all its derivative ValueObjects
|
||||
// (children, clones, etc.) is managed by a ClusterManager. These
|
||||
@@ -66,12 +66,14 @@ GenericBitsetFrontEnd::GenericBitsetFrontEnd(ValueObject &valobj, StdLib stdlib)
|
||||
}
|
||||
}
|
||||
|
||||
ConstString GenericBitsetFrontEnd::GetDataContainerMemberName() {
|
||||
llvm::StringRef GenericBitsetFrontEnd::GetDataContainerMemberName() {
|
||||
static constexpr llvm::StringLiteral s_libcxx_case("__first_");
|
||||
static constexpr llvm::StringLiteral s_libstdcpp_case("_M_w");
|
||||
switch (m_stdlib) {
|
||||
case StdLib::LibCxx:
|
||||
return ConstString("__first_");
|
||||
return s_libcxx_case;
|
||||
case StdLib::LibStdcpp:
|
||||
return ConstString("_M_w");
|
||||
return s_libstdcpp_case;
|
||||
}
|
||||
llvm_unreachable("Unknown StdLib enum");
|
||||
}
|
||||
|
||||
@@ -79,8 +79,8 @@ enum {
|
||||
|
||||
class PluginProperties : public Properties {
|
||||
public:
|
||||
static ConstString GetSettingName() {
|
||||
return ConstString(ObjectFilePECOFF::GetPluginNameStatic());
|
||||
static llvm::StringRef GetSettingName() {
|
||||
return ObjectFilePECOFF::GetPluginNameStatic();
|
||||
}
|
||||
|
||||
PluginProperties() {
|
||||
|
||||
@@ -43,7 +43,7 @@ class PluginProperties : public Properties {
|
||||
public:
|
||||
PluginProperties() {
|
||||
m_collection_sp = std::make_shared<OptionValueProperties>(
|
||||
ConstString(PlatformAndroid::GetPluginNameStatic(false)));
|
||||
PlatformAndroid::GetPluginNameStatic(false));
|
||||
m_collection_sp->Initialize(g_android_properties);
|
||||
}
|
||||
};
|
||||
@@ -155,8 +155,8 @@ PlatformSP PlatformAndroid::CreateInstance(bool force, const ArchSpec *arch) {
|
||||
}
|
||||
|
||||
void PlatformAndroid::DebuggerInitialize(Debugger &debugger) {
|
||||
if (!PluginManager::GetSettingForPlatformPlugin(
|
||||
debugger, ConstString(GetPluginNameStatic(false)))) {
|
||||
if (!PluginManager::GetSettingForPlatformPlugin(debugger,
|
||||
GetPluginNameStatic(false))) {
|
||||
PluginManager::CreateSettingForPlatformPlugin(
|
||||
debugger, GetGlobalProperties().GetValueProperties(),
|
||||
"Properties for the Android platform plugin.",
|
||||
|
||||
@@ -123,8 +123,8 @@ enum {
|
||||
|
||||
class PlatformDarwinProperties : public Properties {
|
||||
public:
|
||||
static ConstString &GetSettingName() {
|
||||
static ConstString g_setting_name("darwin");
|
||||
static llvm::StringRef GetSettingName() {
|
||||
static constexpr llvm::StringLiteral g_setting_name("darwin");
|
||||
return g_setting_name;
|
||||
}
|
||||
|
||||
|
||||
@@ -187,8 +187,8 @@ enum {
|
||||
|
||||
class PlatformDarwinKernelProperties : public Properties {
|
||||
public:
|
||||
static ConstString &GetSettingName() {
|
||||
static ConstString g_setting_name("darwin-kernel");
|
||||
static llvm::StringRef GetSettingName() {
|
||||
static constexpr llvm::StringLiteral g_setting_name("darwin-kernel");
|
||||
return g_setting_name;
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ class PluginProperties : public Properties {
|
||||
public:
|
||||
PluginProperties() {
|
||||
m_collection_sp = std::make_shared<OptionValueProperties>(
|
||||
ConstString(PlatformQemuUser::GetPluginNameStatic()));
|
||||
PlatformQemuUser::GetPluginNameStatic());
|
||||
m_collection_sp->Initialize(g_platformqemuuser_properties);
|
||||
}
|
||||
|
||||
@@ -89,8 +89,8 @@ void PlatformQemuUser::Terminate() {
|
||||
}
|
||||
|
||||
void PlatformQemuUser::DebuggerInitialize(Debugger &debugger) {
|
||||
if (!PluginManager::GetSettingForPlatformPlugin(
|
||||
debugger, ConstString(GetPluginNameStatic()))) {
|
||||
if (!PluginManager::GetSettingForPlatformPlugin(debugger,
|
||||
GetPluginNameStatic())) {
|
||||
PluginManager::CreateSettingForPlatformPlugin(
|
||||
debugger, GetGlobalProperties().GetValueProperties(),
|
||||
"Properties for the qemu-user platform plugin.",
|
||||
|
||||
@@ -65,8 +65,8 @@ enum {
|
||||
|
||||
class PluginProperties : public Properties {
|
||||
public:
|
||||
static ConstString GetSettingName() {
|
||||
return ConstString(ProcessKDP::GetPluginNameStatic());
|
||||
static llvm::StringRef GetSettingName() {
|
||||
return ProcessKDP::GetPluginNameStatic();
|
||||
}
|
||||
|
||||
PluginProperties() : Properties() {
|
||||
|
||||
@@ -129,8 +129,8 @@ enum {
|
||||
|
||||
class PluginProperties : public Properties {
|
||||
public:
|
||||
static ConstString GetSettingName() {
|
||||
return ConstString(ProcessGDBRemote::GetPluginNameStatic());
|
||||
static llvm::StringRef GetSettingName() {
|
||||
return ProcessGDBRemote::GetPluginNameStatic();
|
||||
}
|
||||
|
||||
PluginProperties() : Properties() {
|
||||
|
||||
@@ -117,8 +117,8 @@ enum {
|
||||
|
||||
class StructuredDataDarwinLogProperties : public Properties {
|
||||
public:
|
||||
static ConstString &GetSettingName() {
|
||||
static ConstString g_setting_name("darwin-log");
|
||||
static llvm::StringRef GetSettingName() {
|
||||
static constexpr llvm::StringLiteral g_setting_name("darwin-log");
|
||||
return g_setting_name;
|
||||
}
|
||||
|
||||
|
||||
@@ -114,8 +114,8 @@ enum {
|
||||
|
||||
class PluginProperties : public Properties {
|
||||
public:
|
||||
static ConstString GetSettingName() {
|
||||
return ConstString(SymbolFileDWARF::GetPluginNameStatic());
|
||||
static llvm::StringRef GetSettingName() {
|
||||
return SymbolFileDWARF::GetPluginNameStatic();
|
||||
}
|
||||
|
||||
PluginProperties() {
|
||||
|
||||
@@ -72,8 +72,8 @@ enum {
|
||||
|
||||
} // namespace
|
||||
|
||||
ConstString PlatformProperties::GetSettingName() {
|
||||
static ConstString g_setting_name("platform");
|
||||
llvm::StringRef PlatformProperties::GetSettingName() {
|
||||
static constexpr llvm::StringLiteral g_setting_name("platform");
|
||||
return g_setting_name;
|
||||
}
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ using namespace std::chrono;
|
||||
class ProcessOptionValueProperties
|
||||
: public Cloneable<ProcessOptionValueProperties, OptionValueProperties> {
|
||||
public:
|
||||
ProcessOptionValueProperties(ConstString name) : Cloneable(name) {}
|
||||
ProcessOptionValueProperties(llvm::StringRef name) : Cloneable(name) {}
|
||||
|
||||
const Property *
|
||||
GetPropertyAtIndex(size_t idx,
|
||||
@@ -146,8 +146,7 @@ class ProcessExperimentalOptionValueProperties
|
||||
OptionValueProperties> {
|
||||
public:
|
||||
ProcessExperimentalOptionValueProperties()
|
||||
: Cloneable(
|
||||
ConstString(Properties::GetExperimentalSettingsName())) {}
|
||||
: Cloneable(Properties::GetExperimentalSettingsName()) {}
|
||||
};
|
||||
|
||||
ProcessExperimentalProperties::ProcessExperimentalProperties()
|
||||
@@ -162,8 +161,7 @@ ProcessProperties::ProcessProperties(lldb_private::Process *process)
|
||||
{
|
||||
if (process == nullptr) {
|
||||
// Global process properties, set them up one time
|
||||
m_collection_sp =
|
||||
std::make_shared<ProcessOptionValueProperties>(ConstString("process"));
|
||||
m_collection_sp = std::make_shared<ProcessOptionValueProperties>("process");
|
||||
m_collection_sp->Initialize(g_process_properties);
|
||||
m_collection_sp->AppendProperty(
|
||||
"thread", "Settings specific to threads.", true,
|
||||
|
||||
@@ -4062,7 +4062,7 @@ enum {
|
||||
class TargetOptionValueProperties
|
||||
: public Cloneable<TargetOptionValueProperties, OptionValueProperties> {
|
||||
public:
|
||||
TargetOptionValueProperties(ConstString name) : Cloneable(name) {}
|
||||
TargetOptionValueProperties(llvm::StringRef name) : Cloneable(name) {}
|
||||
|
||||
const Property *
|
||||
GetPropertyAtIndex(size_t idx,
|
||||
@@ -4098,7 +4098,7 @@ class TargetExperimentalOptionValueProperties
|
||||
OptionValueProperties> {
|
||||
public:
|
||||
TargetExperimentalOptionValueProperties()
|
||||
: Cloneable(ConstString(Properties::GetExperimentalSettingsName())) {}
|
||||
: Cloneable(Properties::GetExperimentalSettingsName()) {}
|
||||
};
|
||||
|
||||
TargetExperimentalProperties::TargetExperimentalProperties()
|
||||
@@ -4152,8 +4152,7 @@ TargetProperties::TargetProperties(Target *target)
|
||||
"errors if the setting is not present.",
|
||||
true, m_experimental_properties_up->GetValueProperties());
|
||||
} else {
|
||||
m_collection_sp =
|
||||
std::make_shared<TargetOptionValueProperties>(ConstString("target"));
|
||||
m_collection_sp = std::make_shared<TargetOptionValueProperties>("target");
|
||||
m_collection_sp->Initialize(g_target_properties);
|
||||
m_experimental_properties_up =
|
||||
std::make_unique<TargetExperimentalProperties>();
|
||||
|
||||
@@ -76,7 +76,7 @@ enum {
|
||||
class ThreadOptionValueProperties
|
||||
: public Cloneable<ThreadOptionValueProperties, OptionValueProperties> {
|
||||
public:
|
||||
ThreadOptionValueProperties(ConstString name) : Cloneable(name) {}
|
||||
ThreadOptionValueProperties(llvm::StringRef name) : Cloneable(name) {}
|
||||
|
||||
const Property *
|
||||
GetPropertyAtIndex(size_t idx,
|
||||
@@ -100,8 +100,7 @@ public:
|
||||
|
||||
ThreadProperties::ThreadProperties(bool is_global) : Properties() {
|
||||
if (is_global) {
|
||||
m_collection_sp =
|
||||
std::make_shared<ThreadOptionValueProperties>(ConstString("thread"));
|
||||
m_collection_sp = std::make_shared<ThreadOptionValueProperties>("thread");
|
||||
m_collection_sp->Initialize(g_thread_properties);
|
||||
} else
|
||||
m_collection_sp =
|
||||
|
||||
Reference in New Issue
Block a user