clang 22.0.0git
EntityIdTable.cpp
Go to the documentation of this file.
1//===- EntityIdTable.cpp ----------------------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
10#include <cassert>
11
12namespace clang::ssaf {
13
15 EntityId Id(Entities.size());
16 const auto Res = Entities.try_emplace(Name, Id);
17 return Res.first->second;
18}
19
20bool EntityIdTable::contains(const EntityName &Name) const {
21 return Entities.find(Name) != Entities.end();
22}
23
25 llvm::function_ref<void(const EntityName &, EntityId)> Callback) const {
26 for (const auto &NameIdPair : Entities) {
27 Callback(NameIdPair.first, NameIdPair.second);
28 }
29}
30
31} // namespace clang::ssaf
bool contains(const EntityName &Name) const
Returns true if an entity with the given name exists in the table.
EntityId getId(const EntityName &Name)
Creates or retrieves an EntityId for the given EntityName.
void forEach(llvm::function_ref< void(const EntityName &, EntityId)> Callback) const
Invokes the callback for each entity in the table.
Lightweight opaque handle representing an entity in an EntityIdTable.
Definition EntityId.h:30
Uniquely identifies an entity in a program.
Definition EntityName.h:27