Need better fingerprinting of C++ types

Author: jonmeowCreated Feb 12, 2026Updated Sep 22, 2026
Labelslong term issuetoolchain

Description of the bug:

C++ types don't provide sufficient uniqueness in fingerprinting. For example, Cpp.std.initializer_list(i32) and Cpp.std.initializer_list(Cpp.nontrivial_dtor) currently fingerprint the same (example taken from toolchain/lower/testdata/interop/cpp/std_initializer_list.carbon).

There's a TODO for this in inst_fingerprinter.cpp:

  auto Add(ClangDeclId /*decl_id*/) -> void {
    // TODO: For `CppTemplateNameType` we don't need to fingerprint the
    // `decl_id`, because fingerprinting the `NameId` is sufficient to identify
    // the template, but this won't necessarily be true for other
    // `ClangDeclId`s.
  }

This is becoming more of an issue because we need a way to generate unique names. For example I ran into this with custom witness naming (using fingerprints expecting uniqueness), but we can generally use fingerprinting in mangling of specifics, so if a specific involves C++ types it can run into the same issue.

Source: carbon-language/carbon-lang