| 1 | //===- TUSummaryEncoding.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 | // This file defines the TUSummaryEncoding class, which represents a |
| 10 | // translation unit summary in its serialized, format-specific encoding. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #ifndef LLVM_CLANG_ANALYSIS_SCALABLE_ENTITYLINKER_TUSUMMARYENCODING_H |
| 15 | #define LLVM_CLANG_ANALYSIS_SCALABLE_ENTITYLINKER_TUSUMMARYENCODING_H |
| 16 | |
| 17 | #include "clang/Analysis/Scalable/EntityLinker/EntitySummaryEncoding.h" |
| 18 | #include "clang/Analysis/Scalable/Model/BuildNamespace.h" |
| 19 | #include "clang/Analysis/Scalable/Model/EntityId.h" |
| 20 | #include "clang/Analysis/Scalable/Model/EntityIdTable.h" |
| 21 | #include "clang/Analysis/Scalable/Model/EntityLinkage.h" |
| 22 | #include "clang/Analysis/Scalable/Model/SummaryName.h" |
| 23 | #include <map> |
| 24 | #include <memory> |
| 25 | |
| 26 | namespace clang::ssaf { |
| 27 | |
| 28 | /// Represents a translation unit summary in its serialized encoding. |
| 29 | /// |
| 30 | /// TUSummaryEncoding holds entity summary data in a format-specific encoding |
| 31 | /// that can be manipulated by the entity linker without deserializing the |
| 32 | /// full EntitySummary objects. This enables efficient entity ID patching |
| 33 | /// during the linking process. |
| 34 | class TUSummaryEncoding { |
| 35 | friend class EntityLinker; |
| 36 | friend class SerializationFormat; |
| 37 | friend class TestFixture; |
| 38 | |
| 39 | // The namespace identifying this translation unit. |
| 40 | BuildNamespace TUNamespace; |
| 41 | |
| 42 | // Maps entity names to their unique identifiers within this TU. |
| 43 | EntityIdTable IdTable; |
| 44 | |
| 45 | // Maps entity IDs to their linkage properties (None, Internal, External). |
| 46 | std::map<EntityId, EntityLinkage> LinkageTable; |
| 47 | |
| 48 | // Encoded summary data organized by summary type and entity ID. |
| 49 | std::map<SummaryName, |
| 50 | std::map<EntityId, std::unique_ptr<EntitySummaryEncoding>>> |
| 51 | Data; |
| 52 | |
| 53 | public: |
| 54 | explicit TUSummaryEncoding(BuildNamespace TUNamespace) |
| 55 | : TUNamespace(std::move(TUNamespace)) {} |
| 56 | }; |
| 57 | |
| 58 | } // namespace clang::ssaf |
| 59 | |
| 60 | #endif // LLVM_CLANG_ANALYSIS_SCALABLE_ENTITYLINKER_TUSUMMARYENCODING_H |
| 61 |