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}";
65 llvm_unreachable(
"Unhandled EntityLinkageType variant");
72 Output.LUNamespace, TUNamespace, OldName.Namespace,
Linkage.getLinkage());
74 EntityName NewName(OldName.USR, OldName.Suffix, NewNamespace);
80 EntityId NewId = Output.IdTable.getId(NewName);
82 auto [_, Inserted] = Output.LinkageTable.try_emplace(NewId,
Linkage);
98std::map<EntityId, EntityId>
100 std::map<EntityId, EntityId> EntityResolutionTable;
102 Summary.IdTable.
forEach([&](
const EntityName &OldName,
const EntityId OldId) {
103 auto Iter = Summary.LinkageTable.find(OldId);
104 if (Iter == Summary.LinkageTable.end()) {
109 const EntityLinkage &
Linkage = Iter->second;
111 EntityId NewId = resolveEntity(OldName,
Linkage,
112 NestedBuildNamespace(Summary.TUNamespace));
114 auto [_, Inserted] = EntityResolutionTable.insert({OldId, NewId});
121 return EntityResolutionTable;
124std::vector<EntitySummaryEncoding *>
126 const std::map<EntityId, EntityId> &EntityResolutionTable) {
127 std::vector<EntitySummaryEncoding *> PatchTargets;
129 for (
auto &[SN, DataMap] : Summary.Data) {
130 auto &OutputSummaryData = Output.Data[SN];
132 for (
auto &[OldId, ES] : DataMap) {
133 auto Iter = EntityResolutionTable.find(OldId);
134 if (Iter == EntityResolutionTable.end()) {
139 const auto NewId = Iter->second;
141 auto [It, Inserted] = OutputSummaryData.try_emplace(NewId, std::move(ES));
144 PatchTargets.push_back(It->second.get());
148 auto Linkage = Summary.LinkageTable.at(OldId);
171EntityLinker::patch(
const std::vector<EntitySummaryEncoding *> &PatchTargets,
172 const std::map<EntityId, EntityId> &EntityResolutionTable) {
173 for (
auto *PatchTarget : PatchTargets) {
174 assert(PatchTarget &&
"EntityLinker::patch: Patch target cannot be null");
176 if (
auto Err = PatchTarget->patch(EntityResolutionTable)) {
180 return llvm::Error::success();
184 auto [_, Inserted] = ProcessedTUNamespaces.insert(Summary->TUNamespace);
188 Summary->TUNamespace)
194 auto EntityResolutionTable = resolve(SummaryRef);
195 auto PatchTargets = merge(SummaryRef, EntityResolutionTable);
196 return patch(PatchTargets, EntityResolutionTable);
static NestedBuildNamespace resolveNamespace(const NestedBuildNamespace &LUNamespace, const NestedBuildNamespace &TUNamespace, 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.