Conversation
f974dc3 to
5e2c1f2
Compare
5e2c1f2 to
ad0acb0
Compare
| if (!cst->fitsInt()) { | ||
| ::P4::error(ErrorType::ERR_OVERLIMIT, | ||
| "%1$x: this implementation does not support bitstrings this large", cst); | ||
| "%1%: this implementation does not support bitstrings this large", cst); |
There was a problem hiding this comment.
This changes from printing the bitstring a hex to printing it as decimal, which seems less useful. Is there a way to have boost::formatter print in hex?
There was a problem hiding this comment.
%x should give hex printing if using the abseil formatter. Not quite clear how to migrate smoothly here...
The problem here in particular is that cst is a IR::Constant pointer and the operator<< for it doesn't generate hex. And, according to the reference files, this output already generated decimal format: https://github.com/p4lang/p4c/blob/main/testdata/p4_16_errors_outputs/width_e.p4-stderr#L1
ad0acb0 to
a961fbf
Compare
a961fbf to
8a65ab7
Compare
a1c3278 to
221f1eb
Compare
44aa52a to
65d38a9
Compare
65d38a9 to
5817abe
Compare
5817abe to
c5199ff
Compare
c5199ff to
7c379cf
Compare
| // 2. Call Abseil Format | ||
| std::string result; | ||
| absl::UntypedFormatSpec spec(formatSv); | ||
| if (!absl::FormatUntyped(&result, spec, abslArgs)) { |
There was a problem hiding this comment.
Why can't we use compile-time format checking?
There was a problem hiding this comment.
Iirc because boost::format uses runtime checks and you are able to pass string variables. Maybe we could tighten this if we detect the input is a string literal.
Or, if we do not permit string variables, compile-time checks are possible. But that is a significant breaking change.
e251137 to
3fbc91d
Compare
Signed-off-by: fruffy <fruffy@nyu.edu>
3fbc91d to
a37a807
Compare
We have recurring trouble with Boost as a dependency and want to gradually remove it from the compiler. Formatting is one of the harder pieces: error reporting and compiler bug macros are used throughout the compiler and back ends and many pieces rely on Boost’s formatting conventions.
This PR introduces an compatibility layer that uses Abseil and preserves existing format strings and diagnostic behavior. With this layer we can move the shared helpers off Boost without requiring every back end to migrate at once. It also gives us a migration path to adopt Abseil formatting over time.