[PATCH] D110825: [clangd] Handle members of anon structs in SelectionTree
Sam McCall via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 30 08:04:46 PDT 2021
sammccall added inline comments.
================
Comment at: clang-tools-extra/clangd/Selection.cpp:443
// It would be nice if RAV handled this (!shouldTraverseImplicitCode()).
if (auto *CTI = llvm::dyn_cast<CXXThisExpr>(S))
if (CTI->isImplicit())
----------------
kadircet wrote:
> sammccall wrote:
> > seems like it'd be more consistent to handle it here?
> >
> > If it's a MemberExpr and the member is in an anonymous struct, then it's implicit if `isImplicit(ME.getBase())`.
> the test case was actually to demonstrate why we can't do it here. we want to still keep traversing the AST after hitting a field inside an anon struct. handling here terminates the traversal for that subtree completely, and the real node we are interested might be down the tree (`y.[[x]]` in the test case).
That's what I meant by `isImplicit(ME.getBase())`
The following passes tests (added to isImplicit)...
```
if (auto *ME = llvm::dyn_cast<MemberExpr>(S))
if (auto *FD = llvm::dyn_cast<FieldDecl>(ME->getMemberDecl()))
if (FD->isAnonymousStructOrUnion())
return isImplicit(ME->getBase());
```
> and the member is in an anonymous struct
Oops, I meant "and the member *is* an anonymous struct".
It seems more natural to recognize and special-case the field-access to the anon struct itself (which is intuitively implicit!), than the one to a normal field within it.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D110825/new/
https://reviews.llvm.org/D110825
More information about the cfe-commits
mailing list