| 1 | //===- JSONEntitySummaryEncoding.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 | // Opaque JSON-based entity summary encoding used by JSONFormat. Stores raw |
| 10 | // EntitySummary JSON blobs and patches embedded entity ID references without |
| 11 | // requiring knowledge of the analysis schema. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
| 15 | #ifndef LLVM_CLANG_LIB_SCALABLESTATICANALYSISFRAMEWORK_CORE_SERIALIZATION_JSONFORMAT_JSONENTITYSUMMARYENCODING_H |
| 16 | #define LLVM_CLANG_LIB_SCALABLESTATICANALYSISFRAMEWORK_CORE_SERIALIZATION_JSONFORMAT_JSONENTITYSUMMARYENCODING_H |
| 17 | |
| 18 | #include "clang/ScalableStaticAnalysisFramework/Core/EntityLinker/EntitySummaryEncoding.h" |
| 19 | #include "clang/ScalableStaticAnalysisFramework/Core/Serialization/JSONFormat.h" |
| 20 | #include "llvm/Support/JSON.h" |
| 21 | |
| 22 | #include <map> |
| 23 | |
| 24 | namespace clang::ssaf { |
| 25 | |
| 26 | class JSONEntitySummaryEncoding final : public EntitySummaryEncoding { |
| 27 | friend JSONFormat; |
| 28 | |
| 29 | public: |
| 30 | llvm::Error |
| 31 | patch(const std::map<EntityId, EntityId> &EntityResolutionTable) override; |
| 32 | |
| 33 | private: |
| 34 | explicit JSONEntitySummaryEncoding(llvm::json::Value Data) |
| 35 | : Data(std::move(Data)) {} |
| 36 | |
| 37 | llvm::Error patchEntityIdObject(llvm::json::Object &Obj, |
| 38 | const std::map<EntityId, EntityId> &Table, |
| 39 | llvm::json::Value *AtVal); |
| 40 | llvm::Error patchRegularObject(llvm::json::Object &Obj, |
| 41 | const std::map<EntityId, EntityId> &Table); |
| 42 | llvm::Error patchObject(llvm::json::Object &Obj, |
| 43 | const std::map<EntityId, EntityId> &Table); |
| 44 | llvm::Error patchValue(llvm::json::Value &V, |
| 45 | const std::map<EntityId, EntityId> &Table); |
| 46 | |
| 47 | llvm::json::Value Data; |
| 48 | }; |
| 49 | |
| 50 | } // namespace clang::ssaf |
| 51 | |
| 52 | #endif // LLVM_CLANG_LIB_SCALABLESTATICANALYSISFRAMEWORK_CORE_SERIALIZATION_JSONFORMAT_JSONENTITYSUMMARYENCODING_H |
| 53 | |