From 903210f28babe29c18710d89217c0ce468fef9ba Mon Sep 17 00:00:00 2001 From: Justin King Date: Tue, 16 Jun 2026 13:19:17 -0700 Subject: [PATCH] Internal change PiperOrigin-RevId: 933263369 --- checker/BUILD | 1 + checker/validation_result.h | 1 + common/decl.h | 64 +++++++++++++++++++++++++++++++++++++ 3 files changed, 66 insertions(+) diff --git a/checker/BUILD b/checker/BUILD index 10ed6e363..efca3ff73 100644 --- a/checker/BUILD +++ b/checker/BUILD @@ -49,6 +49,7 @@ cc_library( deps = [ ":type_check_issue", "//common:ast", + "//common:decl", "//common:source", "//common:type", "@com_google_absl//absl/base:nullability", diff --git a/checker/validation_result.h b/checker/validation_result.h index f424e7f6f..7417e9969 100644 --- a/checker/validation_result.h +++ b/checker/validation_result.h @@ -28,6 +28,7 @@ #include "absl/types/span.h" #include "checker/type_check_issue.h" #include "common/ast.h" +#include "common/decl.h" #include "common/source.h" #include "common/type.h" diff --git a/common/decl.h b/common/decl.h index 7aea8c502..b15645236 100644 --- a/common/decl.h +++ b/common/decl.h @@ -377,6 +377,70 @@ bool TypeIsAssignable(const Type& to, const Type& from); } // namespace common_internal +struct VariableDeclEqualTo { + using is_transparent = void; + + bool operator()(const cel::VariableDecl& lhs, + const cel::VariableDecl& rhs) const { + return lhs.name() == rhs.name(); + } + + bool operator()(const cel::VariableDecl& lhs, std::string_view rhs) const { + return lhs.name() == rhs; + } + + bool operator()(std::string_view lhs, const cel::VariableDecl& rhs) const { + return lhs == rhs.name(); + } +}; + +struct VariableDeclHash { + using is_transparent = void; + + size_t operator()(const cel::VariableDecl& decl) const { + return (*this)(decl.name()); + } + + size_t operator()(std::string_view name) const { return absl::HashOf(name); } +}; + +using VariableDeclSet = absl::flat_hash_set; + +struct FunctionDeclEqualTo { + using is_transparent = void; + + bool operator()(const cel::FunctionDecl& lhs, + const cel::FunctionDecl& rhs) const { + return (*this)(lhs.name(), rhs.name()); + } + + bool operator()(const cel::FunctionDecl& lhs, std::string_view rhs) const { + return (*this)(lhs.name(), rhs); + } + + bool operator()(std::string_view lhs, const cel::FunctionDecl& rhs) const { + return (*this)(lhs, rhs.name()); + } + + bool operator()(std::string_view lhs, std::string_view rhs) const { + return lhs == rhs; + } +}; + +struct FunctionDeclHash { + using is_transparent = void; + + size_t operator()(const cel::FunctionDecl& decl) const { + return absl::HashOf(decl.name()); + } + + size_t operator()(std::string_view name) const { return absl::HashOf(name); } +}; + +using FunctionDeclSet = absl::flat_hash_set; + } // namespace cel #endif // THIRD_PARTY_CEL_CPP_COMMON_DECL_H_