Path: blob/main/contrib/llvm-project/clang/lib/Serialization/TemplateArgumentHasher.h
213766 views
//===- TemplateArgumentHasher.h - Hash Template Arguments -------*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#include "clang/AST/TemplateBase.h"910namespace clang {11namespace serialization {1213/// Calculate a stable hash value for template arguments. We guarantee that14/// the same template arguments must have the same hashed values. But we don't15/// guarantee that the template arguments with the same hashed value are the16/// same template arguments.17///18/// ODR hashing may not be the best mechanism to hash the template19/// arguments. ODR hashing is (or perhaps, should be) about determining whether20/// two things are spelled the same way and have the same meaning (as required21/// by the C++ ODR), whereas what we want here is whether they have the same22/// meaning regardless of spelling. Maybe we can get away with reusing ODR23/// hashing anyway, on the basis that any canonical, non-dependent template24/// argument should have the same (invented) spelling in every translation25/// unit, but it is not sure that's true in all cases. There may still be cases26/// where the canonical type includes some aspect of "whatever we saw first",27/// in which case the ODR hash can differ across translation units for28/// non-dependent, canonical template arguments that are spelled differently29/// but have the same meaning. But it is not easy to raise examples.30unsigned StableHashForTemplateArguments(llvm::ArrayRef<TemplateArgument> Args);3132} // namespace serialization33} // namespace clang343536