[Lldb-commits] [lldb] r363211 - [Reproducers] Simplify providers with nested Info struct (NFC)
Jonas Devlieghere via lldb-commits
lldb-commits at lists.llvm.org
Wed Jun 12 15:17:38 PDT 2019
Author: jdevlieghere
Date: Wed Jun 12 15:17:38 2019
New Revision: 363211
URL: http://llvm.org/viewvc/llvm-project?rev=363211&view=rev
Log:
[Reproducers] Simplify providers with nested Info struct (NFC)
This replaces the `info` typedef with a nested struct named Info. This
means we now have FooProvider and FooProvider::Info, instead of two
related but separate classes FooProvider and FooInfo. This change is
mostly cosmetic.
Modified:
lldb/trunk/include/lldb/Utility/Reproducer.h
lldb/trunk/source/API/SBDebugger.cpp
lldb/trunk/source/API/SBReproducer.cpp
lldb/trunk/source/API/SBReproducerPrivate.h
lldb/trunk/source/Initialization/SystemInitializerCommon.cpp
lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/trunk/source/Utility/Reproducer.cpp
lldb/trunk/unittests/Utility/ReproducerTest.cpp
Modified: lldb/trunk/include/lldb/Utility/Reproducer.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/Reproducer.h?rev=363211&r1=363210&r2=363211&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Utility/Reproducer.h (original)
+++ lldb/trunk/include/lldb/Utility/Reproducer.h Wed Jun 12 15:17:38 2019
@@ -75,21 +75,19 @@ public:
const void *DynamicClassID() const override { return &ThisProviderT::ID; }
- llvm::StringRef GetName() const override { return ThisProviderT::info::name; }
- llvm::StringRef GetFile() const override { return ThisProviderT::info::file; }
+ llvm::StringRef GetName() const override { return ThisProviderT::Info::name; }
+ llvm::StringRef GetFile() const override { return ThisProviderT::Info::file; }
protected:
using ProviderBase::ProviderBase; // Inherit constructor.
};
-struct FileInfo {
- static const char *name;
- static const char *file;
-};
-
class FileProvider : public Provider<FileProvider> {
public:
- typedef FileInfo info;
+ struct Info {
+ static const char *name;
+ static const char *file;
+ };
FileProvider(const FileSpec &directory)
: Provider(directory),
@@ -98,7 +96,7 @@ public:
FileCollector &GetFileCollector() { return m_collector; }
void Keep() override {
- auto mapping = GetRoot().CopyByAppendingPathComponent(info::file);
+ auto mapping = GetRoot().CopyByAppendingPathComponent(Info::file);
// Temporary files that are removed during execution can cause copy errors.
if (auto ec = m_collector.CopyFiles(/*stop_on_error=*/false))
return;
@@ -142,14 +140,12 @@ private:
bool m_record;
};
-struct CommandInfo {
- static const char *name;
- static const char *file;
-};
-
class CommandProvider : public Provider<CommandProvider> {
public:
- typedef CommandInfo info;
+ struct Info {
+ static const char *name;
+ static const char *file;
+ };
CommandProvider(const FileSpec &directory) : Provider(directory) {}
Modified: lldb/trunk/source/API/SBDebugger.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBDebugger.cpp?rev=363211&r1=363210&r2=363211&view=diff
==============================================================================
--- lldb/trunk/source/API/SBDebugger.cpp (original)
+++ lldb/trunk/source/API/SBDebugger.cpp Wed Jun 12 15:17:38 2019
@@ -67,7 +67,7 @@ public:
if (!loader)
return {};
- FileSpec file = loader->GetFile<repro::CommandInfo>();
+ FileSpec file = loader->GetFile<repro::CommandProvider::Info>();
if (!file)
return {};
Modified: lldb/trunk/source/API/SBReproducer.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBReproducer.cpp?rev=363211&r1=363210&r2=363211&view=diff
==============================================================================
--- lldb/trunk/source/API/SBReproducer.cpp (original)
+++ lldb/trunk/source/API/SBReproducer.cpp Wed Jun 12 15:17:38 2019
@@ -136,7 +136,7 @@ const char *SBReproducer::Replay(const c
return error.c_str();
}
- FileSpec file = loader->GetFile<SBInfo>();
+ FileSpec file = loader->GetFile<SBProvider::Info>();
if (!file) {
error = "unable to get replay data from reproducer.";
return error.c_str();
@@ -149,5 +149,5 @@ const char *SBReproducer::Replay(const c
}
char lldb_private::repro::SBProvider::ID = 0;
-const char *SBInfo::name = "sbapi";
-const char *SBInfo::file = "sbapi.bin";
+const char *SBProvider::Info::name = "sbapi";
+const char *SBProvider::Info::file = "sbapi.bin";
Modified: lldb/trunk/source/API/SBReproducerPrivate.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBReproducerPrivate.h?rev=363211&r1=363210&r2=363211&view=diff
==============================================================================
--- lldb/trunk/source/API/SBReproducerPrivate.h (original)
+++ lldb/trunk/source/API/SBReproducerPrivate.h Wed Jun 12 15:17:38 2019
@@ -30,14 +30,12 @@ public:
SBRegistry();
};
-struct SBInfo {
- static const char *name;
- static const char *file;
-};
-
class SBProvider : public Provider<SBProvider> {
public:
- typedef SBInfo info;
+ struct Info {
+ static const char *name;
+ static const char *file;
+ };
SBProvider(const FileSpec &directory)
: Provider(directory),
Modified: lldb/trunk/source/Initialization/SystemInitializerCommon.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Initialization/SystemInitializerCommon.cpp?rev=363211&r1=363210&r2=363211&view=diff
==============================================================================
--- lldb/trunk/source/Initialization/SystemInitializerCommon.cpp (original)
+++ lldb/trunk/source/Initialization/SystemInitializerCommon.cpp Wed Jun 12 15:17:38 2019
@@ -70,7 +70,7 @@ llvm::Error SystemInitializerCommon::Ini
// Initialize the file system.
auto &r = repro::Reproducer::Instance();
if (repro::Loader *loader = r.GetLoader()) {
- FileSpec vfs_mapping = loader->GetFile<FileInfo>();
+ FileSpec vfs_mapping = loader->GetFile<FileProvider::Info>();
if (vfs_mapping) {
if (llvm::Error e = FileSystem::Initialize(vfs_mapping))
return e;
Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=363211&r1=363210&r2=363211&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Wed Jun 12 15:17:38 2019
@@ -163,24 +163,19 @@ static const ProcessKDPPropertiesSP &Get
return g_settings_sp;
}
-struct ProcessGDBRemoteInfo {
- static const char *name;
- static const char *file;
-};
-
-const char *ProcessGDBRemoteInfo::name = "gdb-remote";
-const char *ProcessGDBRemoteInfo::file = "gdb-remote.yaml";
-
class ProcessGDBRemoteProvider
: public repro::Provider<ProcessGDBRemoteProvider> {
public:
- typedef ProcessGDBRemoteInfo info;
+ struct Info {
+ static const char *name;
+ static const char *file;
+ };
ProcessGDBRemoteProvider(const FileSpec &directory) : Provider(directory) {
}
raw_ostream *GetHistoryStream() {
- FileSpec history_file = GetRoot().CopyByAppendingPathComponent(info::file);
+ FileSpec history_file = GetRoot().CopyByAppendingPathComponent(Info::file);
std::error_code EC;
m_stream_up = llvm::make_unique<raw_fd_ostream>(history_file.GetPath(), EC,
@@ -204,6 +199,8 @@ private:
};
char ProcessGDBRemoteProvider::ID = 0;
+const char *ProcessGDBRemoteProvider::Info::name = "gdb-remote";
+const char *ProcessGDBRemoteProvider::Info::file = "gdb-remote.yaml";
} // namespace
@@ -3432,7 +3429,7 @@ Status ProcessGDBRemote::ConnectToReplay
return Status("No loader provided.");
// Construct replay history path.
- FileSpec history_file = loader->GetFile<ProcessGDBRemoteInfo>();
+ FileSpec history_file = loader->GetFile<ProcessGDBRemoteProvider::Info>();
if (!history_file)
return Status("No provider for gdb-remote.");
Modified: lldb/trunk/source/Utility/Reproducer.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/Reproducer.cpp?rev=363211&r1=363210&r2=363211&view=diff
==============================================================================
--- lldb/trunk/source/Utility/Reproducer.cpp (original)
+++ lldb/trunk/source/Utility/Reproducer.cpp Wed Jun 12 15:17:38 2019
@@ -231,7 +231,7 @@ DataRecorder::Create(const FileSpec &fil
DataRecorder *CommandProvider::GetNewDataRecorder() {
std::size_t i = m_data_recorders.size() + 1;
- std::string filename = (llvm::Twine(info::name) + llvm::Twine("-") +
+ std::string filename = (llvm::Twine(Info::name) + llvm::Twine("-") +
llvm::Twine(i) + llvm::Twine(".txt"))
.str();
auto recorder_or_error =
@@ -252,7 +252,7 @@ void CommandProvider::Keep() {
files.push_back(recorder->GetFilename().GetPath());
}
- FileSpec file = GetRoot().CopyByAppendingPathComponent(info::file);
+ FileSpec file = GetRoot().CopyByAppendingPathComponent(Info::file);
std::error_code ec;
llvm::raw_fd_ostream os(file.GetPath(), ec, llvm::sys::fs::F_Text);
if (ec)
@@ -267,7 +267,7 @@ void ProviderBase::anchor() {}
char ProviderBase::ID = 0;
char FileProvider::ID = 0;
char CommandProvider::ID = 0;
-const char *FileInfo::name = "files";
-const char *FileInfo::file = "files.yaml";
-const char *CommandInfo::name = "command-interpreter";
-const char *CommandInfo::file = "command-interpreter.yaml";
+const char *FileProvider::Info::name = "files";
+const char *FileProvider::Info::file = "files.yaml";
+const char *CommandProvider::Info::name = "command-interpreter";
+const char *CommandProvider::Info::file = "command-interpreter.yaml";
Modified: lldb/trunk/unittests/Utility/ReproducerTest.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Utility/ReproducerTest.cpp?rev=363211&r1=363210&r2=363211&view=diff
==============================================================================
--- lldb/trunk/unittests/Utility/ReproducerTest.cpp (original)
+++ lldb/trunk/unittests/Utility/ReproducerTest.cpp Wed Jun 12 15:17:38 2019
@@ -19,23 +19,21 @@ using namespace llvm;
using namespace lldb_private;
using namespace lldb_private::repro;
-struct DummyInfo {
- static const char *name;
- static const char *file;
-};
-
-const char *DummyInfo::name = "dummy";
-const char *DummyInfo::file = "dummy.yaml";
-
class DummyProvider : public repro::Provider<DummyProvider> {
public:
- typedef DummyInfo info;
+ struct Info {
+ static const char *name;
+ static const char *file;
+ };
DummyProvider(const FileSpec &directory) : Provider(directory) {}
static char ID;
};
+const char *DummyProvider::Info::name = "dummy";
+const char *DummyProvider::Info::file = "dummy.yaml";
+
class DummyReproducer : public Reproducer {
public:
DummyReproducer() : Reproducer(){};
More information about the lldb-commits
mailing list