This is an archive of the discontinued LLVM Phabricator instance.

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

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

Details

Summary

This extends smart pointer support beyond the existing maybeDeref and
maybeAddressOf.

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

Thanks!

clang/unittests/Tooling/StencilTest.cpp
410

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
clang/unittests/Tooling/StencilTest.cpp
410

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.