// // This file is distributed under the MIT License. See LICENSE.md for details. // #include #include "llvm/Support/CommandLine.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/raw_ostream.h" #include "revng/Model/Binary.h" #include "revng/Support/InitRevng.h" #include "revng/Support/MetaAddress/YAMLTraits.h" #include "revng/Support/YAMLTraits.h" #include "revng/TupleTree/TupleTreeDiff.h" namespace cl = llvm::cl; static cl::OptionCategory ThisToolCategory("Tool options", ""); static cl::opt PathModel(cl::Positional, cl::cat(ThisToolCategory), cl::desc(""), cl::value_desc("model")); static cl::opt DiffPath(cl::Positional, cl::cat(ThisToolCategory), cl::desc(""), cl::init("-"), cl::value_desc("model")); static cl::opt OutputPath("o", llvm::cl::init("-"), llvm::cl::desc("Override output " "filename"), llvm::cl::value_desc("filename"), llvm::cl::cat(ThisToolCategory)); int main(int Argc, char *Argv[]) { revng::InitRevng X(Argc, Argv, "", { &ThisToolCategory }); llvm::ExitOnError ExitOnError; using Type = TupleTree; auto Model = Type::fromFileOrSTDIN(PathModel); if (not Model) ExitOnError(Model.takeError()); using TypeDiff = TupleTreeDiff; auto Diff = ExitOnError(fromFileOrSTDIN(DiffPath)); ExitOnError(Diff.apply(*Model)); ExitOnError(Model->toFile(OutputPath)); return EXIT_SUCCESS; }