[PATCH] D148793: [clang-tidy] Implement an include-cleaner check.
Haojian Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed May 31 02:29:44 PDT 2023
hokein added inline comments.
================
Comment at: clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp:170-175
+ diag(Inc.SymRefLocation, "missing include %0")
+ << Inc.MissingHeaderSpelling
+ << FixItHint::CreateInsertion(
+ SM->getComposedLoc(SM->getMainFileID(),
+ Replacement->getOffset()),
+ Replacement->getReplacementText());
----------------
PiotrZSL wrote:
> Use IncludeInserter::createIncludeInsertion if possible...
> So include style would be properly handled.
`tooling::HeaderIncludes` already handles the include style well (and more). In general, we recommend to use `tooling::headerIncludes` -- it was built for generic toolings that need to perform #include manipulations, it has been heavily used in clangd/clang-format/clang-include-cleaner etc.
`IncludeInserter::createIncludeInsertion` is an old implementation in clang-tidy, and it was built before `tooling::HeaderIncludes` is thing. In the long-term, I think we should probably consider deprecating it and replacing it with `tooling::HeaderIncludes`.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D148793/new/
https://reviews.llvm.org/D148793
More information about the cfe-commits
mailing list