This is an archive of the discontinued LLVM Phabricator instance.

[clang][dataflow] Refactor `TestingSupport.h`
ClosedPublic

Authored by wyt on Aug 18 2022, 10:37 AM.

Details

Summary
  • Add AnalysisInputs struct as the parameters for checkDataflow, and renamed AnalysisData struct to AnalysisOutputs which contains the data structures generated from a dataflow analysis run.
  • Remove compulsory binding from statement to annotations. Instead, checkDataflow in the most general form takes a VerifyResults callback which takes as input an AnalysisOutputs struct. This struct contains the data structures generated by the analysis that can then be tested. We then introduce two overloads/wrappers of checkDataflow for different mechanisms of testing - one which exposes annotation line numbers and is not restricted to statements, and the other which exposes states computed after annotated statements. In the future, we should look at retrieving the analysis states for constructs other than statements.

Depends On D131616

Diff Detail

Event Timeline

wyt created this revision.Aug 18 2022, 10:37 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 18 2022, 10:37 AM
wyt requested review of this revision.Aug 18 2022, 10:37 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 18 2022, 10:37 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
wyt updated this revision to Diff 453708.Aug 18 2022, 10:45 AM

Small fixes.

gribozavr2 added inline comments.Aug 18 2022, 11:58 AM
clang/unittests/Analysis/FlowSensitive/TestingSupport.h
60

AnalysisInputs?

82–93

AnalysisOutputs?

125

Could we capture the lattice elements in the PostVisitCFG callback? It already receives the lattice element, we can easily copy it when the CFGElement is the Stmt of interest.

That should allow us to remove this function completely!

wyt updated this revision to Diff 454097.Aug 19 2022, 1:31 PM
wyt marked 2 inline comments as done.

Address comments: rename AnalysisArguments to AnalysisInputs and AnalysisData to AnalysisOutputs.

wyt edited the summary of this revision. (Show Details)Aug 19 2022, 2:00 PM
wyt added inline comments.Aug 19 2022, 2:07 PM
clang/unittests/Analysis/FlowSensitive/TestingSupport.h
125

Coming in next patch.

gribozavr2 accepted this revision.Aug 19 2022, 3:10 PM
This revision is now accepted and ready to land.Aug 19 2022, 3:10 PM
wyt updated this revision to Diff 454525.Aug 22 2022, 8:53 AM

Propagate change from parent patch.

wyt updated this revision to Diff 454535.Aug 22 2022, 9:16 AM

Rebase.

gribozavr2 accepted this revision.Aug 22 2022, 9:46 AM
sgatev accepted this revision.Aug 26 2022, 4:42 AM
sgatev added inline comments.
clang/unittests/Analysis/FlowSensitive/TestingSupport.h
60

Could you please indicate which members are mandatory and which are optional. Perhaps comments could start either with /// Mandatory. ... or /// Optional. ....

244

Should requirements include the full list of the requirements of checkDataflow below?

294–311

Let's clearly indicate that it's deprecated.

338–355

Let's clearly indicate that it's deprecated.

wyt updated this revision to Diff 456029.Aug 26 2022, 2:48 PM
wyt marked 4 inline comments as done.

Address comments.

wyt updated this revision to Diff 456032.Aug 26 2022, 3:01 PM

Fix typo and indentation.

gribozavr2 accepted this revision.Aug 26 2022, 3:18 PM
gribozavr2 added inline comments.Aug 26 2022, 3:47 PM
clang/unittests/Analysis/FlowSensitive/TestingSupport.h
125

(if possible)

139

(if possible)

175
254–255
264
wyt updated this revision to Diff 456305.Aug 29 2022, 4:45 AM
wyt marked 5 inline comments as done.

Address comments: add const qualifiers where applicable.

gribozavr2 accepted this revision.Aug 29 2022, 5:24 AM
wyt updated this revision to Diff 456978.Aug 31 2022, 8:35 AM

Remove use of designated initializers which are only allowed on C++20. Instead, introduce a constructor that sets required fields, and withFieldName methods that sets optional fields when constructing an AnalysisInputs struct.

Herald added a project: Restricted Project. · View Herald TranscriptAug 31 2022, 8:35 AM
wyt updated this revision to Diff 456980.Aug 31 2022, 8:48 AM

This is a re-update of a previous update which uploaded the wrong diff.
Remove use of designated initializers which are only allowed on C++20. Instead, introduce a constructor that sets required fields, and withFieldName methods that sets optional fields when constructing an AnalysisInputs struct.

gribozavr2 accepted this revision.Aug 31 2022, 9:07 AM
This revision was automatically updated to reflect the committed changes.