forked from OSchip/llvm-project
[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. llvm-svn: 363211
This commit is contained in:
parent
781a0dc58d
commit
ef96e985fc
|
@ -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) {}
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ public:
|
|||
if (!loader)
|
||||
return {};
|
||||
|
||||
FileSpec file = loader->GetFile<repro::CommandInfo>();
|
||||
FileSpec file = loader->GetFile<repro::CommandProvider::Info>();
|
||||
if (!file)
|
||||
return {};
|
||||
|
||||
|
|
|
@ -136,7 +136,7 @@ const char *SBReproducer::Replay(const char *path) {
|
|||
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 char *path) {
|
|||
}
|
||||
|
||||
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";
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -70,7 +70,7 @@ llvm::Error SystemInitializerCommon::Initialize() {
|
|||
// 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;
|
||||
|
|
|
@ -163,24 +163,19 @@ static const ProcessKDPPropertiesSP &GetGlobalPluginProperties() {
|
|||
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::ConnectToReplayServer(repro::Loader *loader) {
|
|||
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.");
|
||||
|
||||
|
|
|
@ -231,7 +231,7 @@ DataRecorder::Create(const FileSpec &filename) {
|
|||
|
||||
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";
|
||||
|
|
|
@ -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(){};
|
||||
|
|
Loading…
Reference in New Issue