[clang] [clang][ssaf] Add EntityId and EntityIdTable for efficient entity handling (PR #171660)
Balázs Benics via cfe-commits
cfe-commits at lists.llvm.org
Thu Dec 11 05:30:43 PST 2025
================
@@ -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;
----------------
steakhal wrote:
Personally, I prefer the non-static data members at the bottom of the class declaration, as they represent the internals of the class.
For example, when one clicks on the class name, it usually jumps to the beginning of the class declaration in the editor. It's somewhat annoying to scroll through to get to the public interface.
https://github.com/llvm/llvm-project/pull/171660
More information about the cfe-commits
mailing list