aboutsummaryrefslogtreecommitdiff
path: root/stable_hash.cc
diff options
context:
space:
mode:
Diffstat (limited to 'stable_hash.cc')
-rw-r--r--stable_hash.cc10
1 files changed, 9 insertions, 1 deletions
diff --git a/stable_hash.cc b/stable_hash.cc
index 8621aed..725cf61 100644
--- a/stable_hash.cc
+++ b/stable_hash.cc
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
// -*- mode: C++ -*-
//
-// Copyright 2022 Google LLC
+// Copyright 2022-2024 Google LLC
//
// Licensed under the Apache License v2.0 with LLVM Exceptions (the
// "License"); you may not use this file except in compliance with the
@@ -126,6 +126,14 @@ HashValue StableHash::operator()(const Member& x) {
}
}
+HashValue StableHash::operator()(const VariantMember& x) {
+ HashValue hash = hash_('v', x.name);
+ hash = DecayHashCombine<8>(hash, (*this)(x.type_id));
+ return x.discriminant_value
+ ? DecayHashCombine<20>(hash, hash_(*x.discriminant_value))
+ : hash;
+}
+
HashValue StableHash::operator()(const StructUnion& x) {
HashValue hash = hash_('S', static_cast<uint32_t>(x.kind), x.name,
static_cast<bool>(x.definition));