/// \file Main.cpp // // 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/ToolHelpers.h" #include "revng/Support/InitRevng.h" #include "revng/Support/MetaAddress/YAMLTraits.h" #include "revng/Support/YAMLTraits.h" #include "revng/TupleTree/TupleTreeDiff.h" using namespace llvm; 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 ModelOutputOptions Options(ThisToolCategory); int main(int Argc, char *Argv[]) { revng::InitRevng X(Argc, Argv, "", { &ThisToolCategory }); ExitOnError ExitOnError; using Type = TupleTree; auto Model = llvm::errorOrToExpected(Type::fromFileOrSTDIN(PathModel)); if (not Model) ExitOnError(Model.takeError()); using TypeDiff = TupleTreeDiff; auto Diff = ExitOnError(deserializeFileOrSTDIN(DiffPath)); ExitOnError(Diff.apply(*Model)); auto DesiredOutput = Options.getDesiredOutput(); ExitOnError(Model->toFile(Options.getPath())); return EXIT_SUCCESS; }