@@ -1200,24 +1200,20 @@ struct SingleValueFlowAnalyzer : ValueFlowAnalyzer {
12001200 {
12011201 if (value.isImpossible ())
12021202 return false ;
1203- // Lifetime values must keep flowing through conditions to detect dangling dereferences on every path.
1203+ // lifetime values must keep flowing to find dangling derefs on all paths
12041204 if (value.isLifetimeValue ())
12051205 return false ;
1206- // A value carrying the explicit 'conditional' flag (e.g. an uninitialized value, or a value lowered
1207- // to possible after a branch that modifies the variable) can depend on conditions that don't mention
1208- // the variable itself, so stop at any subsequent condition to stay conservative.
1206+ // 'conditional' flag (uninit, or lowered after a modifying branch): may depend on a
1207+ // condition that doesn't mention the variable -> stop
12091208 if (value.conditional && !value.isKnown ())
12101209 return true ;
12111210 if (value.isNonValue ())
12121211 return false ;
12131212 if (value.isSymbolicValue ())
12141213 return isConditional () && !value.isKnown ();
1215- // The value may still be conditional via the originating 'condition' token (e.g. a possible null
1216- // pointer after 'if (p && ...)'). Such a value may keep flowing past a later condition, but only
1217- // when that condition actually refers to the tracked value: then cppcheck can reason about how the
1218- // condition constrains it. If the value is not mentioned, a correlation that cppcheck cannot follow
1219- // during forward analysis (e.g. 'bool ok = (p != nullptr); if (!ok) return;') could make a later
1220- // dereference safe, so stop conservatively to avoid false positives.
1214+ // conditional via the originating 'condition' (e.g. possible null after 'if (p && ...)'): only flow
1215+ // if the condition references the value, else a correlation we can't follow (e.g.
1216+ // 'bool ok = (p != nullptr); if (!ok)') could make a later deref safe -> stop
12211217 if (value.condition && !value.isKnown () && !conditionReferencesValue (condTok))
12221218 return true ;
12231219 ConditionState cs = analyzeCondition (condTok);
0 commit comments