================
@@ -0,0 +1,131 @@
+//===- JSONFormat.h ---------------------------------------------*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// JSON serialization format implementation
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef CLANG_ANALYSIS_SCALABLE_SERIALIZATION_JSONFORMAT_H
+#define CLANG_ANALYSIS_SCALABLE_SERIALIZATION_JSONFORMAT_H
+
+#include "clang/Analysis/Scalable/Serialization/SerializationFormat.h"
+#include "llvm/ADT/STLFunctionalExtras.h"
+#include "llvm/Support/JSON.h"
+
+namespace clang::ssaf {
+
+class EntityIdTable;
+class EntitySummary;
+class SummaryName;
+
+class JSONFormat final : public SerializationFormat {
+  using Array = llvm::json::Array;
+  using Object = llvm::json::Object;
+
+public:
+  // Helper class to provide limited access to EntityId conversion methods
+  // Only exposes EntityId serialization/deserialization to format handlers
+  class EntityIdConverter {
+  public:
+    EntityId fromJSON(uint64_t EntityIdIndex) const {
+      return Format.entityIdFromJSON(EntityIdIndex);
+    }
+
+    uint64_t toJSON(EntityId EI) const { return Format.entityIdToJSON(EI); }
+
+  private:
+    friend class JSONFormat;
+    EntityIdConverter(const JSONFormat &Format) : Format(Format) {}
+    const JSONFormat &Format;
+  };
+
+  JSONFormat();
+
+  ~JSONFormat() = default;
+
+  llvm::Expected<TUSummary> readTUSummary(llvm::StringRef Path) override;
+
+  llvm::Error writeTUSummary(const TUSummary &Summary,
+                             llvm::StringRef Path) override;
+
+  using SerializerFn = llvm::function_ref<Object(const EntitySummary &,
+                                                 const EntityIdConverter &)>;
+  using DeserializerFn =
+      llvm::function_ref<llvm::Expected<std::unique_ptr<EntitySummary>>(
+          const Object &, EntityIdTable &, const EntityIdConverter &)>;
+
+  using FormatInfo = FormatInfoEntry<SerializerFn, DeserializerFn>;
+
+private:
+  std::map<SummaryName, FormatInfo> FormatInfos;
----------------
aviralg wrote:

Fixed in 
https://github.com/llvm/llvm-project/pull/180021/commits/2a8be113345f614387679fbffbd0c63c9a167e08

https://github.com/llvm/llvm-project/pull/180021
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to