Issue 141602
Summary [clang][dataflow] Diagnose branch conditions using the data-flow framework
Labels clang:dataflow
Assignees Discookie
Reporter Discookie
    I'm currently working on a prototype dead-code check using the data-flow framework: https://github.com/llvm/llvm-project/pull/139068
The check works by finding loop conditions that are always true or always false, and emitting an error there.
However, the dataflow framework's Diagnoser entity doesn't have the ability to diagnose specifically loop conditions. It only has the ability to diagnose expressions.
(The workaround for this is to tag the loop conditions separately, but it's most definitely not a sound workaround, since the tags are also visible in unexpected places.)

There needs to be a way to diagnose specifically loop conditions, in a way that is known to the Diagnoser.
Ideally this diagnosis would be done in a way where both the normal Expr diagnoser, and the condition diagnoser are part of the same function.

Currently I'm thinking to add another overload to operator() in the Diagnoser class, into the DiagnosisCallback here:
https://github.com/llvm/llvm-project/blob/904d0c293e4de2c63ef473bbd2b1d3f56f113402/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h#L199-L202
But at that point it might be better to move the branch-diagnoser into a named function inside the same class.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to