This is an archive of the discontinued LLVM Phabricator instance.

[clang][dataflow] Add flowConditionIsTautology function
ClosedPublic

Authored by li.zhe.hua on May 4 2022, 10:17 AM.

Details

Summary

Provide a way for users to check if a flow condition is
unconditionally true.

Diff Detail

Event Timeline

li.zhe.hua created this revision.May 4 2022, 10:17 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 4 2022, 10:17 AM
li.zhe.hua requested review of this revision.May 4 2022, 10:17 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 4 2022, 10:17 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript

The code looks good, but what is the intended application?

This allows me to query when an expression is always encountered/executed. Alternatively, if I have a set of interesting expressions, I can note the flow condition at every expression, compute the disjunction of the set of flow conditions, and determine if execution will always encounter an interesting expression.

xazax.hun accepted this revision.May 4 2022, 3:50 PM

The code looks good to me too. I was also wondering what sort of check will need this info.

This revision is now accepted and ready to land.May 4 2022, 3:50 PM
sgatev accepted this revision.May 4 2022, 8:42 PM
sgatev added inline comments.
clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h
176–177
clang/unittests/Analysis/FlowSensitive/DataflowAnalysisContextTest.cpp
144
151

I don't think this is doing what the comment above it says. We probably shouldn't add flow conditions directly as constraints because this isn't tracking flow condition dependencies. I suggest removing this case and keeping the one with FC5.

154

Again, I suggest removing this case. The one with FC6 should suffice.

I'm playing around with a tool to take raw pointers and add a non-null annotation or convert them to references, for code that is assumed to be correct. So in this case, "interesting expression" is anything that would be UB if the pointer was null, e.g. dereferencing the pointer.

li.zhe.hua updated this revision to Diff 427183.May 4 2022, 8:53 PM

Address reviewer comments.

li.zhe.hua marked 4 inline comments as done.May 4 2022, 8:54 PM

Ah, good catch regarding the flow condition deps not being tracked. Thanks for the review!

This revision was landed with ongoing or failed builds.May 4 2022, 8:58 PM
This revision was automatically updated to reflect the committed changes.