-
Notifications
You must be signed in to change notification settings - Fork 445
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Format-related string fixes and refactorings #4704
Conversation
I can probably factor our removal of |
How easy is it to switch from |
Format strings are mess :( abseil uses POSIX (printf-style) format strings with few extensions (so we cannot easily switch from But so far:
|
But switching from absl::StrFormat to std::format would be easier? As long as we are assured at that we could remove |
I am afraid we'd need to keep printf-formatting for quite some time. Putting backends aside that use this, printf-formatting is used in parser that is autogenerated by Bison and is not ready for anything else :) |
Oh I am not concerned about printf in particular. More about switching from custom formatters (boost, absl) to the stdlib. |
I think it is easier to switch from abseil as it is "semantical" formatting by default. E.g. one specifies "%d" and we'd just need to replace it with |
25ec93a
to
778b0c6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is fine, we should replace absl::StrFormat
with std::format
once we have it available.
@@ -218,6 +218,8 @@ class ErrorReporter { | |||
Util::SourcePosition position = sources->getCurrentPosition(); | |||
position--; | |||
|
|||
// Unfortunately, we cannot go with statically checked format string | |||
// here as it would require some changes to yyerror |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are the changes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, well, there is some logic there, but essentially the format string is chosen programmatically. And we need it constexpr here.
…xed few bugs here and there.
…g's are misused everywhere in this code. But this is a subject of different task.
Util::printf_format
is often misused, error prone, redundant and therefore fully eliminated: one needs to useabsl::StrFormat
and then do explicitcstring
conversion if necessarySourceCodeBuilder
to use cord data structure from abseilSourceCode
in order to reduce cstrings for transient stuffFixes #4689