brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.7 KiB · f23f131 Raw
35 lines · c
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-exception6//7//===----------------------------------------------------------------------===//8 9#include "clang/AST/TemplateBase.h"10 11namespace clang {12namespace serialization {13 14/// Calculate a stable hash value for template arguments. We guarantee that15/// the same template arguments must have the same hashed values. But we don't16/// guarantee that the template arguments with the same hashed value are the17/// same template arguments.18///19/// ODR hashing may not be the best mechanism to hash the template20/// arguments. ODR hashing is (or perhaps, should be) about determining whether21/// two things are spelled the same way and have the same meaning (as required22/// by the C++ ODR), whereas what we want here is whether they have the same23/// meaning regardless of spelling. Maybe we can get away with reusing ODR24/// hashing anyway, on the basis that any canonical, non-dependent template25/// argument should have the same (invented) spelling in every translation26/// unit, but it is not sure that's true in all cases. There may still be cases27/// where the canonical type includes some aspect of "whatever we saw first",28/// in which case the ODR hash can differ across translation units for29/// non-dependent, canonical template arguments that are spelled differently30/// but have the same meaning. But it is not easy to raise examples.31unsigned StableHashForTemplateArguments(llvm::ArrayRef<TemplateArgument> Args);32 33} // namespace serialization34} // namespace clang35