[clang] [llvm] [analyzer] New checker: optin.core.UnconditionalVAArg (PR #175602)
DonĂ¡t Nagy via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 26 05:35:42 PST 2026
NagyDonat wrote:
@steakhal Thanks for the informative reply!
> > I verified that the `BranchCondition` callback does not react to `switch` statements because although they perform branching, they don't have a branch _condition_ like the other statements.
>
> That's correct. I also documented this in the CheckerDocumentation of `checkBranchCondition` [here](https://clang.llvm.org/doxygen/classclang_1_1ento_1_1CheckerDocumentation.html#acec0e845a9dce2fac06bf3b1e136aff7):
>
> > * ternary operators (?:), gnu conditionals, gnu choose expressions Interestingly, switch statements don't seem to trigger BranchCondition.
Yes, I found that comment a few days after my initial confusion :sweat_smile:
> > * What do you think about this situation?
> > * Should I use the `BlockEntrance` callback or do you see another approach?
>
> I have no strong preference for using `BlockEntrance`. The `BranchCondition` should probably cover switches. If possible, `BlockEntrance` should be avoided as it gets triggered really frequently.
This fits with my plan that I would extend the `BranchCondition` callback to let it cover switches as well :smile:. That way, I'm eliminating a small piece of old technical debt, the new `BranchCondition` would be a comfortable tool for this checker, and I won't need to resort to `BlockEntrance`.
https://github.com/llvm/llvm-project/pull/175602
More information about the cfe-commits
mailing list