================
@@ -0,0 +1,52 @@
+//===- EntityIdTable.h ------------------------------------------*- 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
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_ANALYSIS_SCALABLE_MODEL_ENTITY_ID_TABLE_H
+#define LLVM_CLANG_ANALYSIS_SCALABLE_MODEL_ENTITY_ID_TABLE_H
+
+#include "clang/Analysis/Scalable/Model/EntityId.h"
+#include "clang/Analysis/Scalable/Model/EntityName.h"
+#include <functional>
+#include <map>
+
+namespace clang {
+namespace ssaf {
+
+/// Manages entity name interning and provides efficient EntityId handles.
+///
+/// The table maps each unique EntityName maps to exactly one EntityId.
+/// Entities are never removed.
+class EntityIdTable {
+  std::map<EntityName, EntityId> Entities;
+
+public:
+  EntityIdTable() = default;
+
+  /// Creates or retrieves an EntityId for the given EntityName.
+  ///
+  /// If the entity already exists in the table, returns its existing Id.
+  /// Otherwise, creates and returns a new Id. This operation is idempotent.
+  EntityId getId(const EntityName &Name);
+
+  /// Returns true if an entity with the given name exists in the table.
+  bool exists(const EntityName &Name) const;
+
+  /// Invokes the callback for each entity in the table.
+  ///
+  /// Iteration order is unspecified.
+  void
+  forEach(std::function<void(const EntityName &, EntityId)> Callback) const;
+
+  /// Returns the number of unique entities in the table.
+  size_t count() const;
----------------
ymand wrote:

given that that this is simple, define inline?

https://github.com/llvm/llvm-project/pull/171660
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to