diff --git a/include/revng/Pipeline/Target.h b/include/revng/Pipeline/Target.h index ead3d3883..90af9fa4a 100644 --- a/include/revng/Pipeline/Target.h +++ b/include/revng/Pipeline/Target.h @@ -106,6 +106,7 @@ public: public: std::string toString() const; + std::string path() const; void dump() const debug_function { dump(dbg); } @@ -114,17 +115,6 @@ public: indent(OS, Indentation); OS << toString() << '\n'; } - - template - void dumpPathComponents(OStream &OS) const debug_function { - OS << "/"; - for (const auto &Entry : Components) { - OS << Entry; - if (&Entry != &Components.back()) - OS << "/"; - } - OS << ":" << K->name().str(); - } }; class KindsRegistry; diff --git a/lib/Pipeline/Target.cpp b/lib/Pipeline/Target.cpp index 3b32173e0..a9ecfc8eb 100644 --- a/lib/Pipeline/Target.cpp +++ b/lib/Pipeline/Target.cpp @@ -78,21 +78,12 @@ int Target::operator<=>(const Target &Other) const { return 0; } +std::string Target::path() const { + return llvm::join(Components, "/"); +} + std::string Target::toString() const { - std::string ToReturn; - - if (Components.size() == 0) { - return ":" + K->name().str(); - } - - for (size_t I = 0; I < Components.size() - 1; I++) - ToReturn += Components[I] + "/"; - - ToReturn += Components.back(); - ToReturn += ":"; - ToReturn += K->name(); - - return ToReturn; + return path() + ":" + K->name().str(); } llvm::Expected Target::deserialize(Context &Context, diff --git a/tools/pipeline/artifact/Main.cpp b/tools/pipeline/artifact/Main.cpp index f341340e5..85728cc4b 100644 --- a/tools/pipeline/artifact/Main.cpp +++ b/tools/pipeline/artifact/Main.cpp @@ -186,8 +186,7 @@ int main(int argc, char *argv[]) { auto State = StepState.second.find(ContainerName)->second.filter(*Kind); for (const auto &Entry : State) { - Entry.dumpPathComponents(dbg); - dbg << "\n"; + dbg << Entry.path() << "\n"; } return EXIT_SUCCESS; } @@ -197,8 +196,10 @@ int main(int argc, char *argv[]) { Map.add(ContainerName, Kind->allTargets(Manager.context())); } else { for (llvm::StringRef Argument : llvm::drop_begin(Arguments, 2)) { - auto RequestedTarget = AbortOnError(Target::deserialize(Manager.context(), - Argument)); + std::string ArgumentWithKind = (Argument + ":" + Kind->name()).str(); + auto + RequestedTarget = AbortOnError(Target::deserialize(Manager.context(), + ArgumentWithKind)); Map.add(ContainerName, RequestedTarget); } }