xref: /freebsd/contrib/llvm-project/clang/lib/Serialization/TemplateArgumentHasher.h (revision 700637cbb5e582861067a11aaca4d053546871d2)
1*700637cbSDimitry Andric //===- TemplateArgumentHasher.h - Hash Template Arguments -------*- C++ -*-===//
2*700637cbSDimitry Andric //
3*700637cbSDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*700637cbSDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
5*700637cbSDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*700637cbSDimitry Andric //
7*700637cbSDimitry Andric //===----------------------------------------------------------------------===//
8*700637cbSDimitry Andric 
9*700637cbSDimitry Andric #include "clang/AST/TemplateBase.h"
10*700637cbSDimitry Andric 
11*700637cbSDimitry Andric namespace clang {
12*700637cbSDimitry Andric namespace serialization {
13*700637cbSDimitry Andric 
14*700637cbSDimitry Andric /// Calculate a stable hash value for template arguments. We guarantee that
15*700637cbSDimitry Andric /// the same template arguments must have the same hashed values. But we don't
16*700637cbSDimitry Andric /// guarantee that the template arguments with the same hashed value are the
17*700637cbSDimitry Andric /// same template arguments.
18*700637cbSDimitry Andric ///
19*700637cbSDimitry Andric /// ODR hashing may not be the best mechanism to hash the template
20*700637cbSDimitry Andric /// arguments. ODR hashing is (or perhaps, should be) about determining whether
21*700637cbSDimitry Andric /// two things are spelled the same way and have the same meaning (as required
22*700637cbSDimitry Andric /// by the C++ ODR), whereas what we want here is whether they have the same
23*700637cbSDimitry Andric /// meaning regardless of spelling. Maybe we can get away with reusing ODR
24*700637cbSDimitry Andric /// hashing anyway, on the basis that any canonical, non-dependent template
25*700637cbSDimitry Andric /// argument should have the same (invented) spelling in every translation
26*700637cbSDimitry Andric /// unit, but it is not sure that's true in all cases. There may still be cases
27*700637cbSDimitry Andric /// where the canonical type includes some aspect of "whatever we saw first",
28*700637cbSDimitry Andric /// in which case the ODR hash can differ across translation units for
29*700637cbSDimitry Andric /// non-dependent, canonical template arguments that are spelled differently
30*700637cbSDimitry Andric /// but have the same meaning. But it is not easy to raise examples.
31*700637cbSDimitry Andric unsigned StableHashForTemplateArguments(llvm::ArrayRef<TemplateArgument> Args);
32*700637cbSDimitry Andric 
33*700637cbSDimitry Andric } // namespace serialization
34*700637cbSDimitry Andric } // namespace clang
35