Previously displaying a failed assert would involve a runtime integer to
string conversion. This patch changes that to be a compile time string
conversion.
This was inspired by a comment by JonChesterfield on https://reviews.llvm.org/D155899
Differential D156168
[libc][NFC] Simplify assert message generation michaelrj on Jul 24 2023, 2:11 PM. Authored by
Details Previously displaying a failed assert would involve a runtime integer to This was inspired by a comment by JonChesterfield on https://reviews.llvm.org/D155899
Diff Detail
Event TimelineComment Actions LGTM. I'm slightly surprised __PRETTY_FUNCTION__ can't be concatenated with string literals at preprocessor time but I'm getting errors when I try it. This might leak into user code. Is there an existing __LIBC_ prefix or similar? Thanks for dropping the runtime int -> string conversion, always pleased to have fewer things that can go wrong at runtime. Comment Actions I'm also kinda confused why __PRETTY_FUNCTION__ isn't available to the preprocessor, maybe it's to do with C++ mangling semantics? I'll look into better names for the macros, I think something like __LIBC would probably work. Yeah, my first try involved constexpr strings that were concatenated at compile time, but then I realized that the macros are just strings themselves (or close enough with line).
|
With this change I think it is better to inline these calls also in the macro below. The format relation ship between error_str and funcname is decided in that macro so keep it there.