We are missing an else { WFD = 0; } here. So indeed it might be better to set WFD only in this inner if()..if()..if() clause, and using a new local var for caching dyn_cast<FunctionDecl>(*I->m_DGR.begin()); instead of using WFD.