This is an archive of the discontinued LLVM Phabricator instance.

[clang][dataflow] Generalize custom comparison to return tri-value result.
ClosedPublic

Authored by ymandel on Nov 3 2022, 5:53 AM.

Details

Summary

Currently, the API for a model's custom value comparison returns a
boolean. Therefore, models cannot distinguish between situations where the
values are recognized by the model and different and those where the values are
just not recognized. This patch changes the return value to a tri-valued enum,
allowing models to express "don't know".

This patch is essentially a NFC -- no practical differences result from this
change in this patch. But, it prepares for future patches (particularly,
upcoming patches for widening) which will take advantage of the new flexibility.

Driveby: fixed spelling of IsOptionalType to match style guide.

Diff Detail

Event Timeline

ymandel created this revision.Nov 3 2022, 5:53 AM
Herald added a project: Restricted Project. · View Herald Transcript
ymandel requested review of this revision.Nov 3 2022, 5:53 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 3 2022, 5:53 AM
ymandel edited the summary of this revision. (Show Details)Nov 3 2022, 5:55 AM
sgatev added inline comments.Nov 3 2022, 8:56 AM
clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
52

Alternative that I slightly prefer - ComparisonResult.

75

Perhaps replace "does not" with "can't"?

clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
365–366

Why is it same if IsSet1 is null and IsSet2 isn't null?

1185

Why remove this? It's not the same as the default implementation, right?

ymandel updated this revision to Diff 472975.Nov 3 2022, 10:07 AM
ymandel marked 2 inline comments as done.

address comments

ymandel marked 2 inline comments as done.Nov 3 2022, 10:07 AM
ymandel added inline comments.
clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
365–366

Fixed. that was a mistake.

1185

Correct -- that was a mistake (I think my first version had a sound default, which I later put back as unsound to keep this NFC).

gribozavr2 accepted this revision.Nov 3 2022, 10:10 AM
gribozavr2 added inline comments.
clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
73–74
clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
1188–1191
This revision is now accepted and ready to land.Nov 3 2022, 10:10 AM
ymandel updated this revision to Diff 472978.Nov 3 2022, 10:15 AM

address comments

ymandel marked 2 inline comments as done.Nov 3 2022, 10:16 AM
sgatev accepted this revision.Nov 3 2022, 10:36 AM
xazax.hun accepted this revision.Nov 3 2022, 11:40 AM
This revision was landed with ongoing or failed builds.Nov 3 2022, 4:31 PM
This revision was automatically updated to reflect the committed changes.