[clang] [clang][ssaf] Add EntityId and EntityIdTable for efficient entity handling (PR #171660)
Gábor Horváth via cfe-commits
cfe-commits at lists.llvm.org
Thu Dec 11 03:13:00 PST 2025
================
@@ -0,0 +1,40 @@
+//===- EntityIdTable.cpp ----------------------------------------*- 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
+//
+//===----------------------------------------------------------------------===//
+
+#include "clang/Analysis/Scalable/Model/EntityIdTable.h"
+#include <cassert>
+
+namespace clang {
+namespace ssaf {
+
+EntityId EntityIdTable::getId(const EntityName &Name) {
+ const auto It = Entities.find(Name);
+ if (It == Entities.end()) {
+ EntityId Id(Entities.size());
+ Entities.emplace(Name, Id);
----------------
Xazax-hun wrote:
Nit: maybe via the try_emplace API we could avoid doing 2 lookups when we do the insertion.
https://github.com/llvm/llvm-project/pull/171660
More information about the cfe-commits
mailing list