[clang] [clang] ODR hashes depth+index and not name of TemplateTypeParm (PR #144796)

Ilya Biryukov via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 23 02:19:05 PDT 2025


ilya-biryukov wrote:

> It's just that a canonical template parameter type doesn't refer to a particular template parameter declaration.

The particular statement is that Clang canonicalizes `decltype(func<T>())` to `decltype(func<FirstOccurrenceOfTWithSameDepthAndIndex>())`.  If we don't change that, we end up with spurious false positives from ODR checking (I believe that's one of the reasons why it's disabled in C++20 header units), effectively turning off all the checks and not just weakening them for template parameters.

I feel that this change is a better trade-off, at least that's the best idea for tactically reducing the false positive rate (at the cost of some false negatives).

> This change weakens the ODR checker beyond what the fix should require.
> I can't give a more thorough review at this time since I am still traveling from the WG21 meeting.

👍 eager to hear better suggestions and safe travels.

https://github.com/llvm/llvm-project/pull/144796


More information about the cfe-commits mailing list