[PATCH] D115031: [AST] Print NTTP args as string-literals when possible

Zhihao Yuan via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 3 01:32:30 PST 2021


lichray created this revision.
lichray requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

C++20 NTTP (non-type template parameter) prints `MyType<{{116, 104, 105, 115}}>` when the code is as simple as `MyType<"this">`. Of course, due to the need for an intermediate structural type to trigger CTAD, it'd be better to keep one layer of the braces. So this patch prints `MyType<{"this"}>`.

Currently, `StringLiteral` can handle this case nicely, but `StringLiteral` inside `APValue` code looks like a circular dependency. So, in this patch, I implemented a very cheap strategy to emit string literals in diagnostic message only when it's more readable and fall back to integer sequences. *Please tell me whether this approach is acceptable* before I write tests.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D115031

Files:
  clang/lib/AST/APValue.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D115031.391581.patch
Type: text/x-patch
Size: 3616 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211203/856770a2/attachment.bin>


More information about the cfe-commits mailing list