Miscellaneous-NoTypeConversionToBool¶
Do not use type conversions to bool, use value comparison
Required inputs: IR
void (int i, float* pf)
{
if (i != 0)
{
}
if (pf != NULL)
{
}
}
Possible Messages
Key |
Text |
Severity |
Disabled |
|---|---|---|---|
cast_changes_type_category |
Conversion to bool - use value comparison instead. |
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
category_changes¶
category_changes
List of (from, to) type category pairs to check for. Both from and to are lists of categories.Type: list[typing.Tuple[typing.Set[bauhaus.ir.common.types.type_systems.TypeCategory], typing.Set[bauhaus.ir.common.types.type_systems.TypeCategory]]]
Default:
[({'bool_types', 'char_types', 'enum_types', 'float_types', 'function_pointer_types', 'incomplete_pointer_types', 'null_pointer_types', 'object_pointer_types', 'other_types', 'signed_types', 'unsigned_types', 'void_pointer_types', 'void_types'}, {'bool_types'})]
check_explicit_casts¶
check_explicit_casts : bool = True
check_implicit_casts¶
check_implicit_casts : bool = True
look_through_casts¶
look_through_casts : bool = False
only_complex_expressions¶
only_complex_expressions : bool = False
show_operand_in_entity¶
show_operand_in_entity : bool = False
type_system¶
type_system : bauhaus.ir.common.types.type_systems.TypeSystem = <bauhaus.ir.common.types.type_systems.CompilerTypeSystem object at 0x7f6f1c5fd510>
Option Types¶
These types are used by options listed above:
TypeCategory¶
Base class for the different type categories.signed_types
unsigned_types
float_types
char_types
plain char.bool_types
bool, _Bool and special expressions.enum_types
void_types
void_pointer_types
incomplete_pointer_types
function_pointer_types
object_pointer_types
null_pointer_types
other_types
Those not covered by other categories.