llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: lambo (Lambo-IITian) <details> <summary>Changes</summary> ### Description Fixes #<!-- -->180046 This PR addresses issue #<!-- -->180046 where Clang elides the wrong part of template types in error messages, specifically hiding important type qualifiers (like `const` or `volatile`) behind `[...]`. The fix ensures that when template types differ only by qualifiers, those qualifiers are preserved in the diagnostic output rather than being elided, making the error messages much more actionable. ## Before changes error <img width="1740" height="267" alt="Screenshot 2026-02-06 172130" src="https://github.com/user-attachments/assets/ef3d2d99-d2b1-4cde-8017-b41142004069" /> ## After changes error <img width="919" height="348" alt="Screenshot 2026-02-06 172337" src="https://github.com/user-attachments/assets/c458b47b-ef8a-4d07-84fa-677cce4be271" /> --- Full diff: https://github.com/llvm/llvm-project/pull/180175.diff 1 Files Affected: - (modified) clang/lib/AST/ASTDiagnostic.cpp (+9-2) ``````````diff diff --git a/clang/lib/AST/ASTDiagnostic.cpp b/clang/lib/AST/ASTDiagnostic.cpp index b8023cb6fa10f..7c498bc9b8e8a 100644 --- a/clang/lib/AST/ASTDiagnostic.cpp +++ b/clang/lib/AST/ASTDiagnostic.cpp @@ -1205,8 +1205,15 @@ class TemplateDiff { "Both template specializations need to be valid."); Qualifiers FromQual = FromType.getQualifiers(), ToQual = ToType.getQualifiers(); - FromQual -= QualType(FromArgTST, 0).getQualifiers(); - ToQual -= QualType(ToArgTST, 0).getQualifiers(); + // FromQual -= QualType(FromArgTST, 0).getQualifiers(); + // ToQual -= QualType(ToArgTST, 0).getQualifiers(); + bool Same = false; + if (FromArgTST->getTemplateName().getAsTemplateDecl() == + ToArgTST->getTemplateName().getAsTemplateDecl()) { + // If the names match, the ONLY thing that makes them different is the Qualifiers + Same = (FromQual == ToQual); + } + Tree.SetSame(Same); Tree.SetTemplateDiff(FromArgTST->getTemplateName().getAsTemplateDecl(), ToArgTST->getTemplateName().getAsTemplateDecl(), FromQual, ToQual, FromDefault, ToDefault); `````````` </details> https://github.com/llvm/llvm-project/pull/180175 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
