================
@@ -0,0 +1,49 @@
+//===- EntityId.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
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines the EntityId class, which provides a lightweight opaque
+// handle to entities in an EntityIdTable. EntityIds are index-based for
+// efficient comparison and lookup.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_ANALYSIS_SCALABLE_MODEL_ENTITY_ID_H
+#define LLVM_CLANG_ANALYSIS_SCALABLE_MODEL_ENTITY_ID_H
+
+#include <cstddef>
+
+namespace clang {
+namespace ssaf {
+
+class EntityIdTable;
+
+/// Lightweight opaque handle representing an entity in an EntityIdTable.
+///
+/// EntityIds are created by EntityIdTable. Equality and ordering comparisons
+/// are well-defined for EntityIds created by the same EntityIdTable.
+///
+/// \see EntityIdTable
+class EntityId {
+  friend class EntityIdTable;
+
+  size_t Index;
+
+  explicit EntityId(size_t Index) : Index(Index) {}
+
+  EntityId() = delete;
+
+public:
+  bool operator==(const EntityId &Other) const { return Index == Other.Index; }
+  bool operator<(const EntityId &Other) const { return Index < Other.Index; }
----------------
aviralg wrote:

I understand the need for equality but why do we care about having an ordering 
relation between entities? Does it serve any meaningful purpose in static 
analysis or is it only to enable clients to use them as keys in collections?

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