https://github.com/nico created https://github.com/llvm/llvm-project/pull/217651
TemplateDiff mae a new PrintingPolicy instead of using ASTContext's. Sema::getPrintingPolicy() tweaks ASTContext's, sema template diffing didn't pick up those changes. Sema::getPrintingPolicy() does two things: 1. Something for bool vs _Bool for C (where template diffing doesn't apply) 2. Set EntireContentsOfLargeArray to false Before this patch, the latter had no effect in diff mode, meaning we the same type printed differently in a diagnostic depending on if used template diffing. Now they're consistent. (This made no difference before https://reviews.llvm.org/D115031, which probably just forgot to update this call site.) >From 1e87d94b9a91fc9e0c76538c59f324fa7ac9a003 Mon Sep 17 00:00:00 2001 From: Nico Weber <[email protected]> Date: Thu, 20 Aug 2026 10:04:53 -0400 Subject: [PATCH] clang: Use the context printing policy in TemplateDiff TemplateDiff mae a new PrintingPolicy instead of using ASTContext's. Sema::getPrintingPolicy() tweaks ASTContext's, sema template diffing didn't pick up those changes. Sema::getPrintingPolicy() does two things: 1. Something for bool vs _Bool for C (where template diffing doesn't apply) 2. Set EntireContentsOfLargeArray to false Before this patch, the latter had no effect in diff mode, meaning we the same type printed differently in a diagnostic depending on if used template diffing. Now they're consistent. (This made no difference before https://reviews.llvm.org/D115031, which probably just forgot to update this call site.) --- clang/lib/AST/ASTDiagnostic.cpp | 2 +- clang/test/SemaCXX/cxx2a-nttp-printing.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/clang/lib/AST/ASTDiagnostic.cpp b/clang/lib/AST/ASTDiagnostic.cpp index f7888f58985db..086f5dadc6ec5 100644 --- a/clang/lib/AST/ASTDiagnostic.cpp +++ b/clang/lib/AST/ASTDiagnostic.cpp @@ -2119,7 +2119,7 @@ class TemplateDiff { QualType ToType, bool PrintTree, bool PrintFromType, bool ElideType, bool ShowColor) : Context(Context), - Policy(Context.getLangOpts()), + Policy(Context.getPrintingPolicy()), ElideType(ElideType), PrintTree(PrintTree), ShowColor(ShowColor), diff --git a/clang/test/SemaCXX/cxx2a-nttp-printing.cpp b/clang/test/SemaCXX/cxx2a-nttp-printing.cpp index d03a5dd7dd6ad..cace0bc94f390 100644 --- a/clang/test/SemaCXX/cxx2a-nttp-printing.cpp +++ b/clang/test/SemaCXX/cxx2a-nttp-printing.cpp @@ -7,8 +7,8 @@ template <int N> struct Str { template <Str V> class ASCII {}; -void Foo(ASCII<"this nontype template argument is too long to print">); // expected-note {{no known conversion from 'ASCII<Str<43>{"this nontype template argument is too long"}>' to 'ASCII<Str<52>{"this nontype template argument is too long to print"}>'}} -void Bar(ASCII<"this nttp argument is too short">); // expected-note {{no known conversion from 'ASCII<Str<14>{{119, 97, 105, 116, 32, 97, 32, 115, 27, 99, 111, 110, 100, 0}}>' to 'ASCII<Str<32>{"this nttp argument is too short"}>'}} +void Foo(ASCII<"this nontype template argument is too long to print">); // expected-note {{no known conversion from 'ASCII<Str<43>{"this nontype template argument is [...]"}>' to 'ASCII<Str<52>{"this nontype template argument is [...]"}>'}} +void Bar(ASCII<"this nttp argument is too short">); // expected-note {{no known conversion from 'ASCII<Str<14>{{119, 97, 105, 116, 32, 97, 32, 115, 27, 99, ...}}>' to 'ASCII<Str<32>{"this nttp argument is too short"}>'}} void Meow(ASCII<"what|">); // expected-note {{no known conversion from 'ASCII<Str<8>{"what??!"}>' to 'ASCII<Str<6>{"what|"}>' for 1st argument}} void test_ascii() { _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
