This is an archive of the discontinued LLVM Phabricator instance.

[clang][dataflow] Change transfer and diagnoser functions to receive a CFGElement
AcceptedPublic

Authored by merrymeerkat on Nov 4 2022, 8:28 AM.

Details

Summary

Previously, the diagnoser function returned an AST element that was faulty.
If the dataflow analysis wanted to warn about Stmts and CXXCtorInitializers, or any AST elements without a common base class, we had to choose which type to return.

Now, diagnosers receive and return a CFGElement and can thus warn about any type of C++ construct.

Diff Detail

Event Timeline

merrymeerkat created this revision.Nov 4 2022, 8:28 AM
Herald added a project: Restricted Project. · View Herald Transcript
merrymeerkat requested review of this revision.Nov 4 2022, 8:28 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 4 2022, 8:28 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
merrymeerkat retitled this revision from [clang][dataflow] Change transfer and diagnoser functions to receive a CFGElement. to [clang][dataflow] Change transfer and diagnoser functions to receive a CFGElement.Nov 4 2022, 8:36 AM
merrymeerkat edited the summary of this revision. (Show Details)
merrymeerkat added reviewers: ymandel, gribozavr, sgatev.
gribozavr2 accepted this revision.Nov 4 2022, 8:37 AM
This revision is now accepted and ready to land.Nov 4 2022, 8:37 AM
xazax.hun added inline comments.Nov 4 2022, 8:43 AM
clang/include/clang/Analysis/FlowSensitive/CFGMatchSwitch.h
35

Why do we need to keep this pointer on the heap?

Thanks for this patch! Unfortunately, I'm having trouble following the change. Can you expand the description to give a more detailed explantion of the motivation and the key point that are changing? Unfortunately, I don't understand the motivation for the new API and am even having trouble finding where the changes were made that correspond to the new API used by clients. Maybe that would be good to include in the description? That is, call out the key old API that's being upgraded and write the explanation with respect to the old and the new?

Thanks!

clang/include/clang/Analysis/FlowSensitive/CFGMatchSwitch.h
33

nit: just wanted to double check on the formatting: i'm used to seeing class put on a new line.

35

Can you please explain the need for the unique pointer?

42

Where is this field used?

150–151

Please add a comment explaining the design pattern. I'm not quite clear on why we're taking this approach, so it would probably be generally useful to explain to future readers.

clang/include/clang/Analysis/FlowSensitive/MatchSwitch.h
52

should this change too?

clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
280

Here and below: if the callee does not use the paramter, drop its name.

280–281

This seems a surprising API choice. Once the callee is getting the element as statement at a specific type, why does it need the element?