================
@@ -0,0 +1,91 @@
+//===- 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 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.
+ explicit 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; }
----------------
steakhal wrote:
I think we could remove some boilerplate from this. And I think this is the
last operation of an `EntityLinker` object, so we could make this fn an rvalue
method, and potentially avoid copies.
```suggestion
/// \returns LU summary containing all the deduplicated and patched entity
/// summaries.
LUSummaryEncoding &&getOutput() && { return 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