Skip to content

Remove label style from printing context

Krzysztof Gogolewski requested to merge wip/styled-labels-final into master

Right now, when we print an SDoc in the code generator, the printing context contains style used for labels: either PprCode CStyle or PprCode AsmStyle. The pdoc method for labels reads that context and passes it to pprCLabel.

I have thoroughly investigated all call sites, and it turns out that in every case, the style used by pdoc (C vs Asm) is known statically. So instead of calling pdoc, we can call pprCLabel with the appropriate style. This way we no longer need the parameter to PprCode.

I am adding here an assertion that the pdoc function for CLabel is not used for code generation. In the future, we'll decouple codegen from pretty-printing (#21853 (closed)), so I don't consider this partiality to be a big problem.

There's a change to T15155, the output of -ddump-asm now uses the Asm style (which is faithful to what actually happens).

There are four commits for easier review, I'll squash before merging.

@hsyl20 might be interested

Merge request reports