Qt-Autosar-A0.1.5¶
There shall be no unused named parameters in the set of parameters for a virtual function and all the functions that override it
Required inputs: IR
Bad code (unused parameter):
void ProcessData(int data, int unused) { // ERROR: unused parameter
std::cout << "Data: " << data << std::endl;
}
struct Foo {
virtual void VirtualFunc(const std::string& arg) {
// ERROR: parameter is unused here and in every overridden function
std::cout << "Virtual function called" << std::endl;
}
};
struct Bar : public Foo {
void VirtualFunc(const std::string& arg) override {
std::cout << "Overridden function called" << std::endl;
}
};
Good code (parameter removed when not needed):
void ProcessData(int data) { // OK: only needed parameters
std::cout << "Data: " << data << std::endl;
}
Good code (using (void) cast for C and older C++):
void Callback(int i) {
(void)i; // OK: clearly intentional, works in C and C++
ProcessEvent();
}
Good code (using C++17 [[maybe_unused]]):
struct Foo {
virtual void VirtualFunc([[maybe_unused]] const std::string& arg) {
// OK: explicitly marked as intentionally unused
std::cout << "Virtual function called" << std::endl;
}
};
Good code (using unnamed parameter):
void Callback(int /*unused_parameter*/) { // OK: clearly intentional
ProcessEvent();
}
Possible Messages
Key |
Text |
Severity |
Disabled |
|---|---|---|---|
unused_parameter |
Unused named parameter of virtual function |
None |
False |
Options¶
This rule shares the following common options: exclude_in_macros, exclude_messages_in_system_headers, excludes, extend_exclude_to_macro_invocations, includes, justification_checker, languages, post_processing, provider, report_at, severity
The following places define options that affect this rule: Stylechecks, Analysis-GlobalOptions
ignore_address_taken_functions¶
ignore_address_taken_functions : bool = False
inspect_constexprs¶
inspect_constexprs : bool = False
inspect_nonvirtual_functions¶
inspect_nonvirtual_functions : bool = False
inspect_virtual_functions¶
inspect_virtual_functions : bool = True
inspect_virtual_functions_directly¶
inspect_virtual_functions_directly : bool = False
report_all_virtual_functions¶
report_all_virtual_functions : bool = False
report_unnamed_parameters¶
report_unnamed_parameters : bool = False
suppress_attribute_maybe_unused¶
suppress_attribute_maybe_unused : FilterAction = 'suppress'
[[maybe_unused]] or __attribute__((unused)).
If set to "suppress", findings will be reported but marked as suppressed.
If set to "exclude", findings will not be reported at all.
If set to "normal", no special treatment is applied and the finding is reported as usual.
Option Types¶
These types are used by options listed above:
FilterAction¶
Used for the return value of add_filter() callbacks.normal
The violation proceeds as usual.exclude
The violation is excluded: The violation is discarded as if `--exclude` applied to it. The following filters won't get to see the violation, and it will not be imported into the database under any circumstances.suppress
The violation is suppressed as if `AXIVION DISABLE` applied to it. Whether the violation gets imported into the database is controlled by the Axivion CI configuration.