This is an archive of the discontinued LLVM Phabricator instance.

[clang][dataflow] Convert `PointeeLoc` of `PointerValue` from reference to pointer.
AbandonedPublic

Authored by wyt on Jun 14 2022, 7:53 AM.

Details

Summary

This allows PointeeLoc to be empty in the case of nullptr.

Depends On D127745

Diff Detail

Event Timeline

wyt created this revision.Jun 14 2022, 7:53 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 14 2022, 7:53 AM
wyt requested review of this revision.Jun 14 2022, 7:53 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 14 2022, 7:53 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
wyt updated this revision to Diff 436817.Jun 14 2022, 9:23 AM

Update naming of getPointeeLoc with respect to change in parent

sgatev added inline comments.Jun 14 2022, 10:27 AM
clang/include/clang/Analysis/FlowSensitive/Value.h
189

Can you please document when this can be null?

clang/lib/Analysis/FlowSensitive/Transfer.cpp
266–267

Can you please add a test for this?

ymandel retitled this revision from [clang][dataflow] Convert `PointeeLoc` of PointerValue from reference to pointer. This allows PointeeLoc to be empty in the case of `nullptr` to [clang][dataflow] Convert `PointeeLoc` of `PointerValue` from reference to pointer. .Jun 14 2022, 2:13 PM
ymandel edited the summary of this revision. (Show Details)

Overall, this seems to be an important API change, and I'm having trouble seeing the big picture here. I think it would be great if you could expand (in the CL description) on the motivation behind the change and the thinking behind the particular design choices you've made here. For example, you mentioned that this change supports explicit modeling of nullptr, but what is gained by this explicit modeling? Also, regarding the design choice itself: is the intent that native nullptr now represents an interpreted nullptr? If so, have you considered instead introducing an explicit NullptrLocation or the like and if so, what were the tradeoffs in this decision?

clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
332

Please document the conditions under which these functions return nullptr.

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

If I understand correctly, the nullptr result from this function is now ambiguous: either there's no entry for that storagelocation, or there is and it is null. But, perhaps I'm misunderstanding -- is this not a concern?

clang/lib/Analysis/FlowSensitive/Transfer.cpp
266–267

How does this work in practice? It seems to be an unsual case that we statically know a pointer is null. So, what is the use of this change and (more importantly) what is the impact on the framework, if any?

wyt abandoned this revision.Jun 27 2022, 2:48 AM