[PATCH] D155610: [Clang][ExprConstant] Print integer instead of character on static assertion failure
Corentin Jabot via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 1 07:13:21 PDT 2023
cor3ntin added a comment.
I've been thinking about it and I think I have a cleaner design for the printing of characters:
We need a `CharToString(unsigned, Qualtype) -> SmallString` method that takes a value and the type.
for `char` and `char8_t` we can just return the value.
For `wchar_t`, `char32_t` and `char16_t`, we can use something like `ConvertCodePointToUTF8` to convert to UTF-8. If that fails we can escape with `\x`
If we pass the result of that to the diagnostic engine, escaping of non printing character would happen automatically.
That way we have a nice separation between converting an APValue to string and printing it, which should avoid code duplication quite a bit, and generally make the design nicer.
Then maybe we need to consider whether we want to modify `CharacterLiteral::print` to be aligned with all of that. I don;t know if that's used, for example, for mangling.
Given there are a bunch of different issues here, i would not mind separate PRs - having the numerical value showed in paren seems valuable on its own.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D155610/new/
https://reviews.llvm.org/D155610
More information about the cfe-commits
mailing list