[clang] [clang][ssaf] Add EntityId and EntityIdTable for efficient entity handling (PR #171660)
Balázs Benics via cfe-commits
cfe-commits at lists.llvm.org
Thu Dec 11 05:30:43 PST 2025
================
@@ -0,0 +1,65 @@
+//===- unittests/Analysis/Scalable/EntityIdTest.cpp ----------------------===//
+//
+// 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/EntityId.h"
+#include "clang/Analysis/Scalable/Model/EntityIdTable.h"
+#include "clang/Analysis/Scalable/Model/EntityName.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace ssaf {
+namespace {
+
+TEST(EntityIdTest, Equality) {
+ EntityIdTable Table;
+
+ EntityName Entity1("c:@F at foo", "", {});
+ EntityName Entity2("c:@F at bar", "", {});
+
+ EntityId Id1 = Table.getId(Entity1);
+ EntityId Id2 = Table.getId(Entity2);
+ EntityId Id1Copy = Table.getId(Entity1);
+
+ EXPECT_EQ(Id1, Id1Copy);
+ EXPECT_FALSE(Id1 != Id1Copy);
+
+ EXPECT_NE(Id1, Id2);
+ EXPECT_FALSE(Id1 == Id2);
----------------
steakhal wrote:
Should we also check that equality and inequality implies that neither are "smaller"?
https://github.com/llvm/llvm-project/pull/171660
More information about the cfe-commits
mailing list