14#include "llvm/ADT/iterator_range.h"
15#include "llvm/Support/Error.h"
16#include "llvm/Support/JSON.h"
27llvm::iterator_range<EdgeSet::const_iterator>
31constexpr const char *
const PointerFlowKey =
"PointerFlow";
41 llvm::iterator_range<EdgeSet::const_iterator> Edges,
45 for (
const auto &[LHS, RHSSet] : Edges) {
48 for (
const auto &RHS : RHSSet)
50 EdgesData.push_back(
Value(std::move(EdgeEntry)));
60 for (
const auto &EdgesEntryData : EdgesData) {
61 const auto *EPLArray = EdgesEntryData.getAsArray();
63 if (!EPLArray || EPLArray->size() <= 1)
65 EdgesEntryData,
"a JSON array of EntityPointerLevels with a size "
66 "greater than 1: [src, dest, dest, ...]");
72 return SrcEPL.takeError();
73 for (
const auto &EPLData :
74 llvm::make_range(EPLArray->begin() + 1, EPLArray->end())) {
77 return EPL.takeError();
78 Edges[*SrcEPL].insert(*EPL);
84static llvm::json::Object
97 const Value *EdgesData =
Data.get(PointerFlowKey);
101 Object(
Data),
"a JSON object with the key: %s", PointerFlowKey);
103 const auto *EdgesDataAsArr = EdgesData->getAsArray();
107 *EdgesData,
"a JSON array of array of EntityPointerLevels");
112 return Edges.takeError();
113 return std::make_unique<PointerFlowEntitySummary>(
119 PointerFlowJSONFormatInfo()
120 : JSONFormat::FormatInfo(PointerFlowEntitySummary::summaryName(),
125static llvm::Registry<JSONFormat::FormatInfo>::Add<PointerFlowJSONFormatInfo>
127 "PointerFlow",
"JSON Format info for PointerFlowEntitySummary");
volatile int PointerFlowSSAFJSONFormatAnchorSource
Manages entity name interning and provides efficient EntityId handles.
Base class for analysis-specific summary data.
llvm::json::Array edgeSetToJSON(llvm::iterator_range< EdgeSet::const_iterator > Edges, JSONFormat::EntityIdToJSONFn IdToJSON)
Serialize an EdgeSet {(src1, dest1), (src1, dest2), (src2, dest3), (src2, dest4), ....
std::map< EntityPointerLevel, EntityPointerLevelSet > EdgeSet
Maps each source node to its destination nodes:
llvm::json::Value entityPointerLevelToJSON(const EntityPointerLevel &EPL, JSONFormat::EntityIdToJSONFn EntityId2JSON)
llvm::Error makeSawButExpectedError(const JSONTy &Saw, llvm::StringRef Expected, const Ts &...ExpectedArgs)
llvm::Expected< EdgeSet > edgeSetFromJSON(const llvm::json::Array &EdgesData, JSONFormat::EntityIdFromJSONFn IdFromJSON)
Deserialize an EdgeSet from the array format produced by edgeSetToJSON.
PointerFlowEntitySummary buildPointerFlowEntitySummary(EdgeSet Edges)
Expected< EntityPointerLevel > entityPointerLevelFromJSON(const llvm::json::Value &EPLData, JSONFormat::EntityIdFromJSONFn EntityIdFromJSON)
The JSON file list parser is used to communicate input to InstallAPI.