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