A parameter of a class type with virtual functions is taken by value, which slices objects of derived classes
What it finds
Passing a derived object to a parameter of its base class type copies only the base part; virtual calls inside the function then run the base versions. A reference or pointer keeps the object whole. The class must be defined in the file.
From the rule's source, polymorphic_parameter_by_value.rs.
Turn it on, off or suppress it
The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/cpp:polymorphic-parameter-by-value" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/cpp:polymorphic-parameter-by-value] reason="..."tx0 explain tx0/cpp:polymorphic-parameter-by-value shows the same in the terminal. Found a false positive? Report it.