[llvm] [readtapi] Add Merge functionality (PR #72656)

Juergen Ributzka via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 17 08:19:43 PST 2023


================
@@ -81,28 +89,37 @@ bool handleCompareAction(const Context &Ctx) {
     ExitOnErr(make_error<TextAPIError>(TextAPIErrorCode::InvalidInputFormat,
                                        "compare only supports 2 input files"));
   }
-  StringRef InputFileName = Ctx.Inputs.front();
-  ExitOnErr.setBanner("error: '" + InputFileName.str() + "' ");
-  auto BinLHS = ExitOnErr(convertFileToBinary(InputFileName));
-
-  TapiUniversal *FileLHS = dyn_cast<TapiUniversal>(BinLHS.get());
-  if (!FileLHS) {
-    ExitOnErr(createStringError(std::errc::executable_format_error,
-                                "unsupported file format"));
-  }
 
-  StringRef CompareInputFileName = Ctx.Inputs.at(1);
-  ExitOnErr.setBanner("error: '" + CompareInputFileName.str() + "' ");
-  auto BinRHS = ExitOnErr(convertFileToBinary(CompareInputFileName));
+  auto LeftIF = getInterfaceFile(Ctx.Inputs.front(), ExitOnErr);
+  auto RightIF = getInterfaceFile(Ctx.Inputs.at(1), ExitOnErr);
+
+  raw_ostream &OS = Ctx.OutStream ? *Ctx.OutStream : outs();
+  return DiffEngine(LeftIF.get(), RightIF.get()).compareFiles(OS);
+}
 
-  TapiUniversal *FileRHS = dyn_cast<TapiUniversal>(BinRHS.get());
-  if (!FileRHS) {
-    ExitOnErr(createStringError(std::errc::executable_format_error,
-                                "unsupported file format"));
+bool handleMergeAction(const Context &Ctx) {
+  ExitOnError ExitOnErr("error: ");
+  if (Ctx.Inputs.size() < 2) {
+    ExitOnErr(
+        make_error<TextAPIError>(TextAPIErrorCode::InvalidInputFormat,
----------------
ributzka wrote:

Shouldn't this be a generic invalid argument error?

https://github.com/llvm/llvm-project/pull/72656


More information about the llvm-commits mailing list