[PATCH] D157610: [include-cleaner][clangd][clang-tidy] Ignore resource dir during include-cleaner analysis.

Viktoriia Bakalova via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 11 10:00:12 PDT 2023


VitaNuo added a comment.

Thanks for the comments!



================
Comment at: clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp:122
   llvm::DenseSet<include_cleaner::Symbol> SeenSymbols;
+  std::string ResourceDir = HS->getHeaderSearchOpts().ResourceDir;
   // FIXME: Find a way to have less code duplication between include-cleaner
----------------
kadircet wrote:
> let's use `HS->getModuleMap().getBuiltinDir()` then we can get away with just comparing that pointer to `H.physical()->getLastRef().getDir()` (same applies to all the other places as well)
This only works in `clangd` code for me. I get `nullptr` for `HS->getModuleMap().getBuiltinDir()` in other places (Clang Tidy check and the library).


================
Comment at: clang-tools-extra/clangd/IncludeCleaner.cpp:309
       continue;
+    auto Dir = llvm::StringRef{MFI.Resolved}.rsplit('/').first;
+    if (Dir == AST.getPreprocessor()
----------------
kadircet wrote:
> let's move this into `mayConsiderUnused`, we also convert this include into a FileEntry in there, so we can directly compare the directory agian.
Ok moved to `mayConsiderUnused` and using the file entry now, but see above regarding comparing the directories.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157610/new/

https://reviews.llvm.org/D157610



More information about the cfe-commits mailing list