[PATCH] D122677: [prototype] include-cleaner library

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 29 11:55:13 PDT 2022


sammccall created this revision.
Herald added subscribers: carlosgalvezp, usaxena95, arphaman, mgrang, mgorny.
Herald added a project: All.
sammccall requested review of this revision.
Herald added subscribers: cfe-commits, ilya-biryukov.
Herald added a project: clang-tools-extra.

See RFC
https://discourse.llvm.org/t/rfc-lifting-include-cleaner-missing-unused-include-detection-out-of-clangd/61228

This includes

- a prototype library for IWYU analysis (include-cleaner/{lib,include})
- a standalone tool (include-cleaner/tool)
- replacing clangd's unused-include warning with the library
- adding a new clangd hover interaction
- a clang-tidy unused-include check

This squashes together quite a few patches worth of scope, has no tests, and
designs are half baked. Still it demonstrates that such a library could be
reused across tools & across unused vs missing warnings.

Some significant things that are missing:

- IWYU pragma support and other non-self-contained-header patterns
- ability to sensibly rank suggested includes. (Probably requires a design change to preserve the Node->Symbol->Location->Header DAG)
- better standard library support (macros)
- general accuracy
- missing-include integration for clang-tidy and clangd (mechanical really)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D122677

Files:
  clang-tools-extra/CMakeLists.txt
  clang-tools-extra/clang-tidy/misc/CMakeLists.txt
  clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp
  clang-tools-extra/clang-tidy/misc/UnusedIncludesCheck.cpp
  clang-tools-extra/clang-tidy/misc/UnusedIncludesCheck.h
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/IncludeCleaner.cpp
  clang-tools-extra/clangd/IncludeCleaner.h
  clang-tools-extra/include-cleaner/CMakeLists.txt
  clang-tools-extra/include-cleaner/README.md
  clang-tools-extra/include-cleaner/include/clang-include-cleaner/Analysis.h
  clang-tools-extra/include-cleaner/include/clang-include-cleaner/Hooks.h
  clang-tools-extra/include-cleaner/include/clang-include-cleaner/Policy.h
  clang-tools-extra/include-cleaner/include/clang-include-cleaner/Types.h
  clang-tools-extra/include-cleaner/lib/Analysis.cpp
  clang-tools-extra/include-cleaner/lib/AnalysisInternal.h
  clang-tools-extra/include-cleaner/lib/CMakeLists.txt
  clang-tools-extra/include-cleaner/lib/Headers.cpp
  clang-tools-extra/include-cleaner/lib/Hooks.cpp
  clang-tools-extra/include-cleaner/lib/Locations.cpp
  clang-tools-extra/include-cleaner/lib/Types.cpp
  clang-tools-extra/include-cleaner/lib/WalkAST.cpp
  clang-tools-extra/include-cleaner/tool/CMakeLists.txt
  clang-tools-extra/include-cleaner/tool/ClangIncludeCleaner.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D122677.418944.patch
Type: text/x-patch
Size: 64018 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220329/c535aa58/attachment-0001.bin>


More information about the cfe-commits mailing list