diff --git a/src/cfg/cfg_tests.rs b/src/cfg/cfg_tests.rs index f707fbd3..e04bfdc3 100644 --- a/src/cfg/cfg_tests.rs +++ b/src/cfg/cfg_tests.rs @@ -4075,7 +4075,10 @@ class C { "#; let (cfg, _entry) = parse_and_build(src, "java", ts_lang); let ifs = if_nodes(&cfg); - let arith: Vec<_> = ifs.iter().filter_map(|&n| cfg[n].cond_arith.clone()).collect(); + let arith: Vec<_> = ifs + .iter() + .filter_map(|&n| cfg[n].cond_arith.clone()) + .collect(); // Exactly one If condition is a pure int-arith comparison; the // `s.length() > 200` one must NOT be captured (it contains a call). diff --git a/src/cfg/literals.rs b/src/cfg/literals.rs index 214c5086..306f97b1 100644 --- a/src/cfg/literals.rs +++ b/src/cfg/literals.rs @@ -1202,9 +1202,17 @@ pub(super) fn is_syntactic_literal(node: Node, code: &[u8]) -> bool { // (`decimal_integer_literal`, `hex_integer_literal`, …) rather than a // bare `integer`, so `int num = 86;` would otherwise miss this arm and // lower to `Const(None)` (Varying) instead of `Const("86")`. - "integer" | "integer_literal" | "int_literal" | "float" | "float_literal" | "number" - | "decimal_integer_literal" | "hex_integer_literal" | "octal_integer_literal" - | "binary_integer_literal" | "decimal_floating_point_literal" + "integer" + | "integer_literal" + | "int_literal" + | "float" + | "float_literal" + | "number" + | "decimal_integer_literal" + | "hex_integer_literal" + | "octal_integer_literal" + | "binary_integer_literal" + | "decimal_floating_point_literal" | "hex_floating_point_literal" => true, // Booleans / null / nil / none diff --git a/src/cfg/mod.rs b/src/cfg/mod.rs index ccaff500..26f5097f 100644 --- a/src/cfg/mod.rs +++ b/src/cfg/mod.rs @@ -510,12 +510,14 @@ impl CondArith { BinOp::BitAnd => arith(Some(lhs & rhs)), BinOp::BitOr => arith(Some(lhs | rhs)), BinOp::BitXor => arith(Some(lhs ^ rhs)), - BinOp::LeftShift => { - u32::try_from(rhs).ok().and_then(|s| lhs.checked_shl(s)).map(CondVal::Int) - } - BinOp::RightShift => { - u32::try_from(rhs).ok().and_then(|s| lhs.checked_shr(s)).map(CondVal::Int) - } + BinOp::LeftShift => u32::try_from(rhs) + .ok() + .and_then(|s| lhs.checked_shl(s)) + .map(CondVal::Int), + BinOp::RightShift => u32::try_from(rhs) + .ok() + .and_then(|s| lhs.checked_shr(s)) + .map(CondVal::Int), BinOp::Eq => Some(CondVal::Bool(lhs == rhs)), BinOp::NotEq => Some(CondVal::Bool(lhs != rhs)), BinOp::Lt => Some(CondVal::Bool(lhs < rhs)), @@ -1418,13 +1420,22 @@ fn parse_int_literal(node: Node, code: &[u8]) -> Option { if let Ok(v) = cleaned.parse::() { return Some(v); } - if let Some(h) = cleaned.strip_prefix("0x").or_else(|| cleaned.strip_prefix("0X")) { + if let Some(h) = cleaned + .strip_prefix("0x") + .or_else(|| cleaned.strip_prefix("0X")) + { return i64::from_str_radix(h, 16).ok(); } - if let Some(o) = cleaned.strip_prefix("0o").or_else(|| cleaned.strip_prefix("0O")) { + if let Some(o) = cleaned + .strip_prefix("0o") + .or_else(|| cleaned.strip_prefix("0O")) + { return i64::from_str_radix(o, 8).ok(); } - if let Some(b) = cleaned.strip_prefix("0b").or_else(|| cleaned.strip_prefix("0B")) { + if let Some(b) = cleaned + .strip_prefix("0b") + .or_else(|| cleaned.strip_prefix("0B")) + { return i64::from_str_radix(b, 2).ok(); } None @@ -1479,7 +1490,10 @@ fn build_cond_arith(node: Node, lang: &str, code: &[u8], depth: u32) -> Option Option