1//===- PointerFlowFormat.h --------------------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// JSON serialization helpers for EdgeSet (PointerFlow edge maps).
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_CLANG_SCALABLESTATICANALYSIS_ANALYSES_POINTERFLOW_POINTERFLOWFORMAT_H
14#define LLVM_CLANG_SCALABLESTATICANALYSIS_ANALYSES_POINTERFLOW_POINTERFLOWFORMAT_H
15
16#include "clang/ScalableStaticAnalysis/Analyses/PointerFlow/PointerFlow.h"
17#include "clang/ScalableStaticAnalysis/Core/Serialization/JSONFormat.h"
18#include "llvm/ADT/iterator_range.h"
19
20namespace clang::ssaf {
21
22/// Serialize an EdgeSet
23/// {(src1, dest1), (src1, dest2), (src2, dest3), (src2, dest4), ...}
24/// to an array of arrays of EntityPointerLevels:
25/// [ [src1, dest1, dest2, ...], [src2, dest3, dest4, ...], ... ]
26llvm::json::Array
27edgeSetToJSON(llvm::iterator_range<EdgeSet::const_iterator> Edges,
28 JSONFormat::EntityIdToJSONFn IdToJSON);
29
30/// Deserialize an EdgeSet from the array format produced by `edgeSetToJSON`.
31llvm::Expected<EdgeSet>
32edgeSetFromJSON(const llvm::json::Array &EdgesData,
33 JSONFormat::EntityIdFromJSONFn IdFromJSON);
34
35} // namespace clang::ssaf
36
37#endif // LLVM_CLANG_SCALABLESTATICANALYSIS_ANALYSES_POINTERFLOW_POINTERFLOWFORMAT_H
38