Merge changes If8f521fa,Iaffcdffa into main

* changes:
  Remove IRDiffToProtobufConverter
  Remove IRToJsonConverter
diff --git a/vndk/tools/header-checker/Android.bp b/vndk/tools/header-checker/Android.bp
index 541f206..2d020d8 100644
--- a/vndk/tools/header-checker/Android.bp
+++ b/vndk/tools/header-checker/Android.bp
@@ -146,7 +146,6 @@
         "src/repr/json/converter.cpp",
         "src/repr/json/ir_dumper.cpp",
         "src/repr/json/ir_reader.cpp",
-        "src/repr/protobuf/converter.cpp",
         "src/repr/protobuf/ir_diff_dumper.cpp",
         "src/repr/protobuf/ir_dumper.cpp",
         "src/repr/protobuf/ir_reader.cpp",
diff --git a/vndk/tools/header-checker/src/repr/json/ir_dumper.cpp b/vndk/tools/header-checker/src/repr/json/ir_dumper.cpp
index faf49d6..0dcc510 100644
--- a/vndk/tools/header-checker/src/repr/json/ir_dumper.cpp
+++ b/vndk/tools/header-checker/src/repr/json/ir_dumper.cpp
@@ -15,19 +15,13 @@
 #include "repr/json/ir_dumper.h"
 
 #include "repr/ir_dumper.h"
-#include "repr/ir_reader.h"
-#include "repr/ir_representation_internal.h"
+#include "repr/ir_representation.h"
 #include "repr/json/api.h"
 #include "repr/json/converter.h"
 
-#include <json/reader.h>
 #include <json/writer.h>
 
-#include <llvm/Support/raw_ostream.h>
-
-#include <cstdlib>
 #include <fstream>
-#include <sstream>
 #include <string>
 
 
@@ -70,8 +64,8 @@
   }
 }
 
