[Reproducer] Add convenience methods IsCapturing and IsReplaying.

Add convenience methods to the Reproducer class for when you don't need
access to the generator and the loader.

llvm-svn: 374236
This commit is contained in:
Jonas Devlieghere 2019-10-09 21:47:49 +00:00
parent 00f9e5aa76
commit 865cd0932f
2 changed files with 6 additions and 3 deletions

View file

@ -313,6 +313,9 @@ public:
FileSpec GetReproducerPath() const;
bool IsCapturing() { return static_cast<bool>(m_generator); };
bool IsReplaying() { return static_cast<bool>(m_loader); };
protected:
llvm::Error SetCapture(llvm::Optional<FileSpec> root);
llvm::Error SetReplay(llvm::Optional<FileSpec> root);

View file

@ -88,7 +88,7 @@ protected:
auto &r = Reproducer::Instance();
if (auto generator = r.GetGenerator()) {
generator->Keep();
} else if (r.GetLoader()) {
} else if (r.IsReplaying()) {
// Make this operation a NOP in replay mode.
result.SetStatus(eReturnStatusSuccessFinishNoResult);
return result.Succeeded();
@ -132,9 +132,9 @@ protected:
}
auto &r = Reproducer::Instance();
if (r.GetGenerator()) {
if (r.IsCapturing()) {
result.GetOutputStream() << "Reproducer is in capture mode.\n";
} else if (r.GetLoader()) {
} else if (r.IsReplaying()) {
result.GetOutputStream() << "Reproducer is in replay mode.\n";
} else {
result.GetOutputStream() << "Reproducer is off.\n";