clang 22.0.0git
EntityId.h
Go to the documentation of this file.
1//===- EntityId.h -----------------------------------------------*- 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//
9// This file defines the EntityId class, which provides a lightweight opaque
10// handle to entities in an EntityIdTable. EntityIds are index-based for
11// efficient comparison and lookup.
12//
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_CLANG_ANALYSIS_SCALABLE_MODEL_ENTITY_ID_H
16#define LLVM_CLANG_ANALYSIS_SCALABLE_MODEL_ENTITY_ID_H
17
18#include <cstddef>
19
20namespace clang::ssaf {
21
22class EntityIdTable;
23
24/// Lightweight opaque handle representing an entity in an EntityIdTable.
25///
26/// EntityIds are created by EntityIdTable. Equality and ordering comparisons
27/// are well-defined for EntityIds created by the same EntityIdTable.
28///
29/// \see EntityIdTable
30class EntityId {
31 friend class EntityIdTable;
32
33 size_t Index;
34
35 explicit EntityId(size_t Index) : Index(Index) {}
36
37 EntityId() = delete;
38
39public:
40 bool operator==(const EntityId &Other) const { return Index == Other.Index; }
41 bool operator<(const EntityId &Other) const { return Index < Other.Index; }
42 bool operator!=(const EntityId &Other) const { return !(*this == Other); }
43};
44
45} // namespace clang::ssaf
46
47#endif // LLVM_CLANG_ANALYSIS_SCALABLE_MODEL_ENTITY_ID_H
Manages entity name interning and provides efficient EntityId handles.
Lightweight opaque handle representing an entity in an EntityIdTable.
Definition EntityId.h:30
bool operator==(const EntityId &Other) const
Definition EntityId.h:40
bool operator!=(const EntityId &Other) const
Definition EntityId.h:42
friend class EntityIdTable
Definition EntityId.h:31
bool operator<(const EntityId &Other) const
Definition EntityId.h:41
@ Other
Other implicit parameter.
Definition Decl.h:1746