Page MenuHomePhabricator

[libTooling] Add smart pointer support to the `access` Stencil

Authored by scw on Apr 14 2021, 12:15 AM.



This extends smart pointer support beyond the existing maybeDeref and

Diff Detail

Event Timeline

scw requested review of this revision.Apr 14 2021, 12:15 AM
scw created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptApr 14 2021, 12:15 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
ymandel accepted this revision.Apr 14 2021, 5:39 AM



Hmm. Looks like we could use smart pointer support in tooling::buildAddressOf as well. If you're interested, the code is at
clang/lib/Tooling/Transformer/SourceCodeBuilders.cpp line 94
but I understand if you want to stop here. :)

This revision is now accepted and ready to land.Apr 14 2021, 5:39 AM
scw added inline comments.Apr 14 2021, 11:21 AM

I don't think this particular output "(*x).field" is from buildAddressOf. Instead, it's in buildDot where *x is x.operator*() instead of UO_Deref. Yes, there's potential improvement but at least it's correct output comparing to this change which fixes "x->->field" so I'm leaving it along just adding the test case to highlight the potential.

As for buildAddressOf, we shouldn't change &*x to x when x is a smart pointer -- the types don't match and may result in ill-typed expressions.