[clang] [clang][ssaf] Add Entity Linker and associated data structures (PR #181765)
Aviral Goel via cfe-commits
cfe-commits at lists.llvm.org
Thu Feb 19 18:00:42 PST 2026
================
@@ -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);
----------------
aviralg wrote:
Can't we create separate overloads of link() for each input type?
https://github.com/llvm/llvm-project/pull/181765
More information about the cfe-commits
mailing list