================ @@ -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; + + explicit EntityId(size_t Index) : Index(Index) {} + + EntityId() = delete; + +public: + bool operator==(const EntityId &Other) const { return Index == Other.Index; } + bool operator<(const EntityId &Other) const { return Index < Other.Index; } ---------------- jkorous-apple wrote:
It's the latter. EntityId will very likely be used as an element type in `std::set` or `std::map` in the summary data. https://github.com/llvm/llvm-project/pull/171660 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
