1.5.41. Migration to 7.6.2

1.5.41.1. Stylechecks

FaultDetection-DeadBranches

The following rules report the effects of constant logical expressions, such as dead branches.

For these rules, the message texts have been updated to reflect the actual violations more precisely. The following new message subtypes have also been introduced:

  • loop_cond_true: Loop condition is always true

  • loop_cond_true_type_limits: Loop condition is always true due to limited range of data type

  • loop_cond_false: Loop body is dead, condition is always false

  • loop_cond_false_type_limits: Loop body is dead, condition is always false due to limited range of data type

  • do_while_only_once: Loop is only executed once, loop condition is always false

  • do_while_only_once_type_limits: Loop is only executed once, loop condition is always false due to limited range of data type

  • subexpression_true: Subexpression always evaluates to true

  • subexpression_false: Subexpression always evaluates to false

  • subexpression_true_type_limits: Subexpression always evaluates to true due to limited range of data type

  • subexpression_false_type_limits: Subexpression always evaluates to false due to limited range of data type

  • unreachable_short_circuit: Subexpression never evaluated due to short-circuiting operator

These new message subtypes represent subsets of existing messages, except for unreachable_short_circuit, which produces new messages.

For example, the following code will now produce two messages for rule MisraC++-0.1.2: one of type subexpression_false and another of type unreachable_short_circuit.

bool trivial_shortcircuit()
{
   int x = 1;
   return x != 1 && x != 0;
   //^stdout:14: required: Subexpression always evaluates to false [x!=1] (Rule MisraC++-0.1.2)
   //^^stdout:24: required: Subexpression never evaluated due to short-circuiting operator [x!=0] (Rule MisraC++-0.1.2)
}

These messages can be disabled by setting the option msg/<subkey>/disabled to false in the respective rule.

AutosarC++-A2.7.3, Generic-DoxygenComment, Generic-NoFunctionCommentInImpl

The recognition of Doxygen (and other) comments has been extended to support trailing comments and improved regarding the search for comment tokens. A frequent problem was that leading comments in a file were mistaken for comments of the first definition. This caused false positives for the rule Generic-NoFunctionCommentInImpl and false negatives for the rules Generic-DoxygenCommentAtDefinition and AutosarC++-A2.7.3 (or AutosarC++-A2.8.3). The following rules have been extended with new options:

All these rules now include a new option, stop_tokens, to configure the set of tokens that stop the search for comment tokens. The aforementioned false negatives and positives are reduced by the addition of the "#include" token. However, in rare cases where "#include" is intended to be part of the beginning of a definition, this may cause other false negatives or positives.

In addition to the rule Generic-NoFunctionCommentInImpl, which only handles plain comments rather than Doxygen comments, the following options have also been added:

  • lines_before: Maximum number of lines to search upwards for comment tokens

  • doxygen_trailer: Recognize trailing Doxygen comments as well

  • lines_after: Maximum number of lines to search downwards for trailing comments

  • add_extra_info: A flag to provide extra output for comment recognition

The maximum line number options can be set high enough to ensure backward compatibility.