21#include "llvm/Support/Error.h"
22#include "llvm/Support/JSON.h"
36 for (
const auto &[Id, EntityEdges] :
R.Edges) {
37 Content.push_back(IdToJSON(Id));
38 Content.push_back(json::Value(
edgeSetToJSON(EntityEdges, IdToJSON)));
55 if (Content->size() % 2 != 0)
57 *Content,
"an even number of elements, got %lu", Content->size());
59 std::map<EntityId, EdgeSet> Edges;
61 for (
size_t I = 0; I < Content->size(); I += 2) {
62 const json::Object *IdData = (*Content)[I].getAsObject();
66 "an object representing EntityId");
68 auto Id = IdFromJSON(*IdData);
71 return Id.takeError();
73 const json::Array *EdgesData = (*Content)[I + 1].getAsArray();
77 "an array of arrays representing EdgeSet");
82 return EntityEdges.takeError();
83 Edges[*Id] = std::move(*EntityEdges);
86 auto Ret = std::make_unique<PointerFlowAnalysisResult>();
88 Ret->Edges = std::move(Edges);
92JSONFormat::AnalysisResultRegistry::Add<PointerFlowAnalysisResult>
93 RegisterPointerFlowResultForJSON(serializePointerFlowAnalysisResult,
94 deserializePointerFlowAnalysisResult);
96class PointerFlowAnalysis final
98 PointerFlowEntitySummary> {
100 llvm::Error add(EntityId Id,
101 const PointerFlowEntitySummary &Summary)
override {
102 auto EdgesOfEntity = getEdges(Summary);
104 getResult().Edges[Id] =
EdgeSet(EdgesOfEntity.begin(), EdgesOfEntity.end());
105 return llvm::Error::success();
110 RegisterPointerFlowAnalysis(
"Whole-program pointer flow analysis");
Result
Implement __builtin_bit_cast and related operations.
volatile int PointerFlowAnalysisAnchorSource
Typed intermediate that concrete summary analyses inherit from.
PRESERVE_NONE bool Ret(InterpState &S, CodePtr &PC)
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::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.
constexpr llvm::StringLiteral PointerFlowAnalysisResultName
Diagnostic wrappers for TextAPI types for error reporting.
Registers AnalysisT with the unified registry.