Skip to content

[clang][dataflow] Add bugprone-dataflow-dead-code check #139068

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Discookie
Copy link
Contributor

Finds instances of always-true and always-false conditions in branch statements, a straightforward use case for the dataflow framework.

This check is a work in progress - the core of the check is simple, but there are too many false positives currently for the check to be usable.
More heuristics are needed to reduce the count of false positives.

Currently only assert-like statements are filtered out. More information on false-positive types are in the docs here:
https://github.com/Discookie/llvm-project/blob/dataflow-deadcode/clang-tools-extra/docs/clang-tidy/checks/bugprone/dataflow-dead-code.rst

Results on some open-source projects

Framework improvements needed for the check to be fully functional:

  • A branch transfer function in the Diagnoser entity. The workaround for this missing function is wonky and causes many false positives.
  • Some kind of support for C++ classes. I can technically work this around inside my check, but first-class support for it would be nice.

Copy link

github-actions bot commented May 8, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

@Discookie Discookie force-pushed the dataflow-deadcode branch from 4df3967 to 19677fb Compare May 8, 2025 12:06
@Discookie Discookie force-pushed the dataflow-deadcode branch from 19677fb to 5efde30 Compare May 8, 2025 12:09
@Discookie Discookie changed the title [clang][dataflow][WIP] Add bugprone-dataflow-dead-code check [clang][dataflow] Add bugprone-dataflow-dead-code check May 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant