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

Shu-Chun Weng via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 14 11:21:01 PDT 2021


scw added inline comments.


================
Comment at: clang/unittests/Tooling/StencilTest.cpp:410
+  StringRef Id = "id";
+  testExpr(Id, Snippet, access(Id, "field"), "(*x).field");
+}
----------------
ymandel wrote:
> 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. :)
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.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100450/new/

https://reviews.llvm.org/D100450



More information about the cfe-commits mailing list