================ @@ -0,0 +1,96 @@ +//===- EntityLinker.h - Class for linking entities --------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file defines the EntityLinker class that combines multiple TU summaries +// into a unified LU summary by deduplicating entities and patching summaries. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_ANALYSIS_SCALABLE_ENTITYLINKER_ENTITYLINKER_H +#define LLVM_CLANG_ANALYSIS_SCALABLE_ENTITYLINKER_ENTITYLINKER_H + +#include "clang/Analysis/Scalable/EntityLinker/LUSummaryEncoding.h" +#include "llvm/Support/Error.h" +#include <map> +#include <memory> +#include <set> +#include <vector> + +namespace clang::ssaf { + +class BuildNamespace; +class EntityId; +class EntityLinkage; +class EntityName; +class EntitySummaryEncoding; +class TUSummaryEncoding; + +class EntityLinker { + LUSummaryEncoding Output; + std::set<BuildNamespace> ProcessedTUNamespaces; + +public: + /// Constructs an EntityLinker to link TU summaries into a LU summary. + /// + /// \param LUNamespace The namespace identifying this link unit. + EntityLinker(NestedBuildNamespace LUNamespace) + : Output(std::move(LUNamespace)) {} + + /// Links a TU summary into a LU summary. + /// + /// Deduplicates entities, patches entity ID references in the entity summary, + /// and merges them into a single data store. The provided TU summary is + /// consumed by this operation. + /// + /// \param Summary The TU summary to link. Ownership is transferred. + /// \returns Error if the TU namespace has already been linked, success + /// otherwise. Corrupted summary data (missing linkage information, + /// duplicate entity IDs, etc.) triggers a fatal error. + llvm::Error link(std::unique_ptr<TUSummaryEncoding> Summary); + + /// Returns the accumulated LU summary. + /// + /// \returns LU summary containing all the deduplicated and patched entity + /// summaries. + const LUSummaryEncoding &getOutput() const { return Output; } + +private: + /// Resolves a TU entity name to an LU entity name and ID. ---------------- jkorous-apple wrote:
The resolved name is not returned, so I assume it's stored in the `Output`. https://github.com/llvm/llvm-project/pull/181765 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
