27 "EntityLinker: Corrupted TUSummary or logic bug";
30 "{0} - {1} with {2} already exists in LUSummary";
33 "{0} - {1} missing linkage information in TUSummary";
36 "{0} - Duplicate {1} in EntityResolutionTable";
39 "{0} - {1} not found in EntityResolutionTable";
42 "{0} - Failed to insert data for {1} with {2} against {3} to LUSummary";
45 "failed to link TU summary: duplicate {0}";
61 llvm_unreachable(
"Unhandled EntityLinkageType variant");
67 Output.LUNamespace, OldName.Namespace,
Linkage.getLinkage());
69 EntityName NewName(OldName.USR, OldName.Suffix, NewNamespace);
75 EntityId NewId = Output.IdTable.getId(NewName);
77 auto [_, Inserted] = Output.LinkageTable.try_emplace(NewId,
Linkage);
93std::map<EntityId, EntityId>
95 std::map<EntityId, EntityId> EntityResolutionTable;
97 Summary.IdTable.
forEach([&](
const EntityName &OldName,
const EntityId OldId) {
98 auto Iter = Summary.LinkageTable.find(OldId);
99 if (Iter == Summary.LinkageTable.end()) {
104 const EntityLinkage &
Linkage = Iter->second;
106 EntityId NewId = resolveEntity(OldName,
Linkage);
108 auto [_, Inserted] = EntityResolutionTable.insert({OldId, NewId});
115 return EntityResolutionTable;
118std::vector<EntitySummaryEncoding *>
120 const std::map<EntityId, EntityId> &EntityResolutionTable) {
121 std::vector<EntitySummaryEncoding *> PatchTargets;
123 for (
auto &[SN, DataMap] : Summary.Data) {
124 auto &OutputSummaryData = Output.Data[SN];
126 for (
auto &[OldId, ES] : DataMap) {
127 auto Iter = EntityResolutionTable.find(OldId);
128 if (Iter == EntityResolutionTable.end()) {
133 const auto NewId = Iter->second;
135 auto [It, Inserted] = OutputSummaryData.try_emplace(NewId, std::move(ES));
138 PatchTargets.push_back(It->second.get());
142 auto Linkage = Summary.LinkageTable.at(OldId);
165EntityLinker::patch(
const std::vector<EntitySummaryEncoding *> &PatchTargets,
166 const std::map<EntityId, EntityId> &EntityResolutionTable) {
167 for (
auto *PatchTarget : PatchTargets) {
168 assert(PatchTarget &&
"EntityLinker::patch: Patch target cannot be null");
170 if (
auto Err = PatchTarget->patch(EntityResolutionTable)) {
174 return llvm::Error::success();
178 auto [_, Inserted] = ProcessedTUNamespaces.insert(Summary->TUNamespace);
182 Summary->TUNamespace)
188 auto EntityResolutionTable = resolve(SummaryRef);
189 auto PatchTargets = merge(SummaryRef, EntityResolutionTable);
190 return patch(PatchTargets, EntityResolutionTable);
static NestedBuildNamespace resolveNamespace(const NestedBuildNamespace &LUNamespace, const NestedBuildNamespace &EntityNamespace, EntityLinkageType Linkage)
void forEach(llvm::function_ref< void(const EntityName &, EntityId)> Callback) const
Invokes the callback for each entity in the table.
Lightweight opaque handle representing an entity in an EntityIdTable.
Represents the linkage properties of an entity in the program model.
llvm::Error link(std::unique_ptr< TUSummaryEncoding > Summary)
Links a TU summary into a LU summary.
Uniquely identifies an entity in a program.
static ErrorBuilder create(std::error_code EC, const char *Fmt, Args &&...ArgVals)
Create an ErrorBuilder with an error code and formatted message.
static void fatal(const char *Fmt, Args &&...ArgVals)
Report a fatal error with formatted message and terminate execution.
llvm::Error build() const
Build and return the final error.
Represents a hierarchical sequence of build namespaces.
NestedBuildNamespace makeQualified(NestedBuildNamespace Namespace) const
Creates a new NestedBuildNamespace by appending additional namespace.
Represents a translation unit summary in its serialized encoding.
static constexpr const char * EntityAlreadyExistsInLinkageTable
static constexpr const char * DuplicateTUNamespace
static constexpr const char * EntityLinkerFatalErrorPrefix
static constexpr const char * DuplicateEntityIdInTUSummary
static constexpr const char * MissingLinkageInformation
static constexpr const char * FailedToInsertEntityIntoOutputSummary
static constexpr const char * EntityNotFoundInResolutionTable
@ None
local variables, function parameters
@ Internal
static functions/variables, anonymous namespace
@ External
globally visible across translation units
Linkage
Describes the different kinds of linkage (C++ [basic.link], C99 6.2.2) that an entity may have.