[debuginfo] Update cpp-like enum decoding docs to account for wrapping tag ranges.

This commit is contained in:
Michael Woerister 2022-07-20 16:15:02 +02:00
parent 171d8a3f57
commit 95d7591478

View File

@ -142,7 +142,7 @@ const SINGLE_VARIANT_VIRTUAL_DISR: u64 = 0;
/// let begin = variant_field.field("DISCR_BEGIN");
/// let end = variant_field.field("DISCR_END");
///
/// if tag >= begin && tag <= end {
/// if is_in_range(tag, begin, end) {
/// return (variant_field.field("NAME"), variant_field.value);
/// }
/// }
@ -169,7 +169,7 @@ const SINGLE_VARIANT_VIRTUAL_DISR: u64 = 0;
/// let end = (variant_field.field("DISCR128_END_LO").value as u128) |
/// (variant_field.field("DISCR128_END_HI").value as u128 << 64);
///
/// if tag >= begin && tag <= end {
/// if is_in_range(tag, begin, end) {
/// return (variant_field.field("NAME"), variant_field.value);
/// }
/// }
@ -180,6 +180,16 @@ const SINGLE_VARIANT_VIRTUAL_DISR: u64 = 0;
/// unreachable!();
/// }
///
/// // Check if a value is within the given range
/// // (where the range might wrap around the value space)
/// fn is_in_range(value, start, end) -> bool {
/// if start < end {
/// value >= start && value <= end
/// } else {
/// value >= start || value <= end
/// }
/// }
///
/// ```
pub(super) fn build_enum_type_di_node<'ll, 'tcx>(
cx: &CodegenCx<'ll, 'tcx>,