-void IRToJsonConverter::AddTemplateInfo(
-    JsonObject &type_decl, const TemplatedArtifactIR *template_ir) {
+static void AddTemplateInfo(JsonObject &type_decl,
+                            const TemplatedArtifactIR *template_ir) {
   JsonArray args;
   for (auto &&template_element_ir : template_ir->GetTemplateElements()) {
     args.append(template_element_ir.GetReferencedType());
@@ -79,8 +73,7 @@
   type_decl.Set("template_args", args);
 }
 
-void IRToJsonConverter::AddTypeInfo(JsonObject &type_decl,
-                                    const TypeIR *type_ir) {
+static void AddTypeInfo(JsonObject &type_decl, const TypeIR *type_ir) {
   // LinkableMessageIR
   type_decl.Set("source_file", type_ir->GetSourceFile());
   const std::string &linker_set_key = type_ir->GetLinkerSetKey();
@@ -111,8 +104,8 @@
   return record_field;
 }
 
-void IRToJsonConverter::AddRecordFields(JsonObject &record_type,
-                                        const RecordTypeIR *record_ir) {
+static void AddRecordFields(JsonObject &record_type,
+                            const RecordTypeIR *record_ir) {
   JsonArray fields;
   for (auto &&field_ir : record_ir->GetFields()) {
     fields.append(ConvertRecordFieldIR(&field_ir));
@@ -129,8 +122,8 @@
   return base_specifier;
 }
 
-void IRToJsonConverter::AddBaseSpecifiers(JsonObject &record_type,
-                                          const RecordTypeIR *record_ir) {
+static void AddBaseSpecifiers(JsonObject &record_type,
+                              const RecordTypeIR *record_ir) {
   JsonArray base_specifiers;
   for (auto &&base_ir : record_ir->GetBases()) {
     base_specifiers.append(ConvertBaseSpecifierIR(base_ir));
@@ -149,8 +142,8 @@
   return vtable_component;
 }
 
-void IRToJsonConverter::AddVTableLayout(JsonObject &record_type,
-                                        const RecordTypeIR *record_ir) {
+static void AddVTableLayout(JsonObject &record_type,
+                            const RecordTypeIR *record_ir) {
   JsonArray vtable_components;
   for (auto &&vtable_component_ir :
        record_ir->GetVTableLayout().GetVTableComponents()) {
@@ -159,7 +152,7 @@
   record_type.Set("vtable_components", vtable_components);
 }
 
-JsonObject IRToJsonConverter::ConvertRecordTypeIR(const RecordTypeIR *recordp) {
+static JsonObject ConvertRecordTypeIR(const RecordTypeIR *recordp) {
   JsonObject record_type;
 
   AddAccess(record_type, recordp->GetAccess());
@@ -173,14 +166,8 @@
   return record_type;
 }
 
-void IRToJsonConverter::AddFunctionParametersAndSetReturnType(
-    JsonObject &function, const CFunctionLikeIR *cfunction_like_ir) {
-  function.Set("return_type", cfunction_like_ir->GetReturnType());
-  AddFunctionParameters(function, cfunction_like_ir);
-}
-
-void IRToJsonConverter::AddFunctionParameters(
-    JsonObject &function, const CFunctionLikeIR *cfunction_like_ir) {
+static void AddFunctionParameters(JsonObject &function,
+                                  const CFunctionLikeIR *cfunction_like_ir) {
   JsonArray parameters;
   for (auto &&parameter_ir : cfunction_like_ir->GetParameters()) {
     JsonObject parameter;
@@ -192,15 +179,20 @@
   function.Set("parameters", parameters);
 }
 
-JsonObject
-IRToJsonConverter::ConvertFunctionTypeIR(const FunctionTypeIR *function_typep) {
+static void AddFunctionParametersAndSetReturnType(
+    JsonObject &function, const CFunctionLikeIR *cfunction_like_ir) {
+  function.Set("return_type", cfunction_like_ir->GetReturnType());
+  AddFunctionParameters(function, cfunction_like_ir);
+}
+
+static JsonObject ConvertFunctionTypeIR(const FunctionTypeIR *function_typep) {
   JsonObject function_type;
   AddTypeInfo(function_type, function_typep);
   AddFunctionParametersAndSetReturnType(function_type, function_typep);
   return function_type;
 }
 
-JsonObject IRToJsonConverter::ConvertFunctionIR(const FunctionIR *functionp) {
+static JsonObject ConvertFunctionIR(const FunctionIR *functionp) {
   JsonObject function;
   AddAccess(function, functionp->GetAccess());
   function.Set("linker_set_key", functionp->GetLinkerSetKey());
@@ -224,8 +216,7 @@
   return enum_field;
 }
 
-void IRToJsonConverter::AddEnumFields(JsonObject &enum_type,
-                                      const EnumTypeIR *enum_ir) {
+static void AddEnumFields(JsonObject &enum_type, const EnumTypeIR *enum_ir) {
   JsonArray enum_fields;
   for (auto &&field : enum_ir->GetFields()) {
     enum_fields.append(ConvertEnumFieldIR(&field));
@@ -233,7 +224,7 @@
   enum_type.Set("enum_fields", enum_fields);
 }
 
-JsonObject IRToJsonConverter::ConvertEnumTypeIR(const EnumTypeIR *enump) {
+static JsonObject ConvertEnumTypeIR(const EnumTypeIR *enump) {
   JsonObject enum_type;
   AddAccess(enum_type, enump->GetAccess());
   enum_type.Set("underlying_type", enump->GetUnderlyingType());
@@ -242,8 +233,7 @@
   return enum_type;
 }
 
-JsonObject
-IRToJsonConverter::ConvertGlobalVarIR(const GlobalVarIR *global_varp) {
+static JsonObject ConvertGlobalVarIR(const GlobalVarIR *global_varp) {
   JsonObject global_var;
   // GlobalVarIR
   global_var.Set("name", global_varp->GetName());
@@ -260,15 +250,13 @@
   return global_var;
 }
 
-JsonObject
-IRToJsonConverter::ConvertPointerTypeIR(const PointerTypeIR *pointerp) {
+static JsonObject ConvertPointerTypeIR(const PointerTypeIR *pointerp) {
   JsonObject pointer_type;
   AddTypeInfo(pointer_type, pointerp);
   return pointer_type;
 }
 
-JsonObject
-IRToJsonConverter::ConvertQualifiedTypeIR(const QualifiedTypeIR *qualtypep) {
+static JsonObject ConvertQualifiedTypeIR(const QualifiedTypeIR *qualtypep) {
   JsonObject qualified_type;
   AddTypeInfo(qualified_type, qualtypep);
   qualified_type.Set("is_const", qualtypep->IsConst());
@@ -277,8 +265,7 @@
   return qualified_type;
 }
 
-JsonObject
-IRToJsonConverter::ConvertBuiltinTypeIR(const BuiltinTypeIR *builtin_typep) {
+static JsonObject ConvertBuiltinTypeIR(const BuiltinTypeIR *builtin_typep) {
   JsonObject builtin_type;
   builtin_type.Set("is_unsigned", builtin_typep->IsUnsigned());
   builtin_type.Set("is_integral", builtin_typep->IsIntegralType());
@@ -286,22 +273,21 @@
   return builtin_type;
 }
 
-JsonObject
-IRToJsonConverter::ConvertArrayTypeIR(const ArrayTypeIR *array_typep) {
+static JsonObject ConvertArrayTypeIR(const ArrayTypeIR *array_typep) {
   JsonObject array_type;
   array_type.Set("is_of_unknown_bound", array_typep->IsOfUnknownBound());
   AddTypeInfo(array_type, array_typep);
   return array_type;
 }
 
-JsonObject IRToJsonConverter::ConvertLvalueReferenceTypeIR(
+static JsonObject ConvertLvalueReferenceTypeIR(
     const LvalueReferenceTypeIR *lvalue_reference_typep) {
   JsonObject lvalue_reference_type;
   AddTypeInfo(lvalue_reference_type, lvalue_reference_typep);
   return lvalue_reference_type;
 }
 
-JsonObject IRToJsonConverter::ConvertRvalueReferenceTypeIR(
+static JsonObject ConvertRvalueReferenceTypeIR(
     const RvalueReferenceTypeIR *rvalue_reference_typep) {
   JsonObject rvalue_reference_type;
   AddTypeInfo(rvalue_reference_type, rvalue_reference_typep);
diff --git a/vndk/tools/header-checker/src/repr/json/ir_dumper.h b/vndk/tools/header-checker/src/repr/json/ir_dumper.h
index dae290a..ccebfb2 100644
--- a/vndk/tools/header-checker/src/repr/json/ir_dumper.h
+++ b/vndk/tools/header-checker/src/repr/json/ir_dumper.h
@@ -16,7 +16,6 @@
 #define HEADER_CHECKER_REPR_JSON_IR_DUMPER_H_
 
 #include "repr/ir_dumper.h"
-#include "repr/ir_reader.h"
 #include "repr/ir_representation.h"
 #include "repr/json/converter.h"
 
@@ -25,58 +24,7 @@
 namespace repr {
 
 
-class IRToJsonConverter {
- private:
-  static void AddTemplateInfo(JsonObject &type_decl,
-                              const TemplatedArtifactIR *template_ir);
-
-  // BasicNamedAndTypedDecl
-  static void AddTypeInfo(JsonObject &type_decl, const TypeIR *type_ir);
-
-  static void AddRecordFields(JsonObject &record_type,
-                              const RecordTypeIR *record_ir);
-
-  static void AddBaseSpecifiers(JsonObject &record_type,
-                                const RecordTypeIR *record_ir);
-
-  static void AddVTableLayout(JsonObject &record_type,
-                              const RecordTypeIR *record_ir);
-
-  static void AddEnumFields(JsonObject &enum_type, const EnumTypeIR *enum_ir);
-
- public:
-  static JsonObject ConvertEnumTypeIR(const EnumTypeIR *enump);
-
-  static JsonObject ConvertRecordTypeIR(const RecordTypeIR *recordp);
-
-  static JsonObject ConvertFunctionTypeIR(const FunctionTypeIR *function_typep);
-
-  static void AddFunctionParametersAndSetReturnType(
-      JsonObject &function, const CFunctionLikeIR *cfunction_like_ir);
-
-  static void AddFunctionParameters(JsonObject &function,
-                                    const CFunctionLikeIR *cfunction_like_ir);
-
-  static JsonObject ConvertFunctionIR(const FunctionIR *functionp);
-
-  static JsonObject ConvertGlobalVarIR(const GlobalVarIR *global_varp);
-
-  static JsonObject ConvertPointerTypeIR(const PointerTypeIR *pointerp);
-
-  static JsonObject ConvertQualifiedTypeIR(const QualifiedTypeIR *qualtypep);
-
-  static JsonObject ConvertBuiltinTypeIR(const BuiltinTypeIR *builtin_typep);
-
-  static JsonObject ConvertArrayTypeIR(const ArrayTypeIR *array_typep);
-
-  static JsonObject ConvertLvalueReferenceTypeIR(
-      const LvalueReferenceTypeIR *lvalue_reference_typep);
-
-  static JsonObject ConvertRvalueReferenceTypeIR(
-      const RvalueReferenceTypeIR *rvalue_reference_typep);
-};
-
-class JsonIRDumper : public IRDumper, public IRToJsonConverter {
+class JsonIRDumper : public IRDumper {
  public:
   JsonIRDumper(const std::string &dump_path);
 
diff --git a/vndk/tools/header-checker/src/repr/protobuf/converter.cpp b/vndk/tools/header-checker/src/repr/protobuf/converter.cpp
deleted file mode 100644
index 3bf620d..0000000
--- a/vndk/tools/header-checker/src/repr/protobuf/converter.cpp
+++ /dev/null
@@ -1,295 +0,0 @@
-// Copyright (C) 2019 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#include "repr/protobuf/converter.h"
-
-#include <llvm/Support/raw_ostream.h>
-
-#include <fstream>
-#include <iostream>
-#include <memory>
-#include <string>
-
-
-namespace header_checker {
-namespace repr {
-
-
-bool IRDiffToProtobufConverter::AddTypeInfoDiff(
-    abi_diff::TypeInfoDiff *type_info_diff_protobuf,
-    const TypeDiffIR *type_diff_ir) {
-  abi_diff::TypeInfo *old_type_info_protobuf =
-      type_info_diff_protobuf->mutable_old_type_info();
-  abi_diff::TypeInfo *new_type_info_protobuf =
-      type_info_diff_protobuf->mutable_new_type_info();
-  if (old_type_info_protobuf == nullptr || new_type_info_protobuf == nullptr) {
-    return false;
-  }
-  const std::pair<uint64_t, uint64_t> &sizes = type_diff_ir->GetSizes();
-  const std::pair<uint32_t, uint32_t> &alignments =
-      type_diff_ir->GetAlignments();
-  old_type_info_protobuf->set_size(sizes.first);
-  new_type_info_protobuf->set_size(sizes.second);
-
-  old_type_info_protobuf->set_alignment(alignments.first);
-  new_type_info_protobuf->set_alignment(alignments.second);
-  return true;
-}
-
-bool IRDiffToProtobufConverter::AddVTableLayoutDiff(
-    abi_diff::VTableLayoutDiff *vtable_layout_diff_protobuf,
-    const VTableLayoutDiffIR *vtable_layout_diff_ir) {
-  abi_dump:: VTableLayout *old_vtable =
-      vtable_layout_diff_protobuf->mutable_old_vtable();
-  abi_dump:: VTableLayout *new_vtable =
-      vtable_layout_diff_protobuf->mutable_new_vtable();
-  if (old_vtable == nullptr || new_vtable == nullptr ||
-      !IRToProtobufConverter::ConvertVTableLayoutIR(
-          old_vtable, vtable_layout_diff_ir->GetOldVTable()) ||
-      !IRToProtobufConverter::ConvertVTableLayoutIR(
-          new_vtable, vtable_layout_diff_ir->GetNewVTable())) {
-    return false;
-  }
-  return true;
-}
-
-static bool CopyBaseSpecifiersDiffIRToProtobuf(
-    google::protobuf::RepeatedPtrField<abi_dump::CXXBaseSpecifier> *dst,
-    const std::vector<CXXBaseSpecifierIR> &bases_ir) {
-  for (auto &&base_ir : bases_ir) {
-    abi_dump::CXXBaseSpecifier *added_base = dst->Add();
-    if (!IRToProtobufConverter::ConvertCXXBaseSpecifierIR(added_base,
-                                                          base_ir)) {
-      return false;
-    }
-  }
-  return true;
-}
-
-bool IRDiffToProtobufConverter::AddBaseSpecifierDiffs(
-    abi_diff::CXXBaseSpecifierDiff *base_specifiers_diff_protobuf,
-    const CXXBaseSpecifierDiffIR *base_specifiers_diff_ir) {
-  if (!CopyBaseSpecifiersDiffIRToProtobuf(
-          base_specifiers_diff_protobuf->mutable_old_bases(),
-          base_specifiers_diff_ir->GetOldBases()) ||
-      !CopyBaseSpecifiersDiffIRToProtobuf(
-          base_specifiers_diff_protobuf->mutable_new_bases(),
-          base_specifiers_diff_ir->GetNewBases())) {
-    return false;
-  }
-  return true;
-}
-
-bool IRDiffToProtobufConverter::AddRecordFields(
-    abi_diff::RecordTypeDiff *record_diff_protobuf,
-    const std::vector<const RecordFieldIR *> &record_fields_ir,
-    bool field_removed) {
-  for (auto &&record_field_ir : record_fields_ir) {
-    abi_dump::RecordFieldDecl *field = nullptr;
-    if (field_removed) {
-      field = record_diff_protobuf->add_fields_removed();
-    } else {
-      field = record_diff_protobuf->add_fields_added();
-    }
-    if (!IRToProtobufConverter::ConvertRecordFieldIR(field, record_field_ir)) {
-      return false;
-    }
-  }
-  return true;
-}
-
-bool IRDiffToProtobufConverter::AddRecordFieldDiffs(
-    abi_diff::RecordTypeDiff *record_diff_protobuf,
-    const std::vector<RecordFieldDiffIR> &record_field_diffs_ir) {
-  for (auto &&record_field_diff_ir : record_field_diffs_ir) {
-    abi_diff::RecordFieldDeclDiff *record_field_diff =
-        record_diff_protobuf->add_fields_diff();
-    if (record_field_diff == nullptr) {
-      return false;
-    }
-    abi_dump::RecordFieldDecl *old_field =
-        record_field_diff->mutable_old_field();
-    abi_dump::RecordFieldDecl *new_field =
-        record_field_diff->mutable_new_field();
-    if (old_field == nullptr || new_field == nullptr) {
-      return false;
-    }
-    IRToProtobufConverter::ConvertRecordFieldIR(
-        old_field, record_field_diff_ir.GetOldField());
-    IRToProtobufConverter::ConvertRecordFieldIR(
-        new_field, record_field_diff_ir.GetNewField());
-  }
-  return true;
-}
-
-abi_diff::RecordTypeDiff IRDiffToProtobufConverter::ConvertRecordTypeDiffIR(
-    const RecordTypeDiffIR *record_type_diff_ir) {
-  abi_diff::RecordTypeDiff record_type_diff_protobuf;
-  record_type_diff_protobuf.set_name(record_type_diff_ir->GetName());
-  record_type_diff_protobuf.set_linker_set_key(
-      record_type_diff_ir->GetLinkerSetKey());
-  // If a type_info diff exists
-  const TypeDiffIR *type_diff_ir = record_type_diff_ir->GetTypeDiff();
-  if (type_diff_ir != nullptr) {
-    abi_diff::TypeInfoDiff *type_info_diff =
-        record_type_diff_protobuf.mutable_type_info_diff();
-    if (!AddTypeInfoDiff(type_info_diff, type_diff_ir)) {
-      llvm::errs() << "RecordType could not be converted\n";
-      ::exit(1);
-    }
-  }
-  // If vtables differ.
-  const VTableLayoutDiffIR *vtable_layout_diff_ir =
-      record_type_diff_ir->GetVTableLayoutDiff();
-  if (vtable_layout_diff_ir != nullptr) {
-    abi_diff::VTableLayoutDiff *vtable_layout_diff_protobuf =
-        record_type_diff_protobuf.mutable_vtable_layout_diff();
-    if (!AddVTableLayoutDiff(vtable_layout_diff_protobuf,
-                             vtable_layout_diff_ir)) {
-      llvm::errs() << "VTable layout diff could not be added\n";
-      ::exit(1);
-    }
-  }
-  // If base specifiers differ.
-  const CXXBaseSpecifierDiffIR *base_specifier_diff_ir =
-      record_type_diff_ir->GetBaseSpecifiers();
-  if (base_specifier_diff_ir != nullptr) {
-    abi_diff::CXXBaseSpecifierDiff *base_specifier_diff_protobuf =
-        record_type_diff_protobuf.mutable_bases_diff();
-    if (!AddBaseSpecifierDiffs(base_specifier_diff_protobuf,
-                               base_specifier_diff_ir)) {
-      llvm::errs() << "Base Specifier diff could not be added\n";
-      ::exit(1);
-    }
-  }
-  // Field diffs
-  if (!AddRecordFields(&record_type_diff_protobuf,
-                       record_type_diff_ir->GetFieldsRemoved(), true) ||
-      !AddRecordFields(&record_type_diff_protobuf,
-                       record_type_diff_ir->GetFieldsAdded(), false) ||
-      !AddRecordFieldDiffs(&record_type_diff_protobuf,
-                           record_type_diff_ir->GetFieldDiffs())) {
-    llvm::errs() << "Record Field diff could not be added\n";
-    ::exit(1);
-  }
-  return record_type_diff_protobuf;
-}
-
-bool IRDiffToProtobufConverter::AddEnumUnderlyingTypeDiff(
-    abi_diff::UnderlyingTypeDiff *underlying_type_diff_protobuf,
-    const std::pair<std::string, std::string> *underlying_type_diff_ir) {
-  if (underlying_type_diff_protobuf == nullptr) {
-    return false;
-  }
-  underlying_type_diff_protobuf->set_old_type(underlying_type_diff_ir->first);
-  underlying_type_diff_protobuf->set_new_type(underlying_type_diff_ir->second);
-  return true;
-}
-
-static bool AddEnumFields(
-    google::protobuf::RepeatedPtrField<abi_dump::EnumFieldDecl> *dst,
-    const std::vector<const EnumFieldIR *> &enum_fields) {
-  for (auto &&enum_field : enum_fields) {
-    abi_dump::EnumFieldDecl *added_enum_field = dst->Add();
-    if (!IRToProtobufConverter::ConvertEnumFieldIR(added_enum_field,
-                                                   enum_field)) {
-      return false;
-    }
-  }
-  return true;
-}
-
-static bool AddEnumFieldDiffs(
-    google::protobuf::RepeatedPtrField<abi_diff::EnumFieldDeclDiff> *dst,
-    const std::vector<EnumFieldDiffIR> &fields_diff_ir) {
-  for (auto &&field_diff_ir : fields_diff_ir) {
-    abi_diff::EnumFieldDeclDiff *field_diff_protobuf = dst->Add();
-    if (field_diff_protobuf == nullptr) {
-      return false;
-    }
-    if (!IRToProtobufConverter::ConvertEnumFieldIR(
-            field_diff_protobuf->mutable_old_field(),
-            field_diff_ir.GetOldField()) ||
-        !IRToProtobufConverter::ConvertEnumFieldIR(
-            field_diff_protobuf->mutable_new_field(),
-            field_diff_ir.GetNewField())) {
-      return false;
-    }
-  }
-  return true;
-}
-
-abi_diff::EnumTypeDiff IRDiffToProtobufConverter::ConvertEnumTypeDiffIR(
-    const EnumTypeDiffIR *enum_type_diff_ir) {
-  abi_diff::EnumTypeDiff enum_type_diff_protobuf;
-  enum_type_diff_protobuf.set_name(enum_type_diff_ir->GetName());
-  enum_type_diff_protobuf.set_linker_set_key(
-      enum_type_diff_ir->GetLinkerSetKey());
-  const std::pair<std::string, std::string> *underlying_type_diff =
-      enum_type_diff_ir->GetUnderlyingTypeDiff();
-  if ((underlying_type_diff != nullptr &&
-       !AddEnumUnderlyingTypeDiff(
-           enum_type_diff_protobuf.mutable_underlying_type_diff(),
-           underlying_type_diff)) ||
-      !AddEnumFields(enum_type_diff_protobuf.mutable_fields_removed(),
-                     enum_type_diff_ir->GetFieldsRemoved()) ||
-      !AddEnumFields(enum_type_diff_protobuf.mutable_fields_added(),
-                     enum_type_diff_ir->GetFieldsAdded()) ||
-      !AddEnumFieldDiffs(enum_type_diff_protobuf.mutable_fields_diff(),
-                         enum_type_diff_ir->GetFieldsDiff())) {
-    llvm::errs() << "Enum field diff could not be added\n";
-    ::exit(1);
-  }
-  return enum_type_diff_protobuf;
-}
-
-abi_diff::GlobalVarDeclDiff IRDiffToProtobufConverter::ConvertGlobalVarDiffIR(
-    const GlobalVarDiffIR *global_var_diff_ir) {
-  abi_diff::GlobalVarDeclDiff global_var_diff;
-  global_var_diff.set_name(global_var_diff_ir->GetName());
-  abi_dump::GlobalVarDecl *old_global_var = global_var_diff.mutable_old();
-  abi_dump::GlobalVarDecl *new_global_var = global_var_diff.mutable_new_();
-  if (old_global_var == nullptr || new_global_var == nullptr) {
-    llvm::errs() << "Globar Var diff could not be added\n";
-    ::exit(1);
-  }
-  *old_global_var =
-      IRToProtobufConverter::ConvertGlobalVarIR(
-          global_var_diff_ir->GetOldGlobalVar());
-  *new_global_var =
-      IRToProtobufConverter::ConvertGlobalVarIR(
-          global_var_diff_ir->GetNewGlobalVar());
-  return global_var_diff;
-}
-
-abi_diff::FunctionDeclDiff IRDiffToProtobufConverter::ConvertFunctionDiffIR(
-    const FunctionDiffIR *function_diff_ir) {
-  abi_diff::FunctionDeclDiff function_diff;
-  function_diff.set_name(function_diff_ir->GetName());
-  abi_dump::FunctionDecl *old_function = function_diff.mutable_old();
-  abi_dump::FunctionDecl *new_function = function_diff.mutable_new_();
-  if (old_function == nullptr || new_function == nullptr) {
-    llvm::errs() << "Function diff could not be added\n";
-    ::exit(1);
-  }
-  *old_function = IRToProtobufConverter::ConvertFunctionIR(
-      function_diff_ir->GetOldFunction());
-  *new_function = IRToProtobufConverter::ConvertFunctionIR(
-      function_diff_ir->GetNewFunction());
-  return function_diff;
-}
-
-
-}  // namespace repr
-}  // namespace header_checker
diff --git a/vndk/tools/header-checker/src/repr/protobuf/converter.h b/vndk/tools/header-checker/src/repr/protobuf/converter.h
index 7325951..d24be23 100644
--- a/vndk/tools/header-checker/src/repr/protobuf/converter.h
+++ b/vndk/tools/header-checker/src/repr/protobuf/converter.h
@@ -271,48 +271,6 @@
       const ElfObjectIR *elf_object_ir);
 };
 
-// Convert IR to the messages defined in abi_diff.proto.
-class IRDiffToProtobufConverter {
- private:
-  static bool AddTypeInfoDiff(
-      abi_diff::TypeInfoDiff *type_info_diff_protobuf,
-      const TypeDiffIR *type_diff_ir);
-
-  static bool AddVTableLayoutDiff(
-      abi_diff::VTableLayoutDiff *vtable_layout_diff_protobuf,
-      const VTableLayoutDiffIR *vtable_layout_diff_ir);
-
-  static bool AddBaseSpecifierDiffs(
-      abi_diff::CXXBaseSpecifierDiff *base_specifier_diff_protobuf,
-      const CXXBaseSpecifierDiffIR *base_specifier_diff_ir);
-
-  static bool AddRecordFields(
-      abi_diff::RecordTypeDiff *record_diff_protobuf,
-      const std::vector<const RecordFieldIR *> &record_fields_removed_ir,
-      bool removed);
-
-  static bool AddRecordFieldDiffs(
-      abi_diff::RecordTypeDiff *record_diff_protobuf,
-      const std::vector<RecordFieldDiffIR> &record_field_diff_ir);
-
-  static bool AddEnumUnderlyingTypeDiff(
-      abi_diff::UnderlyingTypeDiff *underlying_type_diff_protobuf,
-      const std::pair<std::string, std::string> *underlying_type_diff_ir);
-
- public:
-  static abi_diff::RecordTypeDiff ConvertRecordTypeDiffIR(
-      const RecordTypeDiffIR *record_type_diffp);
-
-  static abi_diff::EnumTypeDiff ConvertEnumTypeDiffIR(
-      const EnumTypeDiffIR *enum_type_diffp);
-
-  static abi_diff::FunctionDeclDiff ConvertFunctionDiffIR(
-      const FunctionDiffIR *function_diffp);
-
-  static abi_diff::GlobalVarDeclDiff ConvertGlobalVarDiffIR(
-      const GlobalVarDiffIR *global_var_diffp);
-};
-
 
 }  // namespace repr
 }  // namespace header_checker
diff --git a/vndk/tools/header-checker/src/repr/protobuf/ir_diff_dumper.cpp b/vndk/tools/header-checker/src/repr/protobuf/ir_diff_dumper.cpp
index 0dab87b..da4e5a7 100644
--- a/vndk/tools/header-checker/src/repr/protobuf/ir_diff_dumper.cpp
+++ b/vndk/tools/header-checker/src/repr/protobuf/ir_diff_dumper.cpp
@@ -31,6 +31,266 @@
 namespace header_checker {
 namespace repr {
 
+static bool AddTypeInfoDiff(abi_diff::TypeInfoDiff *type_info_diff_protobuf,
+                            const TypeDiffIR *type_diff_ir) {
+  abi_diff::TypeInfo *old_type_info_protobuf =
+      type_info_diff_protobuf->mutable_old_type_info();
+  abi_diff::TypeInfo *new_type_info_protobuf =
+      type_info_diff_protobuf->mutable_new_type_info();
+  if (old_type_info_protobuf == nullptr || new_type_info_protobuf == nullptr) {
+    return false;
+  }
+  const std::pair<uint64_t, uint64_t> &sizes = type_diff_ir->GetSizes();
+  const std::pair<uint32_t, uint32_t> &alignments =
+      type_diff_ir->GetAlignments();
+  old_type_info_protobuf->set_size(sizes.first);
+  new_type_info_protobuf->set_size(sizes.second);
+
+  old_type_info_protobuf->set_alignment(alignments.first);
+  new_type_info_protobuf->set_alignment(alignments.second);
+  return true;
+}
+
+static bool AddVTableLayoutDiff(
+    abi_diff::VTableLayoutDiff *vtable_layout_diff_protobuf,
+    const VTableLayoutDiffIR *vtable_layout_diff_ir) {
+  abi_dump::VTableLayout *old_vtable =
+      vtable_layout_diff_protobuf->mutable_old_vtable();
+  abi_dump::VTableLayout *new_vtable =
+      vtable_layout_diff_protobuf->mutable_new_vtable();
+  if (old_vtable == nullptr || new_vtable == nullptr ||
+      !IRToProtobufConverter::ConvertVTableLayoutIR(
+          old_vtable, vtable_layout_diff_ir->GetOldVTable()) ||
+      !IRToProtobufConverter::ConvertVTableLayoutIR(
+          new_vtable, vtable_layout_diff_ir->GetNewVTable())) {
+    return false;
+  }
+  return true;
+}
+
+static bool CopyBaseSpecifiersDiffIRToProtobuf(
+    google::protobuf::RepeatedPtrField<abi_dump::CXXBaseSpecifier> *dst,
+    const std::vector<CXXBaseSpecifierIR> &bases_ir) {
+  for (auto &&base_ir : bases_ir) {
+    abi_dump::CXXBaseSpecifier *added_base = dst->Add();
+    if (!IRToProtobufConverter::ConvertCXXBaseSpecifierIR(added_base,
+                                                          base_ir)) {
+      return false;
+    }
+  }
+  return true;
+}
+
+static bool AddBaseSpecifierDiffs(
+    abi_diff::CXXBaseSpecifierDiff *base_specifiers_diff_protobuf,
+    const CXXBaseSpecifierDiffIR *base_specifiers_diff_ir) {
+  if (!CopyBaseSpecifiersDiffIRToProtobuf(
+          base_specifiers_diff_protobuf->mutable_old_bases(),
+          base_specifiers_diff_ir->GetOldBases()) ||
+      !CopyBaseSpecifiersDiffIRToProtobuf(
+          base_specifiers_diff_protobuf->mutable_new_bases(),
+          base_specifiers_diff_ir->GetNewBases())) {
+    return false;
+  }
+  return true;
+}
+
+static bool AddRecordFields(
+    abi_diff::RecordTypeDiff *record_diff_protobuf,
+    const std::vector<const RecordFieldIR *> &record_fields_ir,
+    bool field_removed) {
+  for (auto &&record_field_ir : record_fields_ir) {
+    abi_dump::RecordFieldDecl *field = nullptr;
+    if (field_removed) {
+      field = record_diff_protobuf->add_fields_removed();
+    } else {
+      field = record_diff_protobuf->add_fields_added();
+    }
+    if (!IRToProtobufConverter::ConvertRecordFieldIR(field, record_field_ir)) {
+      return false;
+    }
+  }
+  return true;
+}
+
+static bool AddRecordFieldDiffs(
+    abi_diff::RecordTypeDiff *record_diff_protobuf,
+    const std::vector<RecordFieldDiffIR> &record_field_diffs_ir) {
+  for (auto &&record_field_diff_ir : record_field_diffs_ir) {
+    abi_diff::RecordFieldDeclDiff *record_field_diff =
+        record_diff_protobuf->add_fields_diff();
+    if (record_field_diff == nullptr) {
+      return false;
+    }
+    abi_dump::RecordFieldDecl *old_field =
+        record_field_diff->mutable_old_field();
+    abi_dump::RecordFieldDecl *new_field =
+        record_field_diff->mutable_new_field();
+    if (old_field == nullptr || new_field == nullptr) {
+      return false;
+    }
+    IRToProtobufConverter::ConvertRecordFieldIR(
+        old_field, record_field_diff_ir.GetOldField());
+    IRToProtobufConverter::ConvertRecordFieldIR(
+        new_field, record_field_diff_ir.GetNewField());
+  }
+  return true;
+}
+
+static abi_diff::RecordTypeDiff ConvertRecordTypeDiffIR(
+    const RecordTypeDiffIR *record_type_diff_ir) {
+  abi_diff::RecordTypeDiff record_type_diff_protobuf;
+  record_type_diff_protobuf.set_name(record_type_diff_ir->GetName());
+  record_type_diff_protobuf.set_linker_set_key(
+      record_type_diff_ir->GetLinkerSetKey());
+  // If a type_info diff exists
+  const TypeDiffIR *type_diff_ir = record_type_diff_ir->GetTypeDiff();
+  if (type_diff_ir != nullptr) {
+    abi_diff::TypeInfoDiff *type_info_diff =
+        record_type_diff_protobuf.mutable_type_info_diff();
+    if (!AddTypeInfoDiff(type_info_diff, type_diff_ir)) {
+      llvm::errs() << "RecordType could not be converted\n";
+      ::exit(1);
+    }
+  }
+  // If vtables differ.
+  const VTableLayoutDiffIR *vtable_layout_diff_ir =
+      record_type_diff_ir->GetVTableLayoutDiff();
+  if (vtable_layout_diff_ir != nullptr) {
+    abi_diff::VTableLayoutDiff *vtable_layout_diff_protobuf =
+        record_type_diff_protobuf.mutable_vtable_layout_diff();
+    if (!AddVTableLayoutDiff(vtable_layout_diff_protobuf,
+                             vtable_layout_diff_ir)) {
+      llvm::errs() << "VTable layout diff could not be added\n";
+      ::exit(1);
+    }
+  }
+  // If base specifiers differ.
+  const CXXBaseSpecifierDiffIR *base_specifier_diff_ir =
+      record_type_diff_ir->GetBaseSpecifiers();
+  if (base_specifier_diff_ir != nullptr) {
+    abi_diff::CXXBaseSpecifierDiff *base_specifier_diff_protobuf =
+        record_type_diff_protobuf.mutable_bases_diff();
+    if (!AddBaseSpecifierDiffs(base_specifier_diff_protobuf,
+                               base_specifier_diff_ir)) {
+      llvm::errs() << "Base Specifier diff could not be added\n";
+      ::exit(1);
+    }
+  }
+  // Field diffs
+  if (!AddRecordFields(&record_type_diff_protobuf,
+                       record_type_diff_ir->GetFieldsRemoved(), true) ||
+      !AddRecordFields(&record_type_diff_protobuf,
+                       record_type_diff_ir->GetFieldsAdded(), false) ||
+      !AddRecordFieldDiffs(&record_type_diff_protobuf,
+                           record_type_diff_ir->GetFieldDiffs())) {
+    llvm::errs() << "Record Field diff could not be added\n";
+    ::exit(1);
+  }
+  return record_type_diff_protobuf;
+}
+
+static bool AddEnumUnderlyingTypeDiff(
+    abi_diff::UnderlyingTypeDiff *underlying_type_diff_protobuf,
+    const std::pair<std::string, std::string> *underlying_type_diff_ir) {
+  if (underlying_type_diff_protobuf == nullptr) {
+    return false;
+  }
+  underlying_type_diff_protobuf->set_old_type(underlying_type_diff_ir->first);
+  underlying_type_diff_protobuf->set_new_type(underlying_type_diff_ir->second);
+  return true;
+}
+
+static bool AddEnumFields(
+    google::protobuf::RepeatedPtrField<abi_dump::EnumFieldDecl> *dst,
+    const std::vector<const EnumFieldIR *> &enum_fields) {
+  for (auto &&enum_field : enum_fields) {
+    abi_dump::EnumFieldDecl *added_enum_field = dst->Add();
+    if (!IRToProtobufConverter::ConvertEnumFieldIR(added_enum_field,
+                                                   enum_field)) {
+      return false;
+    }
+  }
+  return true;
+}
+
+static bool AddEnumFieldDiffs(
+    google::protobuf::RepeatedPtrField<abi_diff::EnumFieldDeclDiff> *dst,
+    const std::vector<EnumFieldDiffIR> &fields_diff_ir) {
+  for (auto &&field_diff_ir : fields_diff_ir) {
+    abi_diff::EnumFieldDeclDiff *field_diff_protobuf = dst->Add();
+    if (field_diff_protobuf == nullptr) {
+      return false;
+    }
+    if (!IRToProtobufConverter::ConvertEnumFieldIR(
+            field_diff_protobuf->mutable_old_field(),
+            field_diff_ir.GetOldField()) ||
+        !IRToProtobufConverter::ConvertEnumFieldIR(
+            field_diff_protobuf->mutable_new_field(),
+            field_diff_ir.GetNewField())) {
+      return false;
+    }
+  }
+  return true;
+}
+
+static abi_diff::EnumTypeDiff ConvertEnumTypeDiffIR(
+    const EnumTypeDiffIR *enum_type_diff_ir) {
+  abi_diff::EnumTypeDiff enum_type_diff_protobuf;
+  enum_type_diff_protobuf.set_name(enum_type_diff_ir->GetName());
+  enum_type_diff_protobuf.set_linker_set_key(
+      enum_type_diff_ir->GetLinkerSetKey());
+  const std::pair<std::string, std::string> *underlying_type_diff =
+      enum_type_diff_ir->GetUnderlyingTypeDiff();
+  if ((underlying_type_diff != nullptr &&
+       !AddEnumUnderlyingTypeDiff(
+           enum_type_diff_protobuf.mutable_underlying_type_diff(),
+           underlying_type_diff)) ||
+      !AddEnumFields(enum_type_diff_protobuf.mutable_fields_removed(),
+                     enum_type_diff_ir->GetFieldsRemoved()) ||
+      !AddEnumFields(enum_type_diff_protobuf.mutable_fields_added(),
+                     enum_type_diff_ir->GetFieldsAdded()) ||
+      !AddEnumFieldDiffs(enum_type_diff_protobuf.mutable_fields_diff(),
+                         enum_type_diff_ir->GetFieldsDiff())) {
+    llvm::errs() << "Enum field diff could not be added\n";
+    ::exit(1);
+  }
+  return enum_type_diff_protobuf;
+}
+
+static abi_diff::GlobalVarDeclDiff ConvertGlobalVarDiffIR(
+    const GlobalVarDiffIR *global_var_diff_ir) {
+  abi_diff::GlobalVarDeclDiff global_var_diff;
+  global_var_diff.set_name(global_var_diff_ir->GetName());
+  abi_dump::GlobalVarDecl *old_global_var = global_var_diff.mutable_old();
+  abi_dump::GlobalVarDecl *new_global_var = global_var_diff.mutable_new_();
+  if (old_global_var == nullptr || new_global_var == nullptr) {
+    llvm::errs() << "Globar Var diff could not be added\n";
+    ::exit(1);
+  }
+  *old_global_var = IRToProtobufConverter::ConvertGlobalVarIR(
+      global_var_diff_ir->GetOldGlobalVar());
+  *new_global_var = IRToProtobufConverter::ConvertGlobalVarIR(
+      global_var_diff_ir->GetNewGlobalVar());
+  return global_var_diff;
+}
+
+static abi_diff::FunctionDeclDiff ConvertFunctionDiffIR(
+    const FunctionDiffIR *function_diff_ir) {
+  abi_diff::FunctionDeclDiff function_diff;
+  function_diff.set_name(function_diff_ir->GetName());
+  abi_dump::FunctionDecl *old_function = function_diff.mutable_old();
+  abi_dump::FunctionDecl *new_function = function_diff.mutable_new_();
+  if (old_function == nullptr || new_function == nullptr) {
+    llvm::errs() << "Function diff could not be added\n";
+    ::exit(1);
+  }
+  *old_function = IRToProtobufConverter::ConvertFunctionIR(
+      function_diff_ir->GetOldFunction());
+  *new_function = IRToProtobufConverter::ConvertFunctionIR(
+      function_diff_ir->GetNewFunction());
+  return function_diff;
+}
 
 void ProtobufIRDiffDumper::AddLibNameIR(const std::string &name) {
   diff_tu_->set_lib_name(name);
@@ -306,8 +566,7 @@
     return false;
   }
 
-  *added_record_type_diff =
-      IRDiffToProtobufConverter::ConvertRecordTypeDiffIR(record_diff_ir);
+  *added_record_type_diff = ConvertRecordTypeDiffIR(record_diff_ir);
   added_record_type_diff->set_type_stack(type_stack);
   return true;
 }
@@ -321,8 +580,7 @@
   if (!added_function_diff) {
     return false;
   }
-  *added_function_diff =
-      IRDiffToProtobufConverter::ConvertFunctionDiffIR(function_diff_ir);
+  *added_function_diff = ConvertFunctionDiffIR(function_diff_ir);
   return true;
 }
 
@@ -355,8 +613,7 @@
   if (!added_enum_type_diff) {
     return false;
   }
-  *added_enum_type_diff =
-      IRDiffToProtobufConverter::ConvertEnumTypeDiffIR(enum_diff_ir);
+  *added_enum_type_diff = ConvertEnumTypeDiffIR(enum_diff_ir);
   added_enum_type_diff->set_type_stack(type_stack);
   return true;
 }
@@ -369,8 +626,7 @@
   if (!added_global_var_diff) {
     return false;
   }
-  *added_global_var_diff =
-      IRDiffToProtobufConverter::ConvertGlobalVarDiffIR(global_var_diff_ir);
+  *added_global_var_diff = ConvertGlobalVarDiffIR(global_var_diff_ir);
   return true;
 }