This is an archive of the discontinued LLVM Phabricator instance.

[clang][dataflow] Analyze method bodies
ClosedPublic

Authored by samestep on Aug 4 2022, 7:26 AM.

Details

Summary

This patch adds the ability to context-sensitively analyze method bodies, by moving ThisPointeeLoc from DataflowAnalysisContext to Environment, and adding code in pushCall to set it.

Diff Detail

Event Timeline

samestep created this revision.Aug 4 2022, 7:26 AM
Herald added a project: Restricted Project. · View Herald Transcript
samestep requested review of this revision.Aug 4 2022, 7:26 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 4 2022, 7:26 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
sgatev added inline comments.Aug 4 2022, 7:33 AM
clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
383–385

Let's add a brief comment explaining what this is and when it is expected to be non-null.

clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
218

What if Arg is null?

samestep added inline comments.Aug 4 2022, 8:03 AM
clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
383–385

Will do, thanks.

clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
218

Good point, thanks; under what circumstances can that happen? In any case, I'm adding a guard for this.

samestep updated this revision to Diff 449986.Aug 4 2022, 8:05 AM

Address Stanislav's comments

sgatev accepted this revision.Aug 4 2022, 8:45 AM
sgatev added inline comments.
clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
218

It can be null if the argument isn't modeled and there's no value assigned to its storage location.

This revision is now accepted and ready to land.Aug 4 2022, 8:45 AM
samestep added inline comments.Aug 4 2022, 8:48 AM
clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
218

Hmm I don't quite follow; Arg just comes from calling getImplicitObjectArgument on the CXXMemberCallExpr, right? So shouldn't it only depend on the AST, and be completely independent of what we do or don't model?

sgatev added inline comments.Aug 4 2022, 8:58 AM
clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
218

Ah, right. Well, I'm not familiar with the details, but apparently it returns null in some cases.

xazax.hun accepted this revision.Aug 4 2022, 8:59 AM
ymandel accepted this revision.Aug 4 2022, 9:36 AM

Nice!!

This revision was landed with ongoing or failed builds.Aug 4 2022, 10:45 AM
This revision was automatically updated to reflect the committed changes.