[PATCH] D132110: [IncludeCleaner] Handle more C++ constructs

Kadir Cetinkaya via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 18 01:24:24 PDT 2022


kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added a project: All.
kadircet requested review of this revision.
Herald added subscribers: cfe-commits, ilya-biryukov.
Herald added a project: clang-tools-extra.

This brings IncludeCleaner's reference discovery from AST to the parity
with current implementation in clangd. Some highlights:

- Handling of MemberExprs, only the member declaration is marked as referenced and not the container, unlike clangd.
- Constructor calls, only the constructor and not the container, unlike clangd.
- All the possible candidates for unresolved overloads, same as clangd.
- All the shadow decls for using-decls, same as clangd.
- Declarations for definitions of enums with an underlying type and functions, same as clangd.
- Using typelocs, using templatenames and typedefs only reference the found decl, same as clangd.
- Template specializations only reference the primary template, not the explicit specializations, to be fixed.
- Expr types aren't marked as used, unlike clangd.

Going forward, we can consider having signals to indicate type of a
reference (e.g. `implicit` signal for type of an expr) so that the
applications can perform a filtering based on their needs.
At the moment the biggest discrepancy is around type of exprs, i.e. not
marking containers for member/constructor accesses. I believe this is
the right model since the declaration of the member and the container
should be available in a single file (modulo macros).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D132110

Files:
  clang-tools-extra/include-cleaner/lib/WalkAST.cpp
  clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D132110.453560.patch
Type: text/x-patch
Size: 7304 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220818/0f000ab8/attachment-0001.bin>


More information about the cfe-commits mailing list