Because it communicates what the caller expects: "I have left this
uninitialized because I expect my "v" argument to be the kind of visitor
that fills it in". It's this argument that gives me the confidence
needed to shut up Coverity's false positives.
Embedding the visitor type in the signature makes it impossible not to
pass it, unlike e.g. an assertion in every getter or setter.
I think we got two kinds of code calling visitor methods:
1. Code for use with one kind of visitor only
We get to pass a literal argument to the additional parameter you
propose.
2. Code for use with arbitrary visitors (such as qapi-visit*.c)
We need to pass v->type, where @v is the existing visitor argument.
Except we can't: struct Visitor and VisitorType are private, defined
in <visitor-impl.h>. Easy enough to work around, but has a distinct
"this design is falling apart" smell, at least to me.
Note that "intent explicit in every method call" is sufficient, but not
necessary for "intent is locally explicit, which lets us dismiss false
positives with confidence". We could do "every function that calls
methods". Like checking a precondition. We already have
visit_is_input(). We could have visit_is_output().
The sane way to make output intent explicit is of course passing the
thing by value rather than by reference. To get that, we could generate
even more code. So, if the amount of code we currently generate isn't
disgusting enough, ...