================ @@ -828,7 +828,23 @@ void ODRHash::AddDecl(const Decl *D) { return; } - AddDeclarationName(ND->getDeclName()); + // For template parameters, use depth+index instead of name, because type + // canonicalization can change the name of the template parameter. + if (auto *TTPD = dyn_cast<TemplateTypeParmDecl>(ND)) { + ID.AddInteger(TTPD->getDepth()); + ID.AddInteger(TTPD->getIndex()); + AddBoolean(TTPD->isParameterPack()); ---------------- ilya-biryukov wrote:
Could you split the variadic templates into a separate change? This looks like an independent issue (the code below should detect an ODR violation, but it doesn't) and actually opens a whole other can of worms wrt to what needs to be checked (e.g. checking types of non-type template parameters, template headers of template template parameters, etc). ```cpp namespace mytest { #ifdef FIRST template <class ...T> struct FooTypePack {}; template <int ...I> struct FooIntPack {}; template <template<class> class ...TT> struct FooTemplateTemplatePack {}; #endif #ifdef SECOND template <class T> struct FooTypePack {}; template <int I> struct FooIntPack {}; template <template<class> class TT> struct FooTemplateTemplatePack {}; #endif #ifdef ACCESS FooTypePack<int> a; FooIntPack<0> b; FooTemplateTemplatePack<FooTypePack> c; #endif } ``` https://github.com/llvm/llvm-project/pull/144796 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits