C++20 non-type template parameter prints MyType<{{116, 104, 105, 115}}> when the code is as simple as MyType<"this">. This patch prints MyType<{"this"}>, with one layer of braces preserved for the intermediate structural type to trigger CTAD.
StringLiteral handles this case, but StringLiteral inside APValue code looks like a circular dependency. The proposed patch implements a cheap strategy to emit string literals in diagnostic messages only when they are readable and fall back to integer sequences.
It looks like nothing is setting this to true yet, so that part of this patch seems untested. The places I think we want to set this to true are:
I think what we'd want is: if we still have a collision between type names after comparing the canonical strings (https://github.com/llvm/llvm-project/blob/main/clang/lib/AST/ASTDiagnostic.cpp#L291), then set this policy to true for the rest of the function, and recompute S and CanS.
This should be detectable in a case such as:
... where the diagnostic should include the whole string, not elide the differing portion at the end.
It's generally important that debug information has complete type names.