clang 23.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_SCALABLESTATICANALYSISFRAMEWORK_CORE_MODEL_ENTITYID_H
16#define LLVM_CLANG_SCALABLESTATICANALYSISFRAMEWORK_CORE_MODEL_ENTITYID_H
17
18#include "llvm/Support/raw_ostream.h"
19#include <cstddef>
20
21namespace clang::ssaf {
22
23class EntityIdTable;
24
25/// Lightweight opaque handle representing an entity in an EntityIdTable.
26///
27/// EntityIds are created by EntityIdTable. Equality and ordering comparisons
28/// are well-defined for EntityIds created by the same EntityIdTable.
29///
30/// \see EntityIdTable
31class EntityId {
32 friend class EntityIdTable;
33 friend class SerializationFormat;
34 friend class TestFixture;
35 friend llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
36 const EntityId &Id);
37
38 size_t Index;
39
40 explicit EntityId(size_t Index) : Index(Index) {}
41
42 EntityId() = delete;
43
44public:
45 bool operator==(const EntityId &Other) const { return Index == Other.Index; }
46 bool operator<(const EntityId &Other) const { return Index < Other.Index; }
47 bool operator!=(const EntityId &Other) const { return !(*this == Other); }
48};
49
50llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const EntityId &Id);
51
52} // namespace clang::ssaf
53
54#endif // LLVM_CLANG_SCALABLESTATICANALYSISFRAMEWORK_CORE_MODEL_ENTITYID_H
Manages entity name interning and provides efficient EntityId handles.
Lightweight opaque handle representing an entity in an EntityIdTable.
Definition EntityId.h:31
bool operator==(const EntityId &Other) const
Definition EntityId.h:45
bool operator!=(const EntityId &Other) const
Definition EntityId.h:47
friend class EntityIdTable
Definition EntityId.h:32
friend llvm::raw_ostream & operator<<(llvm::raw_ostream &OS, const EntityId &Id)
Definition EntityId.cpp:13
friend class SerializationFormat
Definition EntityId.h:33
bool operator<(const EntityId &Other) const
Definition EntityId.h:46
friend class TestFixture
Definition EntityId.h:34
llvm::raw_ostream & operator<<(llvm::raw_ostream &OS, BuildNamespaceKind BNK)
@ Other
Other implicit parameter.
Definition Decl.h:1746