[all-commits] [llvm/llvm-project] 772fc6: [IncludeCleaner] Handle more C++ constructs

kadir çetinkaya via All-commits all-commits at lists.llvm.org
Tue Oct 25 00:59:04 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 772fc63f5bb50996370797e55682dd65960d921a
      https://github.com/llvm/llvm-project/commit/772fc63f5bb50996370797e55682dd65960d921a
  Author: Kadir Cetinkaya <kadircet at google.com>
  Date:   2022-10-25 (Tue, 25 Oct 2022)

  Changed paths:
    M clang-tools-extra/include-cleaner/lib/WalkAST.cpp
    M clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
    M clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp

  Log Message:
  -----------
  [IncludeCleaner] Handle more C++ constructs

Summary:
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).

Reviewers: sammccall

Subscribers:

Differential Revision: https://reviews.llvm.org/D132110




More information about the All-commits mailing